documentation.d.ts 3.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430884318843288433884348843588436884378843888439884408844188442884438844488445884468844788448884498845088451884528845388454884558845688457884588845988460884618846288463884648846588466884678846888469884708847188472884738847488475884768847788478884798848088481884828848388484884858848688487884888848988490884918849288493884948849588496884978849888499885008850188502885038850488505885068850788508885098851088511885128851388514885158851688517885188851988520885218852288523885248852588526885278852888529885308853188532885338853488535885368853788538885398854088541885428854388544885458854688547885488854988550885518855288553885548855588556885578855888559885608856188562885638856488565885668856788568885698857088571885728857388574885758857688577885788857988580885818858288583885848858588586885878858888589885908859188592885938859488595885968859788598885998860088601886028860388604886058860688607886088860988610886118861288613886148861588616886178861888619886208862188622886238862488625886268862788628886298863088631886328863388634886358863688637886388863988640886418864288643886448864588646886478864888649886508865188652886538865488655886568865788658886598866088661886628866388664886658866688667886688866988670886718867288673886748867588676886778867888679886808868188682886838868488685886868868788688886898869088691886928869388694886958869688697886988869988700887018870288703887048870588706887078870888709887108871188712887138871488715887168871788718887198872088721887228872388724887258872688727887288872988730887318873288733887348873588736887378873888739887408874188742887438874488745887468874788748887498875088751887528875388754887558875688757887588875988760887618876288763887648876588766887678876888769887708877188772887738877488775887768877788778887798878088781887828878388784887858878688787887888878988790887918879288793887948879588796887978879888799888008880188802888038880488805888068880788808888098881088811888128881388814888158881688817888188881988820888218882288823888248882588826888278882888829888308883188832888338883488835888368883788838888398884088841888428884388844888458884688847888488884988850888518885288853888548885588856888578885888859888608886188862888638886488865888668886788868888698887088871888728887388874888758887688877888788887988880888818888288883888848888588886888878888888889888908889188892888938889488895888968889788898888998890088901889028890388904889058890688907889088890988910889118891288913889148891588916889178891888919889208892188922889238892488925889268892788928889298893088931889328893388934889358893688937889388893988940889418894288943889448894588946889478894888949889508895188952889538895488955889568895788958889598896088961889628896388964889658896688967889688896988970889718897288973889748897588976889778897888979889808898188982889838898488985889868898788988889898899088991889928899388994889958899688997889988899989000890018900289003890048900589006890078900889009890108901189012890138901489015890168901789018890198902089021890228902389024890258902689027890288902989030890318903289033890348903589036890378903889039890408904189042890438904489045890468904789048890498905089051890528905389054890558905689057890588905989060890618906289063890648906589066890678906889069890708907189072890738907489075890768907789078890798908089081890828908389084890858908689087890888908989090890918909289093890948909589096890978909889099891008910189102891038910489105891068910789108891098911089111891128911389114891158911689117891188911989120891218912289123891248912589126891278912889129891308913189132891338913489135891368913789138891398914089141891428914389144891458914689147891488914989150891518915289153891548915589156891578915889159891608916189162891638916489165891668916789168891698917089171891728917389174891758917689177891788917989180891818918289183891848918589186891878918889189891908919189192891938919489195891968919789198891998920089201892028920389204892058920689207892088920989210892118921289213892148921589216892178921889219892208922189222892238922489225892268922789228892298923089231892328923389234892358923689237892388923989240892418924289243892448924589246892478924889249892508925189252892538925489255892568925789258892598926089261892628926389264892658926689267892688926989270892718927289273892748927589276892778927889279892808928189282892838928489285892868928789288892898929089291892928929389294892958929689297892988929989300893018930289303893048930589306893078930889309893108931189312893138931489315893168931789318893198932089321893228932389324893258932689327893288932989330893318933289333893348933589336893378933889339893408934189342893438934489345893468934789348893498935089351893528935389354893558935689357893588935989360893618936289363893648936589366893678936889369893708937189372893738937489375893768937789378893798938089381893828938389384893858938689387893888938989390893918939289393893948939589396893978939889399894008940189402894038940489405894068940789408894098941089411894128941389414894158941689417894188941989420894218942289423894248942589426894278942889429894308943189432894338943489435894368943789438894398944089441894428944389444894458944689447894488944989450894518945289453894548945589456894578945889459894608946189462894638946489465894668946789468894698947089471894728947389474894758947689477894788947989480894818948289483894848948589486894878948889489894908949189492894938949489495894968949789498894998950089501895028950389504895058950689507895088950989510895118951289513895148951589516895178951889519895208952189522895238952489525895268952789528895298953089531895328953389534895358953689537895388953989540895418954289543895448954589546895478954889549895508955189552895538955489555895568955789558895598956089561895628956389564895658956689567895688956989570895718957289573895748957589576895778957889579895808958189582895838958489585895868958789588895898959089591895928959389594895958959689597895988959989600896018960289603896048960589606896078960889609896108961189612896138961489615896168961789618896198962089621896228962389624896258962689627896288962989630896318963289633896348963589636896378963889639896408964189642896438964489645896468964789648896498965089651896528965389654896558965689657896588965989660896618966289663896648966589666896678966889669896708967189672896738967489675896768967789678896798968089681896828968389684896858968689687896888968989690896918969289693896948969589696896978969889699897008970189702897038970489705897068970789708897098971089711897128971389714897158971689717897188971989720897218972289723897248972589726897278972889729897308973189732897338973489735897368973789738897398974089741897428974389744897458974689747897488974989750897518975289753897548975589756897578975889759897608976189762897638976489765897668976789768897698977089771897728977389774897758977689777897788977989780897818978289783897848978589786897878978889789897908979189792897938979489795897968979789798897998980089801898028980389804898058980689807898088980989810898118981289813898148981589816898178981889819898208982189822898238982489825898268982789828898298983089831898328983389834898358983689837898388983989840898418984289843898448984589846898478984889849898508985189852898538985489855898568985789858898598986089861898628986389864898658986689867898688986989870898718987289873898748987589876898778987889879898808988189882898838988489885898868988789888898898989089891898928989389894898958989689897898988989989900899018990289903899048990589906899078990889909899108991189912899138991489915899168991789918899198992089921899228992389924899258992689927899288992989930899318993289933899348993589936899378993889939899408994189942899438994489945899468994789948899498995089951899528995389954899558995689957899588995989960899618996289963899648996589966899678996889969899708997189972899738997489975899768997789978899798998089981899828998389984899858998689987899888998989990899918999289993899948999589996899978999889999900009000190002900039000490005900069000790008900099001090011900129001390014900159001690017900189001990020900219002290023900249002590026900279002890029900309003190032900339003490035900369003790038900399004090041900429004390044900459004690047900489004990050900519005290053900549005590056900579005890059900609006190062900639006490065900669006790068900699007090071900729007390074900759007690077900789007990080900819008290083900849008590086900879008890089900909009190092900939009490095900969009790098900999010090101901029010390104901059010690107901089010990110901119011290113901149011590116901179011890119901209012190122901239012490125901269012790128901299013090131901329013390134901359013690137901389013990140901419014290143901449014590146901479014890149901509015190152901539015490155901569015790158901599016090161901629016390164901659016690167901689016990170901719017290173901749017590176901779017890179901809018190182901839018490185901869018790188901899019090191901929019390194901959019690197901989019990200902019020290203902049020590206902079020890209902109021190212902139021490215902169021790218902199022090221902229022390224902259022690227902289022990230902319023290233902349023590236902379023890239902409024190242902439024490245902469024790248902499025090251902529025390254902559025690257902589025990260902619026290263902649026590266902679026890269902709027190272902739027490275902769027790278902799028090281902829028390284902859028690287902889028990290902919029290293902949029590296902979029890299903009030190302903039030490305903069030790308903099031090311903129031390314903159031690317903189031990320903219032290323903249032590326903279032890329903309033190332903339033490335903369033790338903399034090341903429034390344903459034690347903489034990350903519035290353903549035590356903579035890359903609036190362903639036490365903669036790368903699037090371903729037390374903759037690377903789037990380903819038290383903849038590386903879038890389903909039190392903939039490395903969039790398903999040090401904029040390404904059040690407904089040990410904119041290413904149041590416904179041890419904209042190422904239042490425904269042790428904299043090431904329043390434904359043690437904389043990440904419044290443904449044590446904479044890449904509045190452904539045490455904569045790458904599046090461904629046390464904659046690467904689046990470904719047290473904749047590476904779047890479904809048190482904839048490485904869048790488904899049090491904929049390494904959049690497904989049990500905019050290503905049050590506905079050890509905109051190512905139051490515905169051790518905199052090521905229052390524905259052690527905289052990530905319053290533905349053590536905379053890539905409054190542905439054490545905469054790548905499055090551905529055390554905559055690557905589055990560905619056290563905649056590566905679056890569905709057190572905739057490575905769057790578905799058090581905829058390584905859058690587905889058990590905919059290593905949059590596905979059890599906009060190602906039060490605906069060790608906099061090611906129061390614906159061690617906189061990620906219062290623906249062590626906279062890629906309063190632906339063490635906369063790638906399064090641906429064390644906459064690647906489064990650906519065290653906549065590656906579065890659906609066190662906639066490665906669066790668906699067090671906729067390674906759067690677906789067990680906819068290683906849068590686906879068890689906909069190692906939069490695906969069790698906999070090701907029070390704907059070690707907089070990710907119071290713907149071590716907179071890719907209072190722907239072490725907269072790728907299073090731907329073390734907359073690737907389073990740907419074290743907449074590746907479074890749907509075190752907539075490755907569075790758907599076090761907629076390764907659076690767907689076990770907719077290773907749077590776907779077890779907809078190782907839078490785907869078790788907899079090791907929079390794907959079690797907989079990800908019080290803908049080590806908079080890809908109081190812908139081490815908169081790818908199082090821908229082390824908259082690827908289082990830908319083290833908349083590836908379083890839908409084190842908439084490845908469084790848908499085090851908529085390854908559085690857908589085990860908619086290863908649086590866908679086890869908709087190872908739087490875908769087790878908799088090881908829088390884908859088690887908889088990890908919089290893908949089590896908979089890899909009090190902909039090490905909069090790908909099091090911909129091390914909159091690917909189091990920909219092290923909249092590926909279092890929909309093190932909339093490935909369093790938909399094090941909429094390944909459094690947909489094990950909519095290953909549095590956909579095890959909609096190962909639096490965909669096790968909699097090971909729097390974909759097690977909789097990980909819098290983909849098590986909879098890989909909099190992909939099490995909969099790998909999100091001910029100391004910059100691007910089100991010910119101291013910149101591016910179101891019910209102191022910239102491025910269102791028910299103091031910329103391034910359103691037910389103991040910419104291043910449104591046910479104891049910509105191052910539105491055910569105791058910599106091061910629106391064910659106691067910689106991070910719107291073910749107591076910779107891079910809108191082910839108491085910869108791088910899109091091910929109391094910959109691097910989109991100911019110291103911049110591106911079110891109911109111191112911139111491115911169111791118911199112091121911229112391124911259112691127911289112991130911319113291133911349113591136911379113891139911409114191142911439114491145911469114791148911499115091151911529115391154911559115691157911589115991160911619116291163911649116591166911679116891169911709117191172911739117491175911769117791178911799118091181911829118391184911859118691187911889118991190911919119291193911949119591196911979119891199912009120191202912039120491205912069120791208912099121091211912129121391214912159121691217912189121991220912219122291223912249122591226912279122891229912309123191232912339123491235912369123791238912399124091241912429124391244912459124691247912489124991250912519125291253912549125591256912579125891259912609126191262912639126491265912669126791268912699127091271912729127391274912759127691277912789127991280912819128291283912849128591286912879128891289912909129191292912939129491295912969129791298912999130091301913029130391304913059130691307913089130991310913119131291313913149131591316913179131891319913209132191322913239132491325913269132791328913299133091331913329133391334913359133691337913389133991340913419134291343913449134591346913479134891349913509135191352913539135491355913569135791358913599136091361913629136391364913659136691367913689136991370913719137291373913749137591376913779137891379913809138191382913839138491385913869138791388913899139091391913929139391394913959139691397913989139991400914019140291403914049140591406914079140891409914109141191412914139141491415914169141791418914199142091421914229142391424914259142691427914289142991430914319143291433914349143591436914379143891439914409144191442914439144491445914469144791448914499145091451914529145391454914559145691457914589145991460914619146291463914649146591466914679146891469914709147191472914739147491475914769147791478914799148091481914829148391484914859148691487914889148991490914919149291493914949149591496914979149891499915009150191502915039150491505915069150791508915099151091511915129151391514915159151691517915189151991520915219152291523915249152591526915279152891529915309153191532915339153491535915369153791538915399154091541915429154391544915459154691547915489154991550915519155291553915549155591556915579155891559915609156191562915639156491565915669156791568915699157091571915729157391574915759157691577915789157991580915819158291583915849158591586915879158891589915909159191592915939159491595915969159791598915999160091601916029160391604916059160691607916089160991610916119161291613916149161591616916179161891619916209162191622916239162491625916269162791628916299163091631916329163391634916359163691637916389163991640916419164291643916449164591646916479164891649916509165191652916539165491655916569165791658916599166091661916629166391664916659166691667916689166991670916719167291673916749167591676916779167891679916809168191682916839168491685916869168791688916899169091691916929169391694916959169691697916989169991700917019170291703917049170591706917079170891709917109171191712917139171491715917169171791718917199172091721917229172391724917259172691727917289172991730917319173291733917349173591736917379173891739917409174191742917439174491745917469174791748917499175091751917529175391754917559175691757917589175991760917619176291763917649176591766917679176891769917709177191772917739177491775917769177791778917799178091781917829178391784917859178691787917889178991790917919179291793917949179591796917979179891799918009180191802918039180491805918069180791808918099181091811918129181391814918159181691817918189181991820918219182291823918249182591826918279182891829918309183191832918339183491835918369183791838918399184091841918429184391844918459184691847918489184991850918519185291853918549185591856918579185891859918609186191862918639186491865918669186791868918699187091871918729187391874918759187691877918789187991880918819188291883918849188591886918879188891889918909189191892918939189491895918969189791898918999190091901919029190391904919059190691907919089190991910919119191291913919149191591916919179191891919919209192191922919239192491925919269192791928919299193091931919329193391934919359193691937919389193991940919419194291943919449194591946919479194891949919509195191952919539195491955919569195791958919599196091961919629196391964919659196691967919689196991970919719197291973919749197591976919779197891979919809198191982919839198491985919869198791988919899199091991919929199391994919959199691997919989199992000920019200292003920049200592006920079200892009920109201192012920139201492015920169201792018920199202092021920229202392024920259202692027920289202992030920319203292033920349203592036920379203892039920409204192042920439204492045920469204792048920499205092051920529205392054920559205692057920589205992060920619206292063920649206592066920679206892069920709207192072920739207492075920769207792078920799208092081920829208392084920859208692087920889208992090920919209292093920949209592096920979209892099921009210192102921039210492105921069210792108921099211092111921129211392114921159211692117921189211992120921219212292123921249212592126921279212892129921309213192132921339213492135921369213792138921399214092141921429214392144921459214692147921489214992150921519215292153921549215592156921579215892159921609216192162921639216492165921669216792168921699217092171921729217392174921759217692177921789217992180921819218292183921849218592186921879218892189921909219192192921939219492195921969219792198921999220092201922029220392204922059220692207922089220992210922119221292213922149221592216922179221892219922209222192222922239222492225922269222792228922299223092231922329223392234922359223692237922389223992240922419224292243922449224592246922479224892249922509225192252922539225492255922569225792258922599226092261922629226392264922659226692267922689226992270922719227292273922749227592276922779227892279922809228192282922839228492285922869228792288922899229092291922929229392294922959229692297922989229992300923019230292303923049230592306923079230892309923109231192312923139231492315923169231792318923199232092321923229232392324923259232692327923289232992330923319233292333923349233592336923379233892339923409234192342923439234492345923469234792348923499235092351923529235392354923559235692357923589235992360923619236292363923649236592366923679236892369923709237192372923739237492375923769237792378923799238092381923829238392384923859238692387923889238992390923919239292393923949239592396923979239892399924009240192402924039240492405924069240792408924099241092411924129241392414924159241692417924189241992420924219242292423924249242592426924279242892429924309243192432924339243492435924369243792438924399244092441924429244392444924459244692447924489244992450924519245292453924549245592456924579245892459924609246192462924639246492465924669246792468924699247092471924729247392474924759247692477924789247992480924819248292483924849248592486924879248892489924909249192492924939249492495924969249792498924999250092501925029250392504925059250692507925089250992510925119251292513925149251592516925179251892519925209252192522925239252492525925269252792528925299253092531925329253392534925359253692537925389253992540925419254292543925449254592546925479254892549925509255192552925539255492555925569255792558925599256092561925629256392564925659256692567925689256992570925719257292573925749257592576925779257892579925809258192582925839258492585925869258792588925899259092591925929259392594925959259692597925989259992600926019260292603926049260592606926079260892609926109261192612926139261492615926169261792618926199262092621926229262392624926259262692627926289262992630926319263292633926349263592636926379263892639926409264192642926439264492645926469264792648926499265092651926529265392654926559265692657926589265992660926619266292663926649266592666926679266892669926709267192672926739267492675926769267792678926799268092681926829268392684926859268692687926889268992690926919269292693926949269592696926979269892699927009270192702927039270492705927069270792708927099271092711927129271392714927159271692717927189271992720927219272292723927249272592726927279272892729927309273192732927339273492735927369273792738927399274092741927429274392744927459274692747927489274992750927519275292753927549275592756927579275892759927609276192762927639276492765927669276792768927699277092771927729277392774927759277692777927789277992780927819278292783927849278592786927879278892789927909279192792927939279492795927969279792798927999280092801928029280392804928059280692807928089280992810928119281292813928149281592816928179281892819928209282192822928239282492825928269282792828928299283092831928329283392834928359283692837928389283992840928419284292843928449284592846928479284892849928509285192852928539285492855928569285792858928599286092861928629286392864928659286692867928689286992870928719287292873928749287592876928779287892879928809288192882928839288492885928869288792888928899289092891928929289392894928959289692897928989289992900929019290292903929049290592906929079290892909929109291192912929139291492915929169291792918929199292092921929229292392924929259292692927929289292992930929319293292933929349293592936929379293892939929409294192942929439294492945929469294792948929499295092951929529295392954929559295692957929589295992960929619296292963929649296592966929679296892969929709297192972929739297492975929769297792978929799298092981929829298392984929859298692987929889298992990929919299292993929949299592996929979299892999930009300193002930039300493005930069300793008930099301093011930129301393014930159301693017930189301993020930219302293023930249302593026930279302893029930309303193032930339303493035930369303793038930399304093041930429304393044930459304693047930489304993050930519305293053930549305593056930579305893059930609306193062930639306493065930669306793068930699307093071930729307393074930759307693077930789307993080930819308293083930849308593086930879308893089930909309193092930939309493095930969309793098930999310093101931029310393104931059310693107931089310993110931119311293113931149311593116931179311893119931209312193122931239312493125931269312793128931299313093131931329313393134931359313693137931389313993140931419314293143931449314593146931479314893149931509315193152931539315493155931569315793158931599316093161931629316393164931659316693167931689316993170931719317293173931749317593176931779317893179931809318193182931839318493185931869318793188931899319093191931929319393194931959319693197931989319993200932019320293203932049320593206932079320893209932109321193212932139321493215932169321793218932199322093221932229322393224932259322693227932289322993230932319323293233932349323593236932379323893239932409324193242932439324493245932469324793248932499325093251932529325393254932559325693257932589325993260932619326293263932649326593266932679326893269932709327193272932739327493275932769327793278932799328093281932829328393284932859328693287932889328993290932919329293293932949329593296932979329893299933009330193302933039330493305933069330793308933099331093311933129331393314933159331693317933189331993320933219332293323933249332593326933279332893329933309333193332933339333493335933369333793338933399334093341933429334393344933459334693347933489334993350933519335293353933549335593356933579335893359933609336193362933639336493365933669336793368933699337093371933729337393374933759337693377933789337993380933819338293383933849338593386933879338893389933909339193392933939339493395933969339793398933999340093401934029340393404934059340693407934089340993410934119341293413934149341593416934179341893419934209342193422934239342493425934269342793428934299343093431934329343393434934359343693437934389343993440934419344293443934449344593446934479344893449934509345193452934539345493455934569345793458934599346093461934629346393464934659346693467934689346993470934719347293473934749347593476934779347893479934809348193482934839348493485934869348793488934899349093491934929349393494934959349693497934989349993500935019350293503935049350593506935079350893509935109351193512935139351493515935169351793518935199352093521935229352393524935259352693527935289352993530935319353293533935349353593536935379353893539935409354193542935439354493545935469354793548935499355093551935529355393554935559355693557935589355993560935619356293563935649356593566935679356893569935709357193572935739357493575935769357793578935799358093581935829358393584935859358693587935889358993590935919359293593935949359593596935979359893599936009360193602936039360493605936069360793608936099361093611936129361393614936159361693617936189361993620936219362293623936249362593626936279362893629936309363193632936339363493635936369363793638936399364093641936429364393644936459364693647936489364993650936519365293653936549365593656936579365893659936609366193662936639366493665936669366793668936699367093671936729367393674936759367693677936789367993680936819368293683936849368593686936879368893689936909369193692936939369493695936969369793698936999370093701937029370393704937059370693707937089370993710937119371293713937149371593716937179371893719937209372193722937239372493725937269372793728937299373093731937329373393734937359373693737937389373993740937419374293743937449374593746937479374893749937509375193752937539375493755937569375793758937599376093761937629376393764937659376693767937689376993770937719377293773937749377593776937779377893779937809378193782937839378493785937869378793788937899379093791937929379393794937959379693797937989379993800938019380293803938049380593806
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * 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.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * 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).
  166. * 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.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @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.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used throughout the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. /**
  333. * Message to display when a message has been logged too many times
  334. */
  335. static MessageLimitReached: string;
  336. private static _LogCache;
  337. private static _LogLimitOutputs;
  338. /**
  339. * Gets a value indicating the number of loading errors
  340. * @ignorenaming
  341. */
  342. static errorsCount: number;
  343. /**
  344. * Callback called when a new log is added
  345. */
  346. static OnNewCacheEntry: (entry: string) => void;
  347. private static _CheckLimit;
  348. private static _GenerateLimitMessage;
  349. private static _AddLogEntry;
  350. private static _FormatMessage;
  351. private static _LogDisabled;
  352. private static _LogEnabled;
  353. private static _WarnDisabled;
  354. private static _WarnEnabled;
  355. private static _ErrorDisabled;
  356. private static _ErrorEnabled;
  357. /**
  358. * Log a message to the console
  359. */
  360. static Log: (message: string, limit?: number) => void;
  361. /**
  362. * Write a warning message to the console
  363. */
  364. static Warn: (message: string, limit?: number) => void;
  365. /**
  366. * Write an error message to the console
  367. */
  368. static Error: (message: string, limit?: number) => void;
  369. /**
  370. * Gets current log cache (list of logs)
  371. */
  372. static get LogCache(): string;
  373. /**
  374. * Clears the log cache
  375. */
  376. static ClearLogCache(): void;
  377. /**
  378. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  379. */
  380. static set LogLevels(level: number);
  381. }
  382. }
  383. declare module BABYLON {
  384. /** @hidden */
  385. export class _TypeStore {
  386. /** @hidden */
  387. static RegisteredTypes: {
  388. [key: string]: Object;
  389. };
  390. /** @hidden */
  391. static GetClass(fqdn: string): any;
  392. }
  393. }
  394. declare module BABYLON {
  395. /**
  396. * Helper to manipulate strings
  397. */
  398. export class StringTools {
  399. /**
  400. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static EndsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  408. * @param str Source string
  409. * @param suffix Suffix to search for in the source string
  410. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  411. */
  412. static StartsWith(str: string, suffix: string): boolean;
  413. /**
  414. * Decodes a buffer into a string
  415. * @param buffer The buffer to decode
  416. * @returns The decoded string
  417. */
  418. static Decode(buffer: Uint8Array | Uint16Array): string;
  419. /**
  420. * Encode a buffer to a base64 string
  421. * @param buffer defines the buffer to encode
  422. * @returns the encoded string
  423. */
  424. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  425. /**
  426. * Converts a number to string and pads with preceding zeroes until it is of specified length.
  427. * @param num the number to convert and pad
  428. * @param length the expected length of the string
  429. * @returns the padded string
  430. */
  431. static PadNumber(num: number, length: number): string;
  432. }
  433. }
  434. declare module BABYLON {
  435. /**
  436. * Class containing a set of static utilities functions for deep copy.
  437. */
  438. export class DeepCopier {
  439. /**
  440. * Tries to copy an object by duplicating every property
  441. * @param source defines the source object
  442. * @param destination defines the target object
  443. * @param doNotCopyList defines a list of properties to avoid
  444. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  445. */
  446. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  447. }
  448. }
  449. declare module BABYLON {
  450. /**
  451. * Class containing a set of static utilities functions for precision date
  452. */
  453. export class PrecisionDate {
  454. /**
  455. * Gets either window.performance.now() if supported or Date.now() else
  456. */
  457. static get Now(): number;
  458. }
  459. }
  460. declare module BABYLON {
  461. /** @hidden */
  462. export class _DevTools {
  463. static WarnImport(name: string): string;
  464. }
  465. }
  466. declare module BABYLON {
  467. /**
  468. * Interface used to define the mechanism to get data from the network
  469. */
  470. export interface IWebRequest {
  471. /**
  472. * Returns client's response url
  473. */
  474. responseURL: string;
  475. /**
  476. * Returns client's status
  477. */
  478. status: number;
  479. /**
  480. * Returns client's status as a text
  481. */
  482. statusText: string;
  483. }
  484. }
  485. declare module BABYLON {
  486. /**
  487. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  488. */
  489. export class WebRequest implements IWebRequest {
  490. private readonly _xhr;
  491. /**
  492. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  493. * i.e. when loading files, where the server/service expects an Authorization header
  494. */
  495. static CustomRequestHeaders: {
  496. [key: string]: string;
  497. };
  498. /**
  499. * Add callback functions in this array to update all the requests before they get sent to the network
  500. */
  501. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  502. private _injectCustomRequestHeaders;
  503. /**
  504. * Gets or sets a function to be called when loading progress changes
  505. */
  506. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  507. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  508. /**
  509. * Returns client's state
  510. */
  511. get readyState(): number;
  512. /**
  513. * Returns client's status
  514. */
  515. get status(): number;
  516. /**
  517. * Returns client's status as a text
  518. */
  519. get statusText(): string;
  520. /**
  521. * Returns client's response
  522. */
  523. get response(): any;
  524. /**
  525. * Returns client's response url
  526. */
  527. get responseURL(): string;
  528. /**
  529. * Returns client's response as text
  530. */
  531. get responseText(): string;
  532. /**
  533. * Gets or sets the expected response type
  534. */
  535. get responseType(): XMLHttpRequestResponseType;
  536. set responseType(value: XMLHttpRequestResponseType);
  537. /** @hidden */
  538. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  539. /** @hidden */
  540. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  541. /**
  542. * Cancels any network activity
  543. */
  544. abort(): void;
  545. /**
  546. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  547. * @param body defines an optional request body
  548. */
  549. send(body?: Document | BodyInit | null): void;
  550. /**
  551. * Sets the request method, request URL
  552. * @param method defines the method to use (GET, POST, etc..)
  553. * @param url defines the url to connect with
  554. */
  555. open(method: string, url: string): void;
  556. /**
  557. * Sets the value of a request header.
  558. * @param name The name of the header whose value is to be set
  559. * @param value The value to set as the body of the header
  560. */
  561. setRequestHeader(name: string, value: string): void;
  562. /**
  563. * Get the string containing the text of a particular header's value.
  564. * @param name The name of the header
  565. * @returns The string containing the text of the given header name
  566. */
  567. getResponseHeader(name: string): Nullable<string>;
  568. }
  569. }
  570. declare module BABYLON {
  571. /**
  572. * File request interface
  573. */
  574. export interface IFileRequest {
  575. /**
  576. * Raised when the request is complete (success or error).
  577. */
  578. onCompleteObservable: Observable<IFileRequest>;
  579. /**
  580. * Aborts the request for a file.
  581. */
  582. abort: () => void;
  583. }
  584. }
  585. declare module BABYLON {
  586. /**
  587. * Define options used to create a render target texture
  588. */
  589. export class RenderTargetCreationOptions {
  590. /**
  591. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  592. */
  593. createMipMaps?: boolean;
  594. /**
  595. * Specifies if mipmaps must be generated
  596. */
  597. generateMipMaps?: boolean;
  598. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  599. generateDepthBuffer?: boolean;
  600. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  601. generateStencilBuffer?: boolean;
  602. /** Defines texture type (int by default) */
  603. type?: number;
  604. /** Defines sampling mode (trilinear by default) */
  605. samplingMode?: number;
  606. /** Defines format (RGBA by default) */
  607. format?: number;
  608. /** Defines sample count (1 by default) */
  609. samples?: number;
  610. }
  611. }
  612. declare module BABYLON {
  613. /** Defines the cross module used constants to avoid circular dependencies */
  614. export class Constants {
  615. /** Defines that alpha blending is disabled */
  616. static readonly ALPHA_DISABLE: number;
  617. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  618. static readonly ALPHA_ADD: number;
  619. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  620. static readonly ALPHA_COMBINE: number;
  621. /** Defines that alpha blending is DEST - SRC * DEST */
  622. static readonly ALPHA_SUBTRACT: number;
  623. /** Defines that alpha blending is SRC * DEST */
  624. static readonly ALPHA_MULTIPLY: number;
  625. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  626. static readonly ALPHA_MAXIMIZED: number;
  627. /** Defines that alpha blending is SRC + DEST */
  628. static readonly ALPHA_ONEONE: number;
  629. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  630. static readonly ALPHA_PREMULTIPLIED: number;
  631. /**
  632. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  633. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  634. */
  635. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  636. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  637. static readonly ALPHA_INTERPOLATE: number;
  638. /**
  639. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  640. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  641. */
  642. static readonly ALPHA_SCREENMODE: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA + DST ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEONE: number;
  648. /**
  649. * Defines that alpha blending is SRC * DST ALPHA + DST
  650. * Alpha will be set to 0
  651. */
  652. static readonly ALPHA_ALPHATOCOLOR: number;
  653. /**
  654. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  655. */
  656. static readonly ALPHA_REVERSEONEMINUS: number;
  657. /**
  658. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  659. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  660. */
  661. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  662. /**
  663. * Defines that alpha blending is SRC + DST
  664. * Alpha will be set to SRC ALPHA
  665. */
  666. static readonly ALPHA_ONEONE_ONEZERO: number;
  667. /**
  668. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  669. * Alpha will be set to DST ALPHA
  670. */
  671. static readonly ALPHA_EXCLUSION: number;
  672. /** Defines that alpha blending equation a SUM */
  673. static readonly ALPHA_EQUATION_ADD: number;
  674. /** Defines that alpha blending equation a SUBSTRACTION */
  675. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  676. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  677. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  678. /** Defines that alpha blending equation a MAX operation */
  679. static readonly ALPHA_EQUATION_MAX: number;
  680. /** Defines that alpha blending equation a MIN operation */
  681. static readonly ALPHA_EQUATION_MIN: number;
  682. /**
  683. * Defines that alpha blending equation a DARKEN operation:
  684. * It takes the min of the src and sums the alpha channels.
  685. */
  686. static readonly ALPHA_EQUATION_DARKEN: number;
  687. /** Defines that the resource is not delayed*/
  688. static readonly DELAYLOADSTATE_NONE: number;
  689. /** Defines that the resource was successfully delay loaded */
  690. static readonly DELAYLOADSTATE_LOADED: number;
  691. /** Defines that the resource is currently delay loading */
  692. static readonly DELAYLOADSTATE_LOADING: number;
  693. /** Defines that the resource is delayed and has not started loading */
  694. static readonly DELAYLOADSTATE_NOTLOADED: number;
  695. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  696. static readonly NEVER: number;
  697. /** 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 */
  698. static readonly ALWAYS: number;
  699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  700. static readonly LESS: number;
  701. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  702. static readonly EQUAL: number;
  703. /** 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 */
  704. static readonly LEQUAL: number;
  705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  706. static readonly GREATER: number;
  707. /** 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 */
  708. static readonly GEQUAL: number;
  709. /** 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 */
  710. static readonly NOTEQUAL: number;
  711. /** Passed to stencilOperation to specify that stencil value must be kept */
  712. static readonly KEEP: number;
  713. /** Passed to stencilOperation to specify that stencil value must be zero */
  714. static readonly ZERO: number;
  715. /** Passed to stencilOperation to specify that stencil value must be replaced */
  716. static readonly REPLACE: number;
  717. /** Passed to stencilOperation to specify that stencil value must be incremented */
  718. static readonly INCR: number;
  719. /** Passed to stencilOperation to specify that stencil value must be decremented */
  720. static readonly DECR: number;
  721. /** Passed to stencilOperation to specify that stencil value must be inverted */
  722. static readonly INVERT: number;
  723. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  724. static readonly INCR_WRAP: number;
  725. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  726. static readonly DECR_WRAP: number;
  727. /** Texture is not repeating outside of 0..1 UVs */
  728. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  729. /** Texture is repeating outside of 0..1 UVs */
  730. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  731. /** Texture is repeating and mirrored */
  732. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  733. /** ALPHA */
  734. static readonly TEXTUREFORMAT_ALPHA: number;
  735. /** LUMINANCE */
  736. static readonly TEXTUREFORMAT_LUMINANCE: number;
  737. /** LUMINANCE_ALPHA */
  738. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  739. /** RGB */
  740. static readonly TEXTUREFORMAT_RGB: number;
  741. /** RGBA */
  742. static readonly TEXTUREFORMAT_RGBA: number;
  743. /** RED */
  744. static readonly TEXTUREFORMAT_RED: number;
  745. /** RED (2nd reference) */
  746. static readonly TEXTUREFORMAT_R: number;
  747. /** RG */
  748. static readonly TEXTUREFORMAT_RG: number;
  749. /** RED_INTEGER */
  750. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  751. /** RED_INTEGER (2nd reference) */
  752. static readonly TEXTUREFORMAT_R_INTEGER: number;
  753. /** RG_INTEGER */
  754. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  755. /** RGB_INTEGER */
  756. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  757. /** RGBA_INTEGER */
  758. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  759. /** BGRA */
  760. static readonly TEXTUREFORMAT_BGRA: number;
  761. /** Depth 24 bits + Stencil 8 bits */
  762. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  763. /** Depth 32 bits float */
  764. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  765. /** Compressed BC7 */
  766. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  767. /** Compressed BC6 unsigned float */
  768. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  769. /** Compressed BC6 signed float */
  770. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  771. /** Compressed BC3 */
  772. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  773. /** Compressed BC2 */
  774. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  775. /** Compressed BC1 */
  776. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  777. /** UNSIGNED_BYTE */
  778. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  779. /** UNSIGNED_BYTE (2nd reference) */
  780. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  781. /** FLOAT */
  782. static readonly TEXTURETYPE_FLOAT: number;
  783. /** HALF_FLOAT */
  784. static readonly TEXTURETYPE_HALF_FLOAT: number;
  785. /** BYTE */
  786. static readonly TEXTURETYPE_BYTE: number;
  787. /** SHORT */
  788. static readonly TEXTURETYPE_SHORT: number;
  789. /** UNSIGNED_SHORT */
  790. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  791. /** INT */
  792. static readonly TEXTURETYPE_INT: number;
  793. /** UNSIGNED_INT */
  794. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  795. /** UNSIGNED_SHORT_4_4_4_4 */
  796. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  797. /** UNSIGNED_SHORT_5_5_5_1 */
  798. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  799. /** UNSIGNED_SHORT_5_6_5 */
  800. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  801. /** UNSIGNED_INT_2_10_10_10_REV */
  802. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  803. /** UNSIGNED_INT_24_8 */
  804. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  805. /** UNSIGNED_INT_10F_11F_11F_REV */
  806. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  807. /** UNSIGNED_INT_5_9_9_9_REV */
  808. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  809. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  810. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  811. /** nearest is mag = nearest and min = nearest and no mip */
  812. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  813. /** mag = nearest and min = nearest and mip = none */
  814. static readonly TEXTURE_NEAREST_NEAREST: number;
  815. /** Bilinear is mag = linear and min = linear and no mip */
  816. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  817. /** mag = linear and min = linear and mip = none */
  818. static readonly TEXTURE_LINEAR_LINEAR: number;
  819. /** Trilinear is mag = linear and min = linear and mip = linear */
  820. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  821. /** Trilinear is mag = linear and min = linear and mip = linear */
  822. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  823. /** mag = nearest and min = nearest and mip = nearest */
  824. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  825. /** mag = nearest and min = linear and mip = nearest */
  826. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  827. /** mag = nearest and min = linear and mip = linear */
  828. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  829. /** mag = nearest and min = linear and mip = none */
  830. static readonly TEXTURE_NEAREST_LINEAR: number;
  831. /** nearest is mag = nearest and min = nearest and mip = linear */
  832. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  833. /** mag = linear and min = nearest and mip = nearest */
  834. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  835. /** mag = linear and min = nearest and mip = linear */
  836. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  838. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  839. /** mag = linear and min = nearest and mip = none */
  840. static readonly TEXTURE_LINEAR_NEAREST: number;
  841. /** Explicit coordinates mode */
  842. static readonly TEXTURE_EXPLICIT_MODE: number;
  843. /** Spherical coordinates mode */
  844. static readonly TEXTURE_SPHERICAL_MODE: number;
  845. /** Planar coordinates mode */
  846. static readonly TEXTURE_PLANAR_MODE: number;
  847. /** Cubic coordinates mode */
  848. static readonly TEXTURE_CUBIC_MODE: number;
  849. /** Projection coordinates mode */
  850. static readonly TEXTURE_PROJECTION_MODE: number;
  851. /** Skybox coordinates mode */
  852. static readonly TEXTURE_SKYBOX_MODE: number;
  853. /** Inverse Cubic coordinates mode */
  854. static readonly TEXTURE_INVCUBIC_MODE: number;
  855. /** Equirectangular coordinates mode */
  856. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  857. /** Equirectangular Fixed coordinates mode */
  858. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  859. /** Equirectangular Fixed Mirrored coordinates mode */
  860. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  861. /** Offline (baking) quality for texture filtering */
  862. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  863. /** High quality for texture filtering */
  864. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  865. /** Medium quality for texture filtering */
  866. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  867. /** Low quality for texture filtering */
  868. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  869. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  870. static readonly SCALEMODE_FLOOR: number;
  871. /** Defines that texture rescaling will look for the nearest power of 2 size */
  872. static readonly SCALEMODE_NEAREST: number;
  873. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  874. static readonly SCALEMODE_CEILING: number;
  875. /**
  876. * The dirty texture flag value
  877. */
  878. static readonly MATERIAL_TextureDirtyFlag: number;
  879. /**
  880. * The dirty light flag value
  881. */
  882. static readonly MATERIAL_LightDirtyFlag: number;
  883. /**
  884. * The dirty fresnel flag value
  885. */
  886. static readonly MATERIAL_FresnelDirtyFlag: number;
  887. /**
  888. * The dirty attribute flag value
  889. */
  890. static readonly MATERIAL_AttributesDirtyFlag: number;
  891. /**
  892. * The dirty misc flag value
  893. */
  894. static readonly MATERIAL_MiscDirtyFlag: number;
  895. /**
  896. * The dirty prepass flag value
  897. */
  898. static readonly MATERIAL_PrePassDirtyFlag: number;
  899. /**
  900. * The all dirty flag value
  901. */
  902. static readonly MATERIAL_AllDirtyFlag: number;
  903. /**
  904. * Returns the triangle fill mode
  905. */
  906. static readonly MATERIAL_TriangleFillMode: number;
  907. /**
  908. * Returns the wireframe mode
  909. */
  910. static readonly MATERIAL_WireFrameFillMode: number;
  911. /**
  912. * Returns the point fill mode
  913. */
  914. static readonly MATERIAL_PointFillMode: number;
  915. /**
  916. * Returns the point list draw mode
  917. */
  918. static readonly MATERIAL_PointListDrawMode: number;
  919. /**
  920. * Returns the line list draw mode
  921. */
  922. static readonly MATERIAL_LineListDrawMode: number;
  923. /**
  924. * Returns the line loop draw mode
  925. */
  926. static readonly MATERIAL_LineLoopDrawMode: number;
  927. /**
  928. * Returns the line strip draw mode
  929. */
  930. static readonly MATERIAL_LineStripDrawMode: number;
  931. /**
  932. * Returns the triangle strip draw mode
  933. */
  934. static readonly MATERIAL_TriangleStripDrawMode: number;
  935. /**
  936. * Returns the triangle fan draw mode
  937. */
  938. static readonly MATERIAL_TriangleFanDrawMode: number;
  939. /**
  940. * Stores the clock-wise side orientation
  941. */
  942. static readonly MATERIAL_ClockWiseSideOrientation: number;
  943. /**
  944. * Stores the counter clock-wise side orientation
  945. */
  946. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  947. /**
  948. * Nothing
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_NothingTrigger: number;
  952. /**
  953. * On pick
  954. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPickTrigger: number;
  957. /**
  958. * On left pick
  959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnLeftPickTrigger: number;
  962. /**
  963. * On right pick
  964. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnRightPickTrigger: number;
  967. /**
  968. * On center pick
  969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnCenterPickTrigger: number;
  972. /**
  973. * On pick down
  974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnPickDownTrigger: number;
  977. /**
  978. * On double pick
  979. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnDoublePickTrigger: number;
  982. /**
  983. * On pick up
  984. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  985. */
  986. static readonly ACTION_OnPickUpTrigger: number;
  987. /**
  988. * On pick out.
  989. * This trigger will only be raised if you also declared a OnPickDown
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnPickOutTrigger: number;
  993. /**
  994. * On long press
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnLongPressTrigger: number;
  998. /**
  999. * On pointer over
  1000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1001. */
  1002. static readonly ACTION_OnPointerOverTrigger: number;
  1003. /**
  1004. * On pointer out
  1005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1006. */
  1007. static readonly ACTION_OnPointerOutTrigger: number;
  1008. /**
  1009. * On every frame
  1010. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1011. */
  1012. static readonly ACTION_OnEveryFrameTrigger: number;
  1013. /**
  1014. * On intersection enter
  1015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1016. */
  1017. static readonly ACTION_OnIntersectionEnterTrigger: number;
  1018. /**
  1019. * On intersection exit
  1020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1021. */
  1022. static readonly ACTION_OnIntersectionExitTrigger: number;
  1023. /**
  1024. * On key down
  1025. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1026. */
  1027. static readonly ACTION_OnKeyDownTrigger: number;
  1028. /**
  1029. * On key up
  1030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1031. */
  1032. static readonly ACTION_OnKeyUpTrigger: number;
  1033. /**
  1034. * Billboard mode will only apply to Y axis
  1035. */
  1036. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1037. /**
  1038. * Billboard mode will apply to all axes
  1039. */
  1040. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1041. /**
  1042. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1043. */
  1044. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1045. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1046. * Test order :
  1047. * Is the bounding sphere outside the frustum ?
  1048. * If not, are the bounding box vertices outside the frustum ?
  1049. * It not, then the cullable object is in the frustum.
  1050. */
  1051. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1052. /** Culling strategy : Bounding Sphere Only.
  1053. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1054. * It's also less accurate than the standard because some not visible objects can still be selected.
  1055. * Test : is the bounding sphere outside the frustum ?
  1056. * If not, then the cullable object is in the frustum.
  1057. */
  1058. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1059. /** Culling strategy : Optimistic Inclusion.
  1060. * This in an inclusion test first, then the standard exclusion test.
  1061. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1062. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1063. * Anyway, it's as accurate as the standard strategy.
  1064. * Test :
  1065. * Is the cullable object bounding sphere center in the frustum ?
  1066. * If not, apply the default culling strategy.
  1067. */
  1068. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1069. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1070. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1071. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1072. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1073. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1074. * Test :
  1075. * Is the cullable object bounding sphere center in the frustum ?
  1076. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1077. */
  1078. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1079. /**
  1080. * No logging while loading
  1081. */
  1082. static readonly SCENELOADER_NO_LOGGING: number;
  1083. /**
  1084. * Minimal logging while loading
  1085. */
  1086. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1087. /**
  1088. * Summary logging while loading
  1089. */
  1090. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1091. /**
  1092. * Detailed logging while loading
  1093. */
  1094. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1095. /**
  1096. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1097. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1098. */
  1099. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1100. /**
  1101. * Constant used to retrieve the position texture index in the textures array in the prepass
  1102. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1103. */
  1104. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1105. /**
  1106. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1107. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1108. */
  1109. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1110. /**
  1111. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1112. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1113. */
  1114. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1115. /**
  1116. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1117. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1118. */
  1119. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1120. /**
  1121. * Constant used to retrieve depth index in the textures array in the prepass
  1122. * using the getIndex(Constants.PREPASS_DEPTH_TEXTURE_TYPE)
  1123. */
  1124. static readonly PREPASS_DEPTH_TEXTURE_TYPE: number;
  1125. /**
  1126. * Constant used to retrieve normal index in the textures array in the prepass
  1127. * using the getIndex(Constants.PREPASS_NORMAL_TEXTURE_TYPE)
  1128. */
  1129. static readonly PREPASS_NORMAL_TEXTURE_TYPE: number;
  1130. /**
  1131. * Constant used to retrieve albedo index in the textures array in the prepass
  1132. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1133. */
  1134. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1135. /**
  1136. * Prefixes used by the engine for custom effects
  1137. */
  1138. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1139. }
  1140. }
  1141. declare module BABYLON {
  1142. /** @hidden */
  1143. export interface HardwareTextureWrapper {
  1144. underlyingResource: any;
  1145. set(hardwareTexture: any): void;
  1146. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1147. reset(): void;
  1148. release(): void;
  1149. }
  1150. }
  1151. declare module BABYLON {
  1152. /**
  1153. * This represents the required contract to create a new type of texture loader.
  1154. */
  1155. export interface IInternalTextureLoader {
  1156. /**
  1157. * Defines whether the loader supports cascade loading the different faces.
  1158. */
  1159. supportCascades: boolean;
  1160. /**
  1161. * This returns if the loader support the current file information.
  1162. * @param extension defines the file extension of the file being loaded
  1163. * @param mimeType defines the optional mime type of the file being loaded
  1164. * @returns true if the loader can load the specified file
  1165. */
  1166. canLoad(extension: string, mimeType?: string): boolean;
  1167. /**
  1168. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1169. * @param data contains the texture data
  1170. * @param texture defines the BabylonJS internal texture
  1171. * @param createPolynomials will be true if polynomials have been requested
  1172. * @param onLoad defines the callback to trigger once the texture is ready
  1173. * @param onError defines the callback to trigger in case of error
  1174. * @param options options to be passed to the loader
  1175. */
  1176. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1177. /**
  1178. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1179. * @param data contains the texture data
  1180. * @param texture defines the BabylonJS internal texture
  1181. * @param callback defines the method to call once ready to upload
  1182. * @param options options to be passed to the loader
  1183. */
  1184. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1185. }
  1186. }
  1187. declare module BABYLON {
  1188. /**
  1189. * @hidden
  1190. */
  1191. export interface IColor4Like {
  1192. r: float;
  1193. g: float;
  1194. b: float;
  1195. a: float;
  1196. }
  1197. /**
  1198. * @hidden
  1199. */
  1200. export interface IColor3Like {
  1201. r: float;
  1202. g: float;
  1203. b: float;
  1204. }
  1205. /**
  1206. * @hidden
  1207. */
  1208. export interface IVector4Like {
  1209. x: float;
  1210. y: float;
  1211. z: float;
  1212. w: float;
  1213. }
  1214. /**
  1215. * @hidden
  1216. */
  1217. export interface IVector3Like {
  1218. x: float;
  1219. y: float;
  1220. z: float;
  1221. }
  1222. /**
  1223. * @hidden
  1224. */
  1225. export interface IVector2Like {
  1226. x: float;
  1227. y: float;
  1228. }
  1229. /**
  1230. * @hidden
  1231. */
  1232. export interface IMatrixLike {
  1233. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1234. updateFlag: int;
  1235. }
  1236. /**
  1237. * @hidden
  1238. */
  1239. export interface IViewportLike {
  1240. x: float;
  1241. y: float;
  1242. width: float;
  1243. height: float;
  1244. }
  1245. /**
  1246. * @hidden
  1247. */
  1248. export interface IPlaneLike {
  1249. normal: IVector3Like;
  1250. d: float;
  1251. normalize(): void;
  1252. }
  1253. }
  1254. declare module BABYLON {
  1255. /**
  1256. * Class used to store and describe the pipeline context associated with an effect
  1257. */
  1258. export interface IPipelineContext {
  1259. /**
  1260. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1261. */
  1262. isAsync: boolean;
  1263. /**
  1264. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1265. */
  1266. isReady: boolean;
  1267. /** @hidden */
  1268. _name?: string;
  1269. /** @hidden */
  1270. _getVertexShaderCode(): string | null;
  1271. /** @hidden */
  1272. _getFragmentShaderCode(): string | null;
  1273. /** @hidden */
  1274. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1275. /** @hidden */
  1276. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1277. [key: string]: number;
  1278. }, uniformsNames: string[], uniforms: {
  1279. [key: string]: Nullable<WebGLUniformLocation>;
  1280. }, samplerList: string[], samplers: {
  1281. [key: string]: number;
  1282. }, attributesNames: string[], attributes: number[]): void;
  1283. /** Releases the resources associated with the pipeline. */
  1284. dispose(): void;
  1285. /**
  1286. * Sets an integer value on a uniform variable.
  1287. * @param uniformName Name of the variable.
  1288. * @param value Value to be set.
  1289. */
  1290. setInt(uniformName: string, value: number): void;
  1291. /**
  1292. * Sets an int2 value on a uniform variable.
  1293. * @param uniformName Name of the variable.
  1294. * @param x First int in int2.
  1295. * @param y Second int in int2.
  1296. */
  1297. setInt2(uniformName: string, x: number, y: number): void;
  1298. /**
  1299. * Sets an int3 value on a uniform variable.
  1300. * @param uniformName Name of the variable.
  1301. * @param x First int in int3.
  1302. * @param y Second int in int3.
  1303. * @param z Third int in int3.
  1304. */
  1305. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1306. /**
  1307. * Sets an int4 value on a uniform variable.
  1308. * @param uniformName Name of the variable.
  1309. * @param x First int in int4.
  1310. * @param y Second int in int4.
  1311. * @param z Third int in int4.
  1312. * @param w Fourth int in int4.
  1313. */
  1314. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1315. /**
  1316. * Sets an int array on a uniform variable.
  1317. * @param uniformName Name of the variable.
  1318. * @param array array to be set.
  1319. */
  1320. setIntArray(uniformName: string, array: Int32Array): void;
  1321. /**
  1322. * 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)
  1323. * @param uniformName Name of the variable.
  1324. * @param array array to be set.
  1325. */
  1326. setIntArray2(uniformName: string, array: Int32Array): void;
  1327. /**
  1328. * 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)
  1329. * @param uniformName Name of the variable.
  1330. * @param array array to be set.
  1331. */
  1332. setIntArray3(uniformName: string, array: Int32Array): void;
  1333. /**
  1334. * 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)
  1335. * @param uniformName Name of the variable.
  1336. * @param array array to be set.
  1337. */
  1338. setIntArray4(uniformName: string, array: Int32Array): void;
  1339. /**
  1340. * Sets an array on a uniform variable.
  1341. * @param uniformName Name of the variable.
  1342. * @param array array to be set.
  1343. */
  1344. setArray(uniformName: string, array: number[] | Float32Array): void;
  1345. /**
  1346. * 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)
  1347. * @param uniformName Name of the variable.
  1348. * @param array array to be set.
  1349. */
  1350. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1351. /**
  1352. * 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)
  1353. * @param uniformName Name of the variable.
  1354. * @param array array to be set.
  1355. */
  1356. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1357. /**
  1358. * 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)
  1359. * @param uniformName Name of the variable.
  1360. * @param array array to be set.
  1361. */
  1362. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1363. /**
  1364. * Sets matrices on a uniform variable.
  1365. * @param uniformName Name of the variable.
  1366. * @param matrices matrices to be set.
  1367. */
  1368. setMatrices(uniformName: string, matrices: Float32Array): void;
  1369. /**
  1370. * Sets matrix on a uniform variable.
  1371. * @param uniformName Name of the variable.
  1372. * @param matrix matrix to be set.
  1373. */
  1374. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1375. /**
  1376. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  1377. * @param uniformName Name of the variable.
  1378. * @param matrix matrix to be set.
  1379. */
  1380. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1381. /**
  1382. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1383. * @param uniformName Name of the variable.
  1384. * @param matrix matrix to be set.
  1385. */
  1386. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1387. /**
  1388. * Sets a float on a uniform variable.
  1389. * @param uniformName Name of the variable.
  1390. * @param value value to be set.
  1391. */
  1392. setFloat(uniformName: string, value: number): void;
  1393. /**
  1394. * Sets a Vector2 on a uniform variable.
  1395. * @param uniformName Name of the variable.
  1396. * @param vector2 vector2 to be set.
  1397. */
  1398. setVector2(uniformName: string, vector2: IVector2Like): void;
  1399. /**
  1400. * Sets a float2 on a uniform variable.
  1401. * @param uniformName Name of the variable.
  1402. * @param x First float in float2.
  1403. * @param y Second float in float2.
  1404. */
  1405. setFloat2(uniformName: string, x: number, y: number): void;
  1406. /**
  1407. * Sets a Vector3 on a uniform variable.
  1408. * @param uniformName Name of the variable.
  1409. * @param vector3 Value to be set.
  1410. */
  1411. setVector3(uniformName: string, vector3: IVector3Like): void;
  1412. /**
  1413. * Sets a float3 on a uniform variable.
  1414. * @param uniformName Name of the variable.
  1415. * @param x First float in float3.
  1416. * @param y Second float in float3.
  1417. * @param z Third float in float3.
  1418. */
  1419. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1420. /**
  1421. * Sets a Vector4 on a uniform variable.
  1422. * @param uniformName Name of the variable.
  1423. * @param vector4 Value to be set.
  1424. */
  1425. setVector4(uniformName: string, vector4: IVector4Like): void;
  1426. /**
  1427. * Sets a float4 on a uniform variable.
  1428. * @param uniformName Name of the variable.
  1429. * @param x First float in float4.
  1430. * @param y Second float in float4.
  1431. * @param z Third float in float4.
  1432. * @param w Fourth float in float4.
  1433. */
  1434. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1435. /**
  1436. * Sets a Color3 on a uniform variable.
  1437. * @param uniformName Name of the variable.
  1438. * @param color3 Value to be set.
  1439. */
  1440. setColor3(uniformName: string, color3: IColor3Like): void;
  1441. /**
  1442. * Sets a Color4 on a uniform variable.
  1443. * @param uniformName Name of the variable.
  1444. * @param color3 Value to be set.
  1445. * @param alpha Alpha value to be set.
  1446. */
  1447. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1448. /**
  1449. * Sets a Color4 on a uniform variable
  1450. * @param uniformName defines the name of the variable
  1451. * @param color4 defines the value to be set
  1452. */
  1453. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1454. }
  1455. }
  1456. declare module BABYLON {
  1457. /**
  1458. * Class used to store gfx data (like WebGLBuffer)
  1459. */
  1460. export class DataBuffer {
  1461. private static _Counter;
  1462. /**
  1463. * Gets or sets the number of objects referencing this buffer
  1464. */
  1465. references: number;
  1466. /** Gets or sets the size of the underlying buffer */
  1467. capacity: number;
  1468. /**
  1469. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1470. */
  1471. is32Bits: boolean;
  1472. /**
  1473. * Gets the underlying buffer
  1474. */
  1475. get underlyingResource(): any;
  1476. /**
  1477. * Gets the unique id of this buffer
  1478. */
  1479. readonly uniqueId: number;
  1480. /**
  1481. * Constructs the buffer
  1482. */
  1483. constructor();
  1484. }
  1485. }
  1486. declare module BABYLON {
  1487. /** @hidden */
  1488. export interface IShaderProcessor {
  1489. attributeProcessor?: (attribute: string, preProcessors: {
  1490. [key: string]: string;
  1491. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1492. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1493. [key: string]: string;
  1494. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1495. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1496. [key: string]: string;
  1497. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1498. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1499. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1500. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1501. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1502. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1503. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1504. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1505. vertexCode: string;
  1506. fragmentCode: string;
  1507. };
  1508. }
  1509. }
  1510. declare module BABYLON {
  1511. /** @hidden */
  1512. export interface ShaderProcessingContext {
  1513. }
  1514. /** @hidden */
  1515. export interface ProcessingOptions {
  1516. defines: string[];
  1517. indexParameters: any;
  1518. isFragment: boolean;
  1519. shouldUseHighPrecisionShader: boolean;
  1520. supportsUniformBuffers: boolean;
  1521. shadersRepository: string;
  1522. includesShadersStore: {
  1523. [key: string]: string;
  1524. };
  1525. processor: Nullable<IShaderProcessor>;
  1526. version: string;
  1527. platformName: string;
  1528. lookForClosingBracketForUniformBuffer?: boolean;
  1529. processingContext: Nullable<ShaderProcessingContext>;
  1530. }
  1531. }
  1532. declare module BABYLON {
  1533. /** @hidden */
  1534. export class ShaderCodeNode {
  1535. line: string;
  1536. children: ShaderCodeNode[];
  1537. additionalDefineKey?: string;
  1538. additionalDefineValue?: string;
  1539. isValid(preprocessors: {
  1540. [key: string]: string;
  1541. }): boolean;
  1542. process(preprocessors: {
  1543. [key: string]: string;
  1544. }, options: ProcessingOptions): string;
  1545. }
  1546. }
  1547. declare module BABYLON {
  1548. /** @hidden */
  1549. export class ShaderCodeCursor {
  1550. private _lines;
  1551. lineIndex: number;
  1552. get currentLine(): string;
  1553. get canRead(): boolean;
  1554. set lines(value: string[]);
  1555. }
  1556. }
  1557. declare module BABYLON {
  1558. /** @hidden */
  1559. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1560. process(preprocessors: {
  1561. [key: string]: string;
  1562. }, options: ProcessingOptions): string;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /** @hidden */
  1567. export class ShaderDefineExpression {
  1568. isTrue(preprocessors: {
  1569. [key: string]: string;
  1570. }): boolean;
  1571. private static _OperatorPriority;
  1572. private static _Stack;
  1573. static postfixToInfix(postfix: string[]): string;
  1574. static infixToPostfix(infix: string): string[];
  1575. }
  1576. }
  1577. declare module BABYLON {
  1578. /** @hidden */
  1579. export class ShaderCodeTestNode extends ShaderCodeNode {
  1580. testExpression: ShaderDefineExpression;
  1581. isValid(preprocessors: {
  1582. [key: string]: string;
  1583. }): boolean;
  1584. }
  1585. }
  1586. declare module BABYLON {
  1587. /** @hidden */
  1588. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1589. define: string;
  1590. not: boolean;
  1591. constructor(define: string, not?: boolean);
  1592. isTrue(preprocessors: {
  1593. [key: string]: string;
  1594. }): boolean;
  1595. }
  1596. }
  1597. declare module BABYLON {
  1598. /** @hidden */
  1599. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1600. leftOperand: ShaderDefineExpression;
  1601. rightOperand: ShaderDefineExpression;
  1602. isTrue(preprocessors: {
  1603. [key: string]: string;
  1604. }): boolean;
  1605. }
  1606. }
  1607. declare module BABYLON {
  1608. /** @hidden */
  1609. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1610. leftOperand: ShaderDefineExpression;
  1611. rightOperand: ShaderDefineExpression;
  1612. isTrue(preprocessors: {
  1613. [key: string]: string;
  1614. }): boolean;
  1615. }
  1616. }
  1617. declare module BABYLON {
  1618. /** @hidden */
  1619. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1620. define: string;
  1621. operand: string;
  1622. testValue: string;
  1623. constructor(define: string, operand: string, testValue: string);
  1624. isTrue(preprocessors: {
  1625. [key: string]: string;
  1626. }): boolean;
  1627. }
  1628. }
  1629. declare module BABYLON {
  1630. /**
  1631. * Class used to enable access to offline support
  1632. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1633. */
  1634. export interface IOfflineProvider {
  1635. /**
  1636. * Gets a boolean indicating if scene must be saved in the database
  1637. */
  1638. enableSceneOffline: boolean;
  1639. /**
  1640. * Gets a boolean indicating if textures must be saved in the database
  1641. */
  1642. enableTexturesOffline: boolean;
  1643. /**
  1644. * Open the offline support and make it available
  1645. * @param successCallback defines the callback to call on success
  1646. * @param errorCallback defines the callback to call on error
  1647. */
  1648. open(successCallback: () => void, errorCallback: () => void): void;
  1649. /**
  1650. * Loads an image from the offline support
  1651. * @param url defines the url to load from
  1652. * @param image defines the target DOM image
  1653. */
  1654. loadImage(url: string, image: HTMLImageElement): void;
  1655. /**
  1656. * Loads a file from offline support
  1657. * @param url defines the URL to load from
  1658. * @param sceneLoaded defines a callback to call on success
  1659. * @param progressCallBack defines a callback to call when progress changed
  1660. * @param errorCallback defines a callback to call on error
  1661. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1662. */
  1663. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1664. }
  1665. }
  1666. declare module BABYLON {
  1667. /**
  1668. * Class used to help managing file picking and drag'n'drop
  1669. * File Storage
  1670. */
  1671. export class FilesInputStore {
  1672. /**
  1673. * List of files ready to be loaded
  1674. */
  1675. static FilesToLoad: {
  1676. [key: string]: File;
  1677. };
  1678. }
  1679. }
  1680. declare module BABYLON {
  1681. /**
  1682. * Class used to define a retry strategy when error happens while loading assets
  1683. */
  1684. export class RetryStrategy {
  1685. /**
  1686. * Function used to defines an exponential back off strategy
  1687. * @param maxRetries defines the maximum number of retries (3 by default)
  1688. * @param baseInterval defines the interval between retries
  1689. * @returns the strategy function to use
  1690. */
  1691. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1692. }
  1693. }
  1694. declare module BABYLON {
  1695. /**
  1696. * @ignore
  1697. * Application error to support additional information when loading a file
  1698. */
  1699. export abstract class BaseError extends Error {
  1700. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1701. }
  1702. }
  1703. declare module BABYLON {
  1704. /** @ignore */
  1705. export class LoadFileError extends BaseError {
  1706. request?: WebRequest;
  1707. file?: File;
  1708. /**
  1709. * Creates a new LoadFileError
  1710. * @param message defines the message of the error
  1711. * @param request defines the optional web request
  1712. * @param file defines the optional file
  1713. */
  1714. constructor(message: string, object?: WebRequest | File);
  1715. }
  1716. /** @ignore */
  1717. export class RequestFileError extends BaseError {
  1718. request: WebRequest;
  1719. /**
  1720. * Creates a new LoadFileError
  1721. * @param message defines the message of the error
  1722. * @param request defines the optional web request
  1723. */
  1724. constructor(message: string, request: WebRequest);
  1725. }
  1726. /** @ignore */
  1727. export class ReadFileError extends BaseError {
  1728. file: File;
  1729. /**
  1730. * Creates a new ReadFileError
  1731. * @param message defines the message of the error
  1732. * @param file defines the optional file
  1733. */
  1734. constructor(message: string, file: File);
  1735. }
  1736. /**
  1737. * @hidden
  1738. */
  1739. export class FileTools {
  1740. /**
  1741. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1742. */
  1743. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1744. /**
  1745. * Gets or sets the base URL to use to load assets
  1746. */
  1747. static BaseUrl: string;
  1748. /**
  1749. * Default behaviour for cors in the application.
  1750. * It can be a string if the expected behavior is identical in the entire app.
  1751. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1752. */
  1753. static CorsBehavior: string | ((url: string | string[]) => string);
  1754. /**
  1755. * Gets or sets a function used to pre-process url before using them to load assets
  1756. */
  1757. static PreprocessUrl: (url: string) => string;
  1758. /**
  1759. * Removes unwanted characters from an url
  1760. * @param url defines the url to clean
  1761. * @returns the cleaned url
  1762. */
  1763. private static _CleanUrl;
  1764. /**
  1765. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1766. * @param url define the url we are trying
  1767. * @param element define the dom element where to configure the cors policy
  1768. */
  1769. static SetCorsBehavior(url: string | string[], element: {
  1770. crossOrigin: string | null;
  1771. }): void;
  1772. /**
  1773. * Loads an image as an HTMLImageElement.
  1774. * @param input url string, ArrayBuffer, or Blob to load
  1775. * @param onLoad callback called when the image successfully loads
  1776. * @param onError callback called when the image fails to load
  1777. * @param offlineProvider offline provider for caching
  1778. * @param mimeType optional mime type
  1779. * @returns the HTMLImageElement of the loaded image
  1780. */
  1781. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1782. /**
  1783. * Reads a file from a File object
  1784. * @param file defines the file to load
  1785. * @param onSuccess defines the callback to call when data is loaded
  1786. * @param onProgress defines the callback to call during loading process
  1787. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1788. * @param onError defines the callback to call when an error occurs
  1789. * @returns a file request object
  1790. */
  1791. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1792. /**
  1793. * Loads a file from a url
  1794. * @param url url to load
  1795. * @param onSuccess callback called when the file successfully loads
  1796. * @param onProgress callback called while file is loading (if the server supports this mode)
  1797. * @param offlineProvider defines the offline provider for caching
  1798. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1799. * @param onError callback called when the file fails to load
  1800. * @returns a file request object
  1801. */
  1802. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1803. /**
  1804. * Loads a file
  1805. * @param url url to load
  1806. * @param onSuccess callback called when the file successfully loads
  1807. * @param onProgress callback called while file is loading (if the server supports this mode)
  1808. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1809. * @param onError callback called when the file fails to load
  1810. * @param onOpened callback called when the web request is opened
  1811. * @returns a file request object
  1812. */
  1813. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1814. /**
  1815. * Checks if the loaded document was accessed via `file:`-Protocol.
  1816. * @returns boolean
  1817. */
  1818. static IsFileURL(): boolean;
  1819. }
  1820. }
  1821. declare module BABYLON {
  1822. /** @hidden */
  1823. export class ShaderProcessor {
  1824. static Initialize(options: ProcessingOptions): void;
  1825. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1826. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1827. vertexCode: string;
  1828. fragmentCode: string;
  1829. };
  1830. private static _ProcessPrecision;
  1831. private static _ExtractOperation;
  1832. private static _BuildSubExpression;
  1833. private static _BuildExpression;
  1834. private static _MoveCursorWithinIf;
  1835. private static _MoveCursor;
  1836. private static _EvaluatePreProcessors;
  1837. private static _PreparePreProcessors;
  1838. private static _ProcessShaderConversion;
  1839. private static _ProcessIncludes;
  1840. /**
  1841. * Loads a file from a url
  1842. * @param url url to load
  1843. * @param onSuccess callback called when the file successfully loads
  1844. * @param onProgress callback called while file is loading (if the server supports this mode)
  1845. * @param offlineProvider defines the offline provider for caching
  1846. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1847. * @param onError callback called when the file fails to load
  1848. * @returns a file request object
  1849. * @hidden
  1850. */
  1851. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1852. }
  1853. }
  1854. declare module BABYLON {
  1855. /**
  1856. * Interface used to define common properties for effect fallbacks
  1857. */
  1858. export interface IEffectFallbacks {
  1859. /**
  1860. * Removes the defines that should be removed when falling back.
  1861. * @param currentDefines defines the current define statements for the shader.
  1862. * @param effect defines the current effect we try to compile
  1863. * @returns The resulting defines with defines of the current rank removed.
  1864. */
  1865. reduce(currentDefines: string, effect: Effect): string;
  1866. /**
  1867. * Removes the fallback from the bound mesh.
  1868. */
  1869. unBindMesh(): void;
  1870. /**
  1871. * Checks to see if more fallbacks are still available.
  1872. */
  1873. hasMoreFallbacks: boolean;
  1874. }
  1875. }
  1876. declare module BABYLON {
  1877. /**
  1878. * Interface for the size containing width and height
  1879. */
  1880. export interface ISize {
  1881. /**
  1882. * Width
  1883. */
  1884. width: number;
  1885. /**
  1886. * Heighht
  1887. */
  1888. height: number;
  1889. }
  1890. /**
  1891. * Size containing widht and height
  1892. */
  1893. export class Size implements ISize {
  1894. /**
  1895. * Width
  1896. */
  1897. width: number;
  1898. /**
  1899. * Height
  1900. */
  1901. height: number;
  1902. /**
  1903. * Creates a Size object from the given width and height (floats).
  1904. * @param width width of the new size
  1905. * @param height height of the new size
  1906. */
  1907. constructor(width: number, height: number);
  1908. /**
  1909. * Returns a string with the Size width and height
  1910. * @returns a string with the Size width and height
  1911. */
  1912. toString(): string;
  1913. /**
  1914. * "Size"
  1915. * @returns the string "Size"
  1916. */
  1917. getClassName(): string;
  1918. /**
  1919. * Returns the Size hash code.
  1920. * @returns a hash code for a unique width and height
  1921. */
  1922. getHashCode(): number;
  1923. /**
  1924. * Updates the current size from the given one.
  1925. * @param src the given size
  1926. */
  1927. copyFrom(src: Size): void;
  1928. /**
  1929. * Updates in place the current Size from the given floats.
  1930. * @param width width of the new size
  1931. * @param height height of the new size
  1932. * @returns the updated Size.
  1933. */
  1934. copyFromFloats(width: number, height: number): Size;
  1935. /**
  1936. * Updates in place the current Size from the given floats.
  1937. * @param width width to set
  1938. * @param height height to set
  1939. * @returns the updated Size.
  1940. */
  1941. set(width: number, height: number): Size;
  1942. /**
  1943. * Multiplies the width and height by numbers
  1944. * @param w factor to multiple the width by
  1945. * @param h factor to multiple the height by
  1946. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1947. */
  1948. multiplyByFloats(w: number, h: number): Size;
  1949. /**
  1950. * Clones the size
  1951. * @returns a new Size copied from the given one.
  1952. */
  1953. clone(): Size;
  1954. /**
  1955. * True if the current Size and the given one width and height are strictly equal.
  1956. * @param other the other size to compare against
  1957. * @returns True if the current Size and the given one width and height are strictly equal.
  1958. */
  1959. equals(other: Size): boolean;
  1960. /**
  1961. * The surface of the Size : width * height (float).
  1962. */
  1963. get surface(): number;
  1964. /**
  1965. * Create a new size of zero
  1966. * @returns a new Size set to (0.0, 0.0)
  1967. */
  1968. static Zero(): Size;
  1969. /**
  1970. * Sums the width and height of two sizes
  1971. * @param otherSize size to add to this size
  1972. * @returns a new Size set as the addition result of the current Size and the given one.
  1973. */
  1974. add(otherSize: Size): Size;
  1975. /**
  1976. * Subtracts the width and height of two
  1977. * @param otherSize size to subtract to this size
  1978. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1979. */
  1980. subtract(otherSize: Size): Size;
  1981. /**
  1982. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1983. * @param start starting size to lerp between
  1984. * @param end end size to lerp between
  1985. * @param amount amount to lerp between the start and end values
  1986. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1987. */
  1988. static Lerp(start: Size, end: Size, amount: number): Size;
  1989. }
  1990. }
  1991. declare module BABYLON {
  1992. /**
  1993. * Base class of all the textures in babylon.
  1994. * It groups all the common properties required to work with Thin Engine.
  1995. */
  1996. export class ThinTexture {
  1997. protected _wrapU: number;
  1998. /**
  1999. * | Value | Type | Description |
  2000. * | ----- | ------------------ | ----------- |
  2001. * | 0 | CLAMP_ADDRESSMODE | |
  2002. * | 1 | WRAP_ADDRESSMODE | |
  2003. * | 2 | MIRROR_ADDRESSMODE | |
  2004. */
  2005. get wrapU(): number;
  2006. set wrapU(value: number);
  2007. protected _wrapV: number;
  2008. /**
  2009. * | Value | Type | Description |
  2010. * | ----- | ------------------ | ----------- |
  2011. * | 0 | CLAMP_ADDRESSMODE | |
  2012. * | 1 | WRAP_ADDRESSMODE | |
  2013. * | 2 | MIRROR_ADDRESSMODE | |
  2014. */
  2015. get wrapV(): number;
  2016. set wrapV(value: number);
  2017. /**
  2018. * | Value | Type | Description |
  2019. * | ----- | ------------------ | ----------- |
  2020. * | 0 | CLAMP_ADDRESSMODE | |
  2021. * | 1 | WRAP_ADDRESSMODE | |
  2022. * | 2 | MIRROR_ADDRESSMODE | |
  2023. */
  2024. wrapR: number;
  2025. /**
  2026. * With compliant hardware and browser (supporting anisotropic filtering)
  2027. * this defines the level of anisotropic filtering in the texture.
  2028. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2029. */
  2030. anisotropicFilteringLevel: number;
  2031. /**
  2032. * Define the current state of the loading sequence when in delayed load mode.
  2033. */
  2034. delayLoadState: number;
  2035. /**
  2036. * How a texture is mapped.
  2037. * Unused in thin texture mode.
  2038. */
  2039. get coordinatesMode(): number;
  2040. /**
  2041. * Define if the texture is a cube texture or if false a 2d texture.
  2042. */
  2043. get isCube(): boolean;
  2044. set isCube(value: boolean);
  2045. /**
  2046. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2047. */
  2048. get is3D(): boolean;
  2049. set is3D(value: boolean);
  2050. /**
  2051. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2052. */
  2053. get is2DArray(): boolean;
  2054. set is2DArray(value: boolean);
  2055. /**
  2056. * Get the class name of the texture.
  2057. * @returns "ThinTexture"
  2058. */
  2059. getClassName(): string;
  2060. /** @hidden */
  2061. _texture: Nullable<InternalTexture>;
  2062. protected _engine: Nullable<ThinEngine>;
  2063. private _cachedSize;
  2064. private _cachedBaseSize;
  2065. /**
  2066. * Instantiates a new ThinTexture.
  2067. * Base class of all the textures in babylon.
  2068. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2069. * @param internalTexture Define the internalTexture to wrap
  2070. */
  2071. constructor(internalTexture: Nullable<InternalTexture>);
  2072. /**
  2073. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2074. * @returns true if fully ready
  2075. */
  2076. isReady(): boolean;
  2077. /**
  2078. * Triggers the load sequence in delayed load mode.
  2079. */
  2080. delayLoad(): void;
  2081. /**
  2082. * Get the underlying lower level texture from Babylon.
  2083. * @returns the internal texture
  2084. */
  2085. getInternalTexture(): Nullable<InternalTexture>;
  2086. /**
  2087. * Get the size of the texture.
  2088. * @returns the texture size.
  2089. */
  2090. getSize(): ISize;
  2091. /**
  2092. * Get the base size of the texture.
  2093. * It can be different from the size if the texture has been resized for POT for instance
  2094. * @returns the base size
  2095. */
  2096. getBaseSize(): ISize;
  2097. /**
  2098. * Update the sampling mode of the texture.
  2099. * Default is Trilinear mode.
  2100. *
  2101. * | Value | Type | Description |
  2102. * | ----- | ------------------ | ----------- |
  2103. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2104. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2105. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2106. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2107. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2108. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2109. * | 7 | NEAREST_LINEAR | |
  2110. * | 8 | NEAREST_NEAREST | |
  2111. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2112. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2113. * | 11 | LINEAR_LINEAR | |
  2114. * | 12 | LINEAR_NEAREST | |
  2115. *
  2116. * > _mag_: magnification filter (close to the viewer)
  2117. * > _min_: minification filter (far from the viewer)
  2118. * > _mip_: filter used between mip map levels
  2119. *@param samplingMode Define the new sampling mode of the texture
  2120. */
  2121. updateSamplingMode(samplingMode: number): void;
  2122. /**
  2123. * Release and destroy the underlying lower level texture aka internalTexture.
  2124. */
  2125. releaseInternalTexture(): void;
  2126. /**
  2127. * Dispose the texture and release its associated resources.
  2128. */
  2129. dispose(): void;
  2130. }
  2131. }
  2132. declare module BABYLON {
  2133. /**
  2134. * Defines an array and its length.
  2135. * It can be helpful to group result from both Arrays and smart arrays in one structure.
  2136. */
  2137. export interface ISmartArrayLike<T> {
  2138. /**
  2139. * The data of the array.
  2140. */
  2141. data: Array<T>;
  2142. /**
  2143. * The active length of the array.
  2144. */
  2145. length: number;
  2146. }
  2147. /**
  2148. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2149. */
  2150. export class SmartArray<T> implements ISmartArrayLike<T> {
  2151. /**
  2152. * The full set of data from the array.
  2153. */
  2154. data: Array<T>;
  2155. /**
  2156. * The active length of the array.
  2157. */
  2158. length: number;
  2159. protected _id: number;
  2160. /**
  2161. * Instantiates a Smart Array.
  2162. * @param capacity defines the default capacity of the array.
  2163. */
  2164. constructor(capacity: number);
  2165. /**
  2166. * Pushes a value at the end of the active data.
  2167. * @param value defines the object to push in the array.
  2168. */
  2169. push(value: T): void;
  2170. /**
  2171. * Iterates over the active data and apply the lambda to them.
  2172. * @param func defines the action to apply on each value.
  2173. */
  2174. forEach(func: (content: T) => void): void;
  2175. /**
  2176. * Sorts the full sets of data.
  2177. * @param compareFn defines the comparison function to apply.
  2178. */
  2179. sort(compareFn: (a: T, b: T) => number): void;
  2180. /**
  2181. * Resets the active data to an empty array.
  2182. */
  2183. reset(): void;
  2184. /**
  2185. * Releases all the data from the array as well as the array.
  2186. */
  2187. dispose(): void;
  2188. /**
  2189. * Concats the active data with a given array.
  2190. * @param array defines the data to concatenate with.
  2191. */
  2192. concat(array: any): void;
  2193. /**
  2194. * Returns the position of a value in the active data.
  2195. * @param value defines the value to find the index for
  2196. * @returns the index if found in the active data otherwise -1
  2197. */
  2198. indexOf(value: T): number;
  2199. /**
  2200. * Returns whether an element is part of the active data.
  2201. * @param value defines the value to look for
  2202. * @returns true if found in the active data otherwise false
  2203. */
  2204. contains(value: T): boolean;
  2205. private static _GlobalId;
  2206. }
  2207. /**
  2208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2209. * The data in this array can only be present once
  2210. */
  2211. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2212. private _duplicateId;
  2213. /**
  2214. * Pushes a value at the end of the active data.
  2215. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2216. * @param value defines the object to push in the array.
  2217. */
  2218. push(value: T): void;
  2219. /**
  2220. * Pushes a value at the end of the active data.
  2221. * If the data is already present, it won t be added again
  2222. * @param value defines the object to push in the array.
  2223. * @returns true if added false if it was already present
  2224. */
  2225. pushNoDuplicate(value: T): boolean;
  2226. /**
  2227. * Resets the active data to an empty array.
  2228. */
  2229. reset(): void;
  2230. /**
  2231. * Concats the active data with a given array.
  2232. * This ensures no duplicate will be present in the result.
  2233. * @param array defines the data to concatenate with.
  2234. */
  2235. concatWithNoDuplicate(array: any): void;
  2236. }
  2237. }
  2238. declare module BABYLON {
  2239. /**
  2240. * Class used to evaluate queries containing `and` and `or` operators
  2241. */
  2242. export class AndOrNotEvaluator {
  2243. /**
  2244. * Evaluate a query
  2245. * @param query defines the query to evaluate
  2246. * @param evaluateCallback defines the callback used to filter result
  2247. * @returns true if the query matches
  2248. */
  2249. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2250. private static _HandleParenthesisContent;
  2251. private static _SimplifyNegation;
  2252. }
  2253. }
  2254. declare module BABYLON {
  2255. /**
  2256. * Class used to store custom tags
  2257. */
  2258. export class Tags {
  2259. /**
  2260. * Adds support for tags on the given object
  2261. * @param obj defines the object to use
  2262. */
  2263. static EnableFor(obj: any): void;
  2264. /**
  2265. * Removes tags support
  2266. * @param obj defines the object to use
  2267. */
  2268. static DisableFor(obj: any): void;
  2269. /**
  2270. * Gets a boolean indicating if the given object has tags
  2271. * @param obj defines the object to use
  2272. * @returns a boolean
  2273. */
  2274. static HasTags(obj: any): boolean;
  2275. /**
  2276. * Gets the tags available on a given object
  2277. * @param obj defines the object to use
  2278. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2279. * @returns the tags
  2280. */
  2281. static GetTags(obj: any, asString?: boolean): any;
  2282. /**
  2283. * Adds tags to an object
  2284. * @param obj defines the object to use
  2285. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2286. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2287. */
  2288. static AddTagsTo(obj: any, tagsString: string): void;
  2289. /**
  2290. * @hidden
  2291. */
  2292. static _AddTagTo(obj: any, tag: string): void;
  2293. /**
  2294. * Removes specific tags from a specific object
  2295. * @param obj defines the object to use
  2296. * @param tagsString defines the tags to remove
  2297. */
  2298. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2299. /**
  2300. * @hidden
  2301. */
  2302. static _RemoveTagFrom(obj: any, tag: string): void;
  2303. /**
  2304. * Defines if tags hosted on an object match a given query
  2305. * @param obj defines the object to use
  2306. * @param tagsQuery defines the tag query
  2307. * @returns a boolean
  2308. */
  2309. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2310. }
  2311. }
  2312. declare module BABYLON {
  2313. /**
  2314. * Scalar computation library
  2315. */
  2316. export class Scalar {
  2317. /**
  2318. * Two pi constants convenient for computation.
  2319. */
  2320. static TwoPi: number;
  2321. /**
  2322. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2323. * @param a number
  2324. * @param b number
  2325. * @param epsilon (default = 1.401298E-45)
  2326. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2327. */
  2328. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2329. /**
  2330. * Returns a string : the upper case translation of the number i to hexadecimal.
  2331. * @param i number
  2332. * @returns the upper case translation of the number i to hexadecimal.
  2333. */
  2334. static ToHex(i: number): string;
  2335. /**
  2336. * Returns -1 if value is negative and +1 is value is positive.
  2337. * @param value the value
  2338. * @returns the value itself if it's equal to zero.
  2339. */
  2340. static Sign(value: number): number;
  2341. /**
  2342. * Returns the value itself if it's between min and max.
  2343. * Returns min if the value is lower than min.
  2344. * Returns max if the value is greater than max.
  2345. * @param value the value to clmap
  2346. * @param min the min value to clamp to (default: 0)
  2347. * @param max the max value to clamp to (default: 1)
  2348. * @returns the clamped value
  2349. */
  2350. static Clamp(value: number, min?: number, max?: number): number;
  2351. /**
  2352. * the log2 of value.
  2353. * @param value the value to compute log2 of
  2354. * @returns the log2 of value.
  2355. */
  2356. static Log2(value: number): number;
  2357. /**
  2358. * the floor part of a log2 value.
  2359. * @param value the value to compute log2 of
  2360. * @returns the log2 of value.
  2361. */
  2362. static ILog2(value: number): number;
  2363. /**
  2364. * Loops the value, so that it is never larger than length and never smaller than 0.
  2365. *
  2366. * This is similar to the modulo operator but it works with floating point numbers.
  2367. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2368. * With t = 5 and length = 2.5, the result would be 0.0.
  2369. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2370. * @param value the value
  2371. * @param length the length
  2372. * @returns the looped value
  2373. */
  2374. static Repeat(value: number, length: number): number;
  2375. /**
  2376. * Normalize the value between 0.0 and 1.0 using min and max values
  2377. * @param value value to normalize
  2378. * @param min max to normalize between
  2379. * @param max min to normalize between
  2380. * @returns the normalized value
  2381. */
  2382. static Normalize(value: number, min: number, max: number): number;
  2383. /**
  2384. * Denormalize the value from 0.0 and 1.0 using min and max values
  2385. * @param normalized value to denormalize
  2386. * @param min max to denormalize between
  2387. * @param max min to denormalize between
  2388. * @returns the denormalized value
  2389. */
  2390. static Denormalize(normalized: number, min: number, max: number): number;
  2391. /**
  2392. * Calculates the shortest difference between two given angles given in degrees.
  2393. * @param current current angle in degrees
  2394. * @param target target angle in degrees
  2395. * @returns the delta
  2396. */
  2397. static DeltaAngle(current: number, target: number): number;
  2398. /**
  2399. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2400. * @param tx value
  2401. * @param length length
  2402. * @returns The returned value will move back and forth between 0 and length
  2403. */
  2404. static PingPong(tx: number, length: number): number;
  2405. /**
  2406. * Interpolates between min and max with smoothing at the limits.
  2407. *
  2408. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2409. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2410. * @param from from
  2411. * @param to to
  2412. * @param tx value
  2413. * @returns the smooth stepped value
  2414. */
  2415. static SmoothStep(from: number, to: number, tx: number): number;
  2416. /**
  2417. * Moves a value current towards target.
  2418. *
  2419. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2420. * Negative values of maxDelta pushes the value away from target.
  2421. * @param current current value
  2422. * @param target target value
  2423. * @param maxDelta max distance to move
  2424. * @returns resulting value
  2425. */
  2426. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2427. /**
  2428. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2429. *
  2430. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2431. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2432. * @param current current value
  2433. * @param target target value
  2434. * @param maxDelta max distance to move
  2435. * @returns resulting angle
  2436. */
  2437. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2438. /**
  2439. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2440. * @param start start value
  2441. * @param end target value
  2442. * @param amount amount to lerp between
  2443. * @returns the lerped value
  2444. */
  2445. static Lerp(start: number, end: number, amount: number): number;
  2446. /**
  2447. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2448. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2449. * @param start start value
  2450. * @param end target value
  2451. * @param amount amount to lerp between
  2452. * @returns the lerped value
  2453. */
  2454. static LerpAngle(start: number, end: number, amount: number): number;
  2455. /**
  2456. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2457. * @param a start value
  2458. * @param b target value
  2459. * @param value value between a and b
  2460. * @returns the inverseLerp value
  2461. */
  2462. static InverseLerp(a: number, b: number, value: number): number;
  2463. /**
  2464. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2465. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2466. * @param value1 spline value
  2467. * @param tangent1 spline value
  2468. * @param value2 spline value
  2469. * @param tangent2 spline value
  2470. * @param amount input value
  2471. * @returns hermite result
  2472. */
  2473. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2474. /**
  2475. * Returns a random float number between and min and max values
  2476. * @param min min value of random
  2477. * @param max max value of random
  2478. * @returns random value
  2479. */
  2480. static RandomRange(min: number, max: number): number;
  2481. /**
  2482. * This function returns percentage of a number in a given range.
  2483. *
  2484. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2485. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2486. * @param number to convert to percentage
  2487. * @param min min range
  2488. * @param max max range
  2489. * @returns the percentage
  2490. */
  2491. static RangeToPercent(number: number, min: number, max: number): number;
  2492. /**
  2493. * This function returns number that corresponds to the percentage in a given range.
  2494. *
  2495. * PercentToRange(0.34,0,100) will return 34.
  2496. * @param percent to convert to number
  2497. * @param min min range
  2498. * @param max max range
  2499. * @returns the number
  2500. */
  2501. static PercentToRange(percent: number, min: number, max: number): number;
  2502. /**
  2503. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2504. * @param angle The angle to normalize in radian.
  2505. * @return The converted angle.
  2506. */
  2507. static NormalizeRadians(angle: number): number;
  2508. }
  2509. }
  2510. declare module BABYLON {
  2511. /**
  2512. * Constant used to convert a value to gamma space
  2513. * @ignorenaming
  2514. */
  2515. export const ToGammaSpace: number;
  2516. /**
  2517. * Constant used to convert a value to linear space
  2518. * @ignorenaming
  2519. */
  2520. export const ToLinearSpace = 2.2;
  2521. /**
  2522. * Constant used to define the minimal number value in Babylon.js
  2523. * @ignorenaming
  2524. */
  2525. let Epsilon: number;
  2526. }
  2527. declare module BABYLON {
  2528. /**
  2529. * Class used to represent a viewport on screen
  2530. */
  2531. export class Viewport {
  2532. /** viewport left coordinate */
  2533. x: number;
  2534. /** viewport top coordinate */
  2535. y: number;
  2536. /**viewport width */
  2537. width: number;
  2538. /** viewport height */
  2539. height: number;
  2540. /**
  2541. * Creates a Viewport object located at (x, y) and sized (width, height)
  2542. * @param x defines viewport left coordinate
  2543. * @param y defines viewport top coordinate
  2544. * @param width defines the viewport width
  2545. * @param height defines the viewport height
  2546. */
  2547. constructor(
  2548. /** viewport left coordinate */
  2549. x: number,
  2550. /** viewport top coordinate */
  2551. y: number,
  2552. /**viewport width */
  2553. width: number,
  2554. /** viewport height */
  2555. height: number);
  2556. /**
  2557. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2558. * @param renderWidth defines the rendering width
  2559. * @param renderHeight defines the rendering height
  2560. * @returns a new Viewport
  2561. */
  2562. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2563. /**
  2564. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2565. * @param renderWidth defines the rendering width
  2566. * @param renderHeight defines the rendering height
  2567. * @param ref defines the target viewport
  2568. * @returns the current viewport
  2569. */
  2570. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2571. /**
  2572. * Returns a new Viewport copied from the current one
  2573. * @returns a new Viewport
  2574. */
  2575. clone(): Viewport;
  2576. }
  2577. }
  2578. declare module BABYLON {
  2579. /**
  2580. * Class containing a set of static utilities functions for arrays.
  2581. */
  2582. export class ArrayTools {
  2583. /**
  2584. * Returns an array of the given size filled with element built from the given constructor and the parameters
  2585. * @param size the number of element to construct and put in the array
  2586. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2587. * @returns a new array filled with new objects
  2588. */
  2589. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2590. }
  2591. }
  2592. declare module BABYLON {
  2593. /**
  2594. * Represents a plane by the equation ax + by + cz + d = 0
  2595. */
  2596. export class Plane {
  2597. private static _TmpMatrix;
  2598. /**
  2599. * Normal of the plane (a,b,c)
  2600. */
  2601. normal: Vector3;
  2602. /**
  2603. * d component of the plane
  2604. */
  2605. d: number;
  2606. /**
  2607. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2608. * @param a a component of the plane
  2609. * @param b b component of the plane
  2610. * @param c c component of the plane
  2611. * @param d d component of the plane
  2612. */
  2613. constructor(a: number, b: number, c: number, d: number);
  2614. /**
  2615. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2616. */
  2617. asArray(): number[];
  2618. /**
  2619. * @returns a new plane copied from the current Plane.
  2620. */
  2621. clone(): Plane;
  2622. /**
  2623. * @returns the string "Plane".
  2624. */
  2625. getClassName(): string;
  2626. /**
  2627. * @returns the Plane hash code.
  2628. */
  2629. getHashCode(): number;
  2630. /**
  2631. * Normalize the current Plane in place.
  2632. * @returns the updated Plane.
  2633. */
  2634. normalize(): Plane;
  2635. /**
  2636. * Applies a transformation the plane and returns the result
  2637. * @param transformation the transformation matrix to be applied to the plane
  2638. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2639. */
  2640. transform(transformation: DeepImmutable<Matrix>): Plane;
  2641. /**
  2642. * Compute the dot product between the point and the plane normal
  2643. * @param point point to calculate the dot product with
  2644. * @returns the dot product (float) of the point coordinates and the plane normal.
  2645. */
  2646. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2647. /**
  2648. * Updates the current Plane from the plane defined by the three given points.
  2649. * @param point1 one of the points used to contruct the plane
  2650. * @param point2 one of the points used to contruct the plane
  2651. * @param point3 one of the points used to contruct the plane
  2652. * @returns the updated Plane.
  2653. */
  2654. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2655. /**
  2656. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2657. * Note that for this function to work as expected you should make sure that:
  2658. * - direction and the plane normal are normalized
  2659. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2660. * @param direction the direction to check if the plane is facing
  2661. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2662. * @returns True if the plane is facing the given direction
  2663. */
  2664. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2665. /**
  2666. * Calculates the distance to a point
  2667. * @param point point to calculate distance to
  2668. * @returns the signed distance (float) from the given point to the Plane.
  2669. */
  2670. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2671. /**
  2672. * Creates a plane from an array
  2673. * @param array the array to create a plane from
  2674. * @returns a new Plane from the given array.
  2675. */
  2676. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2677. /**
  2678. * Creates a plane from three points
  2679. * @param point1 point used to create the plane
  2680. * @param point2 point used to create the plane
  2681. * @param point3 point used to create the plane
  2682. * @returns a new Plane defined by the three given points.
  2683. */
  2684. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2685. /**
  2686. * Creates a plane from an origin point and a normal
  2687. * @param origin origin of the plane to be constructed
  2688. * @param normal normal of the plane to be constructed
  2689. * @returns a new Plane the normal vector to this plane at the given origin point.
  2690. * Note : the vector "normal" is updated because normalized.
  2691. */
  2692. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2693. /**
  2694. * Calculates the distance from a plane and a point
  2695. * @param origin origin of the plane to be constructed
  2696. * @param normal normal of the plane to be constructed
  2697. * @param point point to calculate distance to
  2698. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2699. */
  2700. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2701. }
  2702. }
  2703. declare module BABYLON {
  2704. /** @hidden */
  2705. export class PerformanceConfigurator {
  2706. /** @hidden */
  2707. static MatrixUse64Bits: boolean;
  2708. /** @hidden */
  2709. static MatrixTrackPrecisionChange: boolean;
  2710. /** @hidden */
  2711. static MatrixCurrentType: any;
  2712. /** @hidden */
  2713. static MatrixTrackedMatrices: Array<any> | null;
  2714. /** @hidden */
  2715. static SetMatrixPrecision(use64bits: boolean): void;
  2716. }
  2717. }
  2718. declare module BABYLON {
  2719. /**
  2720. * Class representing a vector containing 2 coordinates
  2721. */
  2722. export class Vector2 {
  2723. /** defines the first coordinate */
  2724. x: number;
  2725. /** defines the second coordinate */
  2726. y: number;
  2727. /**
  2728. * Creates a new Vector2 from the given x and y coordinates
  2729. * @param x defines the first coordinate
  2730. * @param y defines the second coordinate
  2731. */
  2732. constructor(
  2733. /** defines the first coordinate */
  2734. x?: number,
  2735. /** defines the second coordinate */
  2736. y?: number);
  2737. /**
  2738. * Gets a string with the Vector2 coordinates
  2739. * @returns a string with the Vector2 coordinates
  2740. */
  2741. toString(): string;
  2742. /**
  2743. * Gets class name
  2744. * @returns the string "Vector2"
  2745. */
  2746. getClassName(): string;
  2747. /**
  2748. * Gets current vector hash code
  2749. * @returns the Vector2 hash code as a number
  2750. */
  2751. getHashCode(): number;
  2752. /**
  2753. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2754. * @param array defines the source array
  2755. * @param index defines the offset in source array
  2756. * @returns the current Vector2
  2757. */
  2758. toArray(array: FloatArray, index?: number): Vector2;
  2759. /**
  2760. * Update the current vector from an array
  2761. * @param array defines the destination array
  2762. * @param index defines the offset in the destination array
  2763. * @returns the current Vector3
  2764. */
  2765. fromArray(array: FloatArray, index?: number): Vector2;
  2766. /**
  2767. * Copy the current vector to an array
  2768. * @returns a new array with 2 elements: the Vector2 coordinates.
  2769. */
  2770. asArray(): number[];
  2771. /**
  2772. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2773. * @param source defines the source Vector2
  2774. * @returns the current updated Vector2
  2775. */
  2776. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2777. /**
  2778. * Sets the Vector2 coordinates with the given floats
  2779. * @param x defines the first coordinate
  2780. * @param y defines the second coordinate
  2781. * @returns the current updated Vector2
  2782. */
  2783. copyFromFloats(x: number, y: number): Vector2;
  2784. /**
  2785. * Sets the Vector2 coordinates with the given floats
  2786. * @param x defines the first coordinate
  2787. * @param y defines the second coordinate
  2788. * @returns the current updated Vector2
  2789. */
  2790. set(x: number, y: number): Vector2;
  2791. /**
  2792. * Add another vector with the current one
  2793. * @param otherVector defines the other vector
  2794. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2795. */
  2796. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2797. /**
  2798. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2799. * @param otherVector defines the other vector
  2800. * @param result defines the target vector
  2801. * @returns the unmodified current Vector2
  2802. */
  2803. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2804. /**
  2805. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2806. * @param otherVector defines the other vector
  2807. * @returns the current updated Vector2
  2808. */
  2809. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2810. /**
  2811. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2812. * @param otherVector defines the other vector
  2813. * @returns a new Vector2
  2814. */
  2815. addVector3(otherVector: Vector3): Vector2;
  2816. /**
  2817. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2818. * @param otherVector defines the other vector
  2819. * @returns a new Vector2
  2820. */
  2821. subtract(otherVector: Vector2): Vector2;
  2822. /**
  2823. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2824. * @param otherVector defines the other vector
  2825. * @param result defines the target vector
  2826. * @returns the unmodified current Vector2
  2827. */
  2828. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2829. /**
  2830. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2831. * @param otherVector defines the other vector
  2832. * @returns the current updated Vector2
  2833. */
  2834. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2835. /**
  2836. * Multiplies in place the current Vector2 coordinates by the given ones
  2837. * @param otherVector defines the other vector
  2838. * @returns the current updated Vector2
  2839. */
  2840. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2841. /**
  2842. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2843. * @param otherVector defines the other vector
  2844. * @returns a new Vector2
  2845. */
  2846. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2847. /**
  2848. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2849. * @param otherVector defines the other vector
  2850. * @param result defines the target vector
  2851. * @returns the unmodified current Vector2
  2852. */
  2853. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2854. /**
  2855. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2856. * @param x defines the first coordinate
  2857. * @param y defines the second coordinate
  2858. * @returns a new Vector2
  2859. */
  2860. multiplyByFloats(x: number, y: number): Vector2;
  2861. /**
  2862. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2863. * @param otherVector defines the other vector
  2864. * @returns a new Vector2
  2865. */
  2866. divide(otherVector: Vector2): Vector2;
  2867. /**
  2868. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2869. * @param otherVector defines the other vector
  2870. * @param result defines the target vector
  2871. * @returns the unmodified current Vector2
  2872. */
  2873. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2874. /**
  2875. * Divides the current Vector2 coordinates by the given ones
  2876. * @param otherVector defines the other vector
  2877. * @returns the current updated Vector2
  2878. */
  2879. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2880. /**
  2881. * Gets a new Vector2 with current Vector2 negated coordinates
  2882. * @returns a new Vector2
  2883. */
  2884. negate(): Vector2;
  2885. /**
  2886. * Negate this vector in place
  2887. * @returns this
  2888. */
  2889. negateInPlace(): Vector2;
  2890. /**
  2891. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2892. * @param result defines the Vector3 object where to store the result
  2893. * @returns the current Vector2
  2894. */
  2895. negateToRef(result: Vector2): Vector2;
  2896. /**
  2897. * Multiply the Vector2 coordinates by scale
  2898. * @param scale defines the scaling factor
  2899. * @returns the current updated Vector2
  2900. */
  2901. scaleInPlace(scale: number): Vector2;
  2902. /**
  2903. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2904. * @param scale defines the scaling factor
  2905. * @returns a new Vector2
  2906. */
  2907. scale(scale: number): Vector2;
  2908. /**
  2909. * Scale the current Vector2 values by a factor to a given Vector2
  2910. * @param scale defines the scale factor
  2911. * @param result defines the Vector2 object where to store the result
  2912. * @returns the unmodified current Vector2
  2913. */
  2914. scaleToRef(scale: number, result: Vector2): Vector2;
  2915. /**
  2916. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2917. * @param scale defines the scale factor
  2918. * @param result defines the Vector2 object where to store the result
  2919. * @returns the unmodified current Vector2
  2920. */
  2921. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2922. /**
  2923. * Gets a boolean if two vectors are equals
  2924. * @param otherVector defines the other vector
  2925. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2926. */
  2927. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2928. /**
  2929. * Gets a boolean if two vectors are equals (using an epsilon value)
  2930. * @param otherVector defines the other vector
  2931. * @param epsilon defines the minimal distance to consider equality
  2932. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2933. */
  2934. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2935. /**
  2936. * Gets a new Vector2 from current Vector2 floored values
  2937. * @returns a new Vector2
  2938. */
  2939. floor(): Vector2;
  2940. /**
  2941. * Gets a new Vector2 from current Vector2 floored values
  2942. * @returns a new Vector2
  2943. */
  2944. fract(): Vector2;
  2945. /**
  2946. * Gets the length of the vector
  2947. * @returns the vector length (float)
  2948. */
  2949. length(): number;
  2950. /**
  2951. * Gets the vector squared length
  2952. * @returns the vector squared length (float)
  2953. */
  2954. lengthSquared(): number;
  2955. /**
  2956. * Normalize the vector
  2957. * @returns the current updated Vector2
  2958. */
  2959. normalize(): Vector2;
  2960. /**
  2961. * Gets a new Vector2 copied from the Vector2
  2962. * @returns a new Vector2
  2963. */
  2964. clone(): Vector2;
  2965. /**
  2966. * Gets a new Vector2(0, 0)
  2967. * @returns a new Vector2
  2968. */
  2969. static Zero(): Vector2;
  2970. /**
  2971. * Gets a new Vector2(1, 1)
  2972. * @returns a new Vector2
  2973. */
  2974. static One(): Vector2;
  2975. /**
  2976. * Gets a new Vector2 set from the given index element of the given array
  2977. * @param array defines the data source
  2978. * @param offset defines the offset in the data source
  2979. * @returns a new Vector2
  2980. */
  2981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2982. /**
  2983. * Sets "result" from the given index element of the given array
  2984. * @param array defines the data source
  2985. * @param offset defines the offset in the data source
  2986. * @param result defines the target vector
  2987. */
  2988. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2989. /**
  2990. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2991. * @param value1 defines 1st point of control
  2992. * @param value2 defines 2nd point of control
  2993. * @param value3 defines 3rd point of control
  2994. * @param value4 defines 4th point of control
  2995. * @param amount defines the interpolation factor
  2996. * @returns a new Vector2
  2997. */
  2998. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2999. /**
  3000. * 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".
  3001. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  3002. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  3003. * @param value defines the value to clamp
  3004. * @param min defines the lower limit
  3005. * @param max defines the upper limit
  3006. * @returns a new Vector2
  3007. */
  3008. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3009. /**
  3010. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3011. * @param value1 defines the 1st control point
  3012. * @param tangent1 defines the outgoing tangent
  3013. * @param value2 defines the 2nd control point
  3014. * @param tangent2 defines the incoming tangent
  3015. * @param amount defines the interpolation factor
  3016. * @returns a new Vector2
  3017. */
  3018. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3019. /**
  3020. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3021. * @param start defines the start vector
  3022. * @param end defines the end vector
  3023. * @param amount defines the interpolation factor
  3024. * @returns a new Vector2
  3025. */
  3026. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3027. /**
  3028. * Gets the dot product of the vector "left" and the vector "right"
  3029. * @param left defines first vector
  3030. * @param right defines second vector
  3031. * @returns the dot product (float)
  3032. */
  3033. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3034. /**
  3035. * Returns a new Vector2 equal to the normalized given vector
  3036. * @param vector defines the vector to normalize
  3037. * @returns a new Vector2
  3038. */
  3039. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3040. /**
  3041. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3042. * @param left defines 1st vector
  3043. * @param right defines 2nd vector
  3044. * @returns a new Vector2
  3045. */
  3046. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3047. /**
  3048. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3049. * @param left defines 1st vector
  3050. * @param right defines 2nd vector
  3051. * @returns a new Vector2
  3052. */
  3053. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3054. /**
  3055. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3056. * @param vector defines the vector to transform
  3057. * @param transformation defines the matrix to apply
  3058. * @returns a new Vector2
  3059. */
  3060. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3061. /**
  3062. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3063. * @param vector defines the vector to transform
  3064. * @param transformation defines the matrix to apply
  3065. * @param result defines the target vector
  3066. */
  3067. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3068. /**
  3069. * Determines if a given vector is included in a triangle
  3070. * @param p defines the vector to test
  3071. * @param p0 defines 1st triangle point
  3072. * @param p1 defines 2nd triangle point
  3073. * @param p2 defines 3rd triangle point
  3074. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3075. */
  3076. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3077. /**
  3078. * Gets the distance between the vectors "value1" and "value2"
  3079. * @param value1 defines first vector
  3080. * @param value2 defines second vector
  3081. * @returns the distance between vectors
  3082. */
  3083. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3084. /**
  3085. * Returns the squared distance between the vectors "value1" and "value2"
  3086. * @param value1 defines first vector
  3087. * @param value2 defines second vector
  3088. * @returns the squared distance between vectors
  3089. */
  3090. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3091. /**
  3092. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3093. * @param value1 defines first vector
  3094. * @param value2 defines second vector
  3095. * @returns a new Vector2
  3096. */
  3097. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3098. /**
  3099. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3100. * @param value1 defines first vector
  3101. * @param value2 defines second vector
  3102. * @param ref defines third vector
  3103. * @returns ref
  3104. */
  3105. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3106. /**
  3107. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3108. * @param p defines the middle point
  3109. * @param segA defines one point of the segment
  3110. * @param segB defines the other point of the segment
  3111. * @returns the shortest distance
  3112. */
  3113. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3114. }
  3115. /**
  3116. * Class used to store (x,y,z) vector representation
  3117. * A Vector3 is the main object used in 3D geometry
  3118. * It can represent etiher the coordinates of a point the space, either a direction
  3119. * Reminder: js uses a left handed forward facing system
  3120. */
  3121. export class Vector3 {
  3122. private static _UpReadOnly;
  3123. private static _ZeroReadOnly;
  3124. /** @hidden */
  3125. _x: number;
  3126. /** @hidden */
  3127. _y: number;
  3128. /** @hidden */
  3129. _z: number;
  3130. /** @hidden */
  3131. _isDirty: boolean;
  3132. /** Gets or sets the x coordinate */
  3133. get x(): number;
  3134. set x(value: number);
  3135. /** Gets or sets the y coordinate */
  3136. get y(): number;
  3137. set y(value: number);
  3138. /** Gets or sets the z coordinate */
  3139. get z(): number;
  3140. set z(value: number);
  3141. /**
  3142. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3143. * @param x defines the first coordinates (on X axis)
  3144. * @param y defines the second coordinates (on Y axis)
  3145. * @param z defines the third coordinates (on Z axis)
  3146. */
  3147. constructor(x?: number, y?: number, z?: number);
  3148. /**
  3149. * Creates a string representation of the Vector3
  3150. * @returns a string with the Vector3 coordinates.
  3151. */
  3152. toString(): string;
  3153. /**
  3154. * Gets the class name
  3155. * @returns the string "Vector3"
  3156. */
  3157. getClassName(): string;
  3158. /**
  3159. * Creates the Vector3 hash code
  3160. * @returns a number which tends to be unique between Vector3 instances
  3161. */
  3162. getHashCode(): number;
  3163. /**
  3164. * Creates an array containing three elements : the coordinates of the Vector3
  3165. * @returns a new array of numbers
  3166. */
  3167. asArray(): number[];
  3168. /**
  3169. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3170. * @param array defines the destination array
  3171. * @param index defines the offset in the destination array
  3172. * @returns the current Vector3
  3173. */
  3174. toArray(array: FloatArray, index?: number): Vector3;
  3175. /**
  3176. * Update the current vector from an array
  3177. * @param array defines the destination array
  3178. * @param index defines the offset in the destination array
  3179. * @returns the current Vector3
  3180. */
  3181. fromArray(array: FloatArray, index?: number): Vector3;
  3182. /**
  3183. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3184. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3185. */
  3186. toQuaternion(): Quaternion;
  3187. /**
  3188. * Adds the given vector to the current Vector3
  3189. * @param otherVector defines the second operand
  3190. * @returns the current updated Vector3
  3191. */
  3192. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * Adds the given coordinates to the current Vector3
  3195. * @param x defines the x coordinate of the operand
  3196. * @param y defines the y coordinate of the operand
  3197. * @param z defines the z coordinate of the operand
  3198. * @returns the current updated Vector3
  3199. */
  3200. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3201. /**
  3202. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3203. * @param otherVector defines the second operand
  3204. * @returns the resulting Vector3
  3205. */
  3206. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3207. /**
  3208. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3209. * @param otherVector defines the second operand
  3210. * @param result defines the Vector3 object where to store the result
  3211. * @returns the current Vector3
  3212. */
  3213. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3214. /**
  3215. * Subtract the given vector from the current Vector3
  3216. * @param otherVector defines the second operand
  3217. * @returns the current updated Vector3
  3218. */
  3219. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3220. /**
  3221. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3222. * @param otherVector defines the second operand
  3223. * @returns the resulting Vector3
  3224. */
  3225. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3226. /**
  3227. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3228. * @param otherVector defines the second operand
  3229. * @param result defines the Vector3 object where to store the result
  3230. * @returns the current Vector3
  3231. */
  3232. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3233. /**
  3234. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3235. * @param x defines the x coordinate of the operand
  3236. * @param y defines the y coordinate of the operand
  3237. * @param z defines the z coordinate of the operand
  3238. * @returns the resulting Vector3
  3239. */
  3240. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3241. /**
  3242. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3243. * @param x defines the x coordinate of the operand
  3244. * @param y defines the y coordinate of the operand
  3245. * @param z defines the z coordinate of the operand
  3246. * @param result defines the Vector3 object where to store the result
  3247. * @returns the current Vector3
  3248. */
  3249. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3250. /**
  3251. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3252. * @returns a new Vector3
  3253. */
  3254. negate(): Vector3;
  3255. /**
  3256. * Negate this vector in place
  3257. * @returns this
  3258. */
  3259. negateInPlace(): Vector3;
  3260. /**
  3261. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3262. * @param result defines the Vector3 object where to store the result
  3263. * @returns the current Vector3
  3264. */
  3265. negateToRef(result: Vector3): Vector3;
  3266. /**
  3267. * Multiplies the Vector3 coordinates by the float "scale"
  3268. * @param scale defines the multiplier factor
  3269. * @returns the current updated Vector3
  3270. */
  3271. scaleInPlace(scale: number): Vector3;
  3272. /**
  3273. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3274. * @param scale defines the multiplier factor
  3275. * @returns a new Vector3
  3276. */
  3277. scale(scale: number): Vector3;
  3278. /**
  3279. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3280. * @param scale defines the multiplier factor
  3281. * @param result defines the Vector3 object where to store the result
  3282. * @returns the current Vector3
  3283. */
  3284. scaleToRef(scale: number, result: Vector3): Vector3;
  3285. /**
  3286. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3287. * @param scale defines the scale factor
  3288. * @param result defines the Vector3 object where to store the result
  3289. * @returns the unmodified current Vector3
  3290. */
  3291. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3292. /**
  3293. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3294. * @param origin defines the origin of the projection ray
  3295. * @param plane defines the plane to project to
  3296. * @returns the projected vector3
  3297. */
  3298. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3299. /**
  3300. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3301. * @param origin defines the origin of the projection ray
  3302. * @param plane defines the plane to project to
  3303. * @param result defines the Vector3 where to store the result
  3304. */
  3305. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3306. /**
  3307. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3308. * @param otherVector defines the second operand
  3309. * @returns true if both vectors are equals
  3310. */
  3311. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3312. /**
  3313. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3314. * @param otherVector defines the second operand
  3315. * @param epsilon defines the minimal distance to define values as equals
  3316. * @returns true if both vectors are distant less than epsilon
  3317. */
  3318. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3319. /**
  3320. * Returns true if the current Vector3 coordinates equals the given floats
  3321. * @param x defines the x coordinate of the operand
  3322. * @param y defines the y coordinate of the operand
  3323. * @param z defines the z coordinate of the operand
  3324. * @returns true if both vectors are equals
  3325. */
  3326. equalsToFloats(x: number, y: number, z: number): boolean;
  3327. /**
  3328. * Multiplies the current Vector3 coordinates by the given ones
  3329. * @param otherVector defines the second operand
  3330. * @returns the current updated Vector3
  3331. */
  3332. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3333. /**
  3334. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3335. * @param otherVector defines the second operand
  3336. * @returns the new Vector3
  3337. */
  3338. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3339. /**
  3340. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3341. * @param otherVector defines the second operand
  3342. * @param result defines the Vector3 object where to store the result
  3343. * @returns the current Vector3
  3344. */
  3345. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3346. /**
  3347. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3348. * @param x defines the x coordinate of the operand
  3349. * @param y defines the y coordinate of the operand
  3350. * @param z defines the z coordinate of the operand
  3351. * @returns the new Vector3
  3352. */
  3353. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3354. /**
  3355. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3356. * @param otherVector defines the second operand
  3357. * @returns the new Vector3
  3358. */
  3359. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3360. /**
  3361. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3362. * @param otherVector defines the second operand
  3363. * @param result defines the Vector3 object where to store the result
  3364. * @returns the current Vector3
  3365. */
  3366. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3367. /**
  3368. * Divides the current Vector3 coordinates by the given ones.
  3369. * @param otherVector defines the second operand
  3370. * @returns the current updated Vector3
  3371. */
  3372. divideInPlace(otherVector: Vector3): Vector3;
  3373. /**
  3374. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3375. * @param other defines the second operand
  3376. * @returns the current updated Vector3
  3377. */
  3378. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3379. /**
  3380. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3381. * @param other defines the second operand
  3382. * @returns the current updated Vector3
  3383. */
  3384. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3385. /**
  3386. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3387. * @param x defines the x coordinate of the operand
  3388. * @param y defines the y coordinate of the operand
  3389. * @param z defines the z coordinate of the operand
  3390. * @returns the current updated Vector3
  3391. */
  3392. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3393. /**
  3394. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3395. * @param x defines the x coordinate of the operand
  3396. * @param y defines the y coordinate of the operand
  3397. * @param z defines the z coordinate of the operand
  3398. * @returns the current updated Vector3
  3399. */
  3400. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3401. /**
  3402. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3403. * Check if is non uniform within a certain amount of decimal places to account for this
  3404. * @param epsilon the amount the values can differ
  3405. * @returns if the the vector is non uniform to a certain number of decimal places
  3406. */
  3407. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3408. /**
  3409. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3410. */
  3411. get isNonUniform(): boolean;
  3412. /**
  3413. * Gets a new Vector3 from current Vector3 floored values
  3414. * @returns a new Vector3
  3415. */
  3416. floor(): Vector3;
  3417. /**
  3418. * Gets a new Vector3 from current Vector3 floored values
  3419. * @returns a new Vector3
  3420. */
  3421. fract(): Vector3;
  3422. /**
  3423. * Gets the length of the Vector3
  3424. * @returns the length of the Vector3
  3425. */
  3426. length(): number;
  3427. /**
  3428. * Gets the squared length of the Vector3
  3429. * @returns squared length of the Vector3
  3430. */
  3431. lengthSquared(): number;
  3432. /**
  3433. * Normalize the current Vector3.
  3434. * Please note that this is an in place operation.
  3435. * @returns the current updated Vector3
  3436. */
  3437. normalize(): Vector3;
  3438. /**
  3439. * Reorders the x y z properties of the vector in place
  3440. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3441. * @returns the current updated vector
  3442. */
  3443. reorderInPlace(order: string): this;
  3444. /**
  3445. * Rotates the vector around 0,0,0 by a quaternion
  3446. * @param quaternion the rotation quaternion
  3447. * @param result vector to store the result
  3448. * @returns the resulting vector
  3449. */
  3450. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3451. /**
  3452. * Rotates a vector around a given point
  3453. * @param quaternion the rotation quaternion
  3454. * @param point the point to rotate around
  3455. * @param result vector to store the result
  3456. * @returns the resulting vector
  3457. */
  3458. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3459. /**
  3460. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3461. * The cross product is then orthogonal to both current and "other"
  3462. * @param other defines the right operand
  3463. * @returns the cross product
  3464. */
  3465. cross(other: Vector3): Vector3;
  3466. /**
  3467. * Normalize the current Vector3 with the given input length.
  3468. * Please note that this is an in place operation.
  3469. * @param len the length of the vector
  3470. * @returns the current updated Vector3
  3471. */
  3472. normalizeFromLength(len: number): Vector3;
  3473. /**
  3474. * Normalize the current Vector3 to a new vector
  3475. * @returns the new Vector3
  3476. */
  3477. normalizeToNew(): Vector3;
  3478. /**
  3479. * Normalize the current Vector3 to the reference
  3480. * @param reference define the Vector3 to update
  3481. * @returns the updated Vector3
  3482. */
  3483. normalizeToRef(reference: Vector3): Vector3;
  3484. /**
  3485. * Creates a new Vector3 copied from the current Vector3
  3486. * @returns the new Vector3
  3487. */
  3488. clone(): Vector3;
  3489. /**
  3490. * Copies the given vector coordinates to the current Vector3 ones
  3491. * @param source defines the source Vector3
  3492. * @returns the current updated Vector3
  3493. */
  3494. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3495. /**
  3496. * Copies the given floats to the current Vector3 coordinates
  3497. * @param x defines the x coordinate of the operand
  3498. * @param y defines the y coordinate of the operand
  3499. * @param z defines the z coordinate of the operand
  3500. * @returns the current updated Vector3
  3501. */
  3502. copyFromFloats(x: number, y: number, z: number): Vector3;
  3503. /**
  3504. * Copies the given floats to the current Vector3 coordinates
  3505. * @param x defines the x coordinate of the operand
  3506. * @param y defines the y coordinate of the operand
  3507. * @param z defines the z coordinate of the operand
  3508. * @returns the current updated Vector3
  3509. */
  3510. set(x: number, y: number, z: number): Vector3;
  3511. /**
  3512. * Copies the given float to the current Vector3 coordinates
  3513. * @param v defines the x, y and z coordinates of the operand
  3514. * @returns the current updated Vector3
  3515. */
  3516. setAll(v: number): Vector3;
  3517. /**
  3518. * Get the clip factor between two vectors
  3519. * @param vector0 defines the first operand
  3520. * @param vector1 defines the second operand
  3521. * @param axis defines the axis to use
  3522. * @param size defines the size along the axis
  3523. * @returns the clip factor
  3524. */
  3525. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3526. /**
  3527. * Get angle between two vectors
  3528. * @param vector0 angle between vector0 and vector1
  3529. * @param vector1 angle between vector0 and vector1
  3530. * @param normal direction of the normal
  3531. * @return the angle between vector0 and vector1
  3532. */
  3533. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3534. /**
  3535. * Returns a new Vector3 set from the index "offset" of the given array
  3536. * @param array defines the source array
  3537. * @param offset defines the offset in the source array
  3538. * @returns the new Vector3
  3539. */
  3540. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3541. /**
  3542. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3543. * @param array defines the source array
  3544. * @param offset defines the offset in the source array
  3545. * @returns the new Vector3
  3546. * @deprecated Please use FromArray instead.
  3547. */
  3548. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3549. /**
  3550. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3551. * @param array defines the source array
  3552. * @param offset defines the offset in the source array
  3553. * @param result defines the Vector3 where to store the result
  3554. */
  3555. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3556. /**
  3557. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3558. * @param array defines the source array
  3559. * @param offset defines the offset in the source array
  3560. * @param result defines the Vector3 where to store the result
  3561. * @deprecated Please use FromArrayToRef instead.
  3562. */
  3563. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3564. /**
  3565. * Sets the given vector "result" with the given floats.
  3566. * @param x defines the x coordinate of the source
  3567. * @param y defines the y coordinate of the source
  3568. * @param z defines the z coordinate of the source
  3569. * @param result defines the Vector3 where to store the result
  3570. */
  3571. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3572. /**
  3573. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3574. * @returns a new empty Vector3
  3575. */
  3576. static Zero(): Vector3;
  3577. /**
  3578. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3579. * @returns a new unit Vector3
  3580. */
  3581. static One(): Vector3;
  3582. /**
  3583. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3584. * @returns a new up Vector3
  3585. */
  3586. static Up(): Vector3;
  3587. /**
  3588. * Gets a up Vector3 that must not be updated
  3589. */
  3590. static get UpReadOnly(): DeepImmutable<Vector3>;
  3591. /**
  3592. * Gets a zero Vector3 that must not be updated
  3593. */
  3594. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3595. /**
  3596. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3597. * @returns a new down Vector3
  3598. */
  3599. static Down(): Vector3;
  3600. /**
  3601. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3602. * @param rightHandedSystem is the scene right-handed (negative z)
  3603. * @returns a new forward Vector3
  3604. */
  3605. static Forward(rightHandedSystem?: boolean): Vector3;
  3606. /**
  3607. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3608. * @param rightHandedSystem is the scene right-handed (negative-z)
  3609. * @returns a new forward Vector3
  3610. */
  3611. static Backward(rightHandedSystem?: boolean): Vector3;
  3612. /**
  3613. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3614. * @returns a new right Vector3
  3615. */
  3616. static Right(): Vector3;
  3617. /**
  3618. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3619. * @returns a new left Vector3
  3620. */
  3621. static Left(): Vector3;
  3622. /**
  3623. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3624. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3625. * @param vector defines the Vector3 to transform
  3626. * @param transformation defines the transformation matrix
  3627. * @returns the transformed Vector3
  3628. */
  3629. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3630. /**
  3631. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3632. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3633. * @param vector defines the Vector3 to transform
  3634. * @param transformation defines the transformation matrix
  3635. * @param result defines the Vector3 where to store the result
  3636. */
  3637. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3638. /**
  3639. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3640. * This method computes tranformed coordinates only, not transformed direction vectors
  3641. * @param x define the x coordinate of the source vector
  3642. * @param y define the y coordinate of the source vector
  3643. * @param z define the z coordinate of the source vector
  3644. * @param transformation defines the transformation matrix
  3645. * @param result defines the Vector3 where to store the result
  3646. */
  3647. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3648. /**
  3649. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3650. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3651. * @param vector defines the Vector3 to transform
  3652. * @param transformation defines the transformation matrix
  3653. * @returns the new Vector3
  3654. */
  3655. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3656. /**
  3657. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3658. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3659. * @param vector defines the Vector3 to transform
  3660. * @param transformation defines the transformation matrix
  3661. * @param result defines the Vector3 where to store the result
  3662. */
  3663. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3664. /**
  3665. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3666. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3667. * @param x define the x coordinate of the source vector
  3668. * @param y define the y coordinate of the source vector
  3669. * @param z define the z coordinate of the source vector
  3670. * @param transformation defines the transformation matrix
  3671. * @param result defines the Vector3 where to store the result
  3672. */
  3673. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3674. /**
  3675. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3676. * @param value1 defines the first control point
  3677. * @param value2 defines the second control point
  3678. * @param value3 defines the third control point
  3679. * @param value4 defines the fourth control point
  3680. * @param amount defines the amount on the spline to use
  3681. * @returns the new Vector3
  3682. */
  3683. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3684. /**
  3685. * 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"
  3686. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3687. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3688. * @param value defines the current value
  3689. * @param min defines the lower range value
  3690. * @param max defines the upper range value
  3691. * @returns the new Vector3
  3692. */
  3693. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3694. /**
  3695. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3696. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3697. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3698. * @param value defines the current value
  3699. * @param min defines the lower range value
  3700. * @param max defines the upper range value
  3701. * @param result defines the Vector3 where to store the result
  3702. */
  3703. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3704. /**
  3705. * Checks if a given vector is inside a specific range
  3706. * @param v defines the vector to test
  3707. * @param min defines the minimum range
  3708. * @param max defines the maximum range
  3709. */
  3710. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3711. /**
  3712. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3713. * @param value1 defines the first control point
  3714. * @param tangent1 defines the first tangent vector
  3715. * @param value2 defines the second control point
  3716. * @param tangent2 defines the second tangent vector
  3717. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3718. * @returns the new Vector3
  3719. */
  3720. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3721. /**
  3722. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3723. * @param start defines the start value
  3724. * @param end defines the end value
  3725. * @param amount max defines amount between both (between 0 and 1)
  3726. * @returns the new Vector3
  3727. */
  3728. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3729. /**
  3730. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3731. * @param start defines the start value
  3732. * @param end defines the end value
  3733. * @param amount max defines amount between both (between 0 and 1)
  3734. * @param result defines the Vector3 where to store the result
  3735. */
  3736. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3737. /**
  3738. * Returns the dot product (float) between the vectors "left" and "right"
  3739. * @param left defines the left operand
  3740. * @param right defines the right operand
  3741. * @returns the dot product
  3742. */
  3743. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3744. /**
  3745. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3746. * The cross product is then orthogonal to both "left" and "right"
  3747. * @param left defines the left operand
  3748. * @param right defines the right operand
  3749. * @returns the cross product
  3750. */
  3751. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3752. /**
  3753. * Sets the given vector "result" with the cross product of "left" and "right"
  3754. * The cross product is then orthogonal to both "left" and "right"
  3755. * @param left defines the left operand
  3756. * @param right defines the right operand
  3757. * @param result defines the Vector3 where to store the result
  3758. */
  3759. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3760. /**
  3761. * Returns a new Vector3 as the normalization of the given vector
  3762. * @param vector defines the Vector3 to normalize
  3763. * @returns the new Vector3
  3764. */
  3765. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3766. /**
  3767. * Sets the given vector "result" with the normalization of the given first vector
  3768. * @param vector defines the Vector3 to normalize
  3769. * @param result defines the Vector3 where to store the result
  3770. */
  3771. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3772. /**
  3773. * Project a Vector3 onto screen space
  3774. * @param vector defines the Vector3 to project
  3775. * @param world defines the world matrix to use
  3776. * @param transform defines the transform (view x projection) matrix to use
  3777. * @param viewport defines the screen viewport to use
  3778. * @returns the new Vector3
  3779. */
  3780. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3781. /**
  3782. * Project a Vector3 onto screen space to reference
  3783. * @param vector defines the Vector3 to project
  3784. * @param world defines the world matrix to use
  3785. * @param transform defines the transform (view x projection) matrix to use
  3786. * @param viewport defines the screen viewport to use
  3787. * @param result the vector in which the screen space will be stored
  3788. * @returns the new Vector3
  3789. */
  3790. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3791. /** @hidden */
  3792. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3793. /**
  3794. * Unproject from screen space to object space
  3795. * @param source defines the screen space Vector3 to use
  3796. * @param viewportWidth defines the current width of the viewport
  3797. * @param viewportHeight defines the current height of the viewport
  3798. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3799. * @param transform defines the transform (view x projection) matrix to use
  3800. * @returns the new Vector3
  3801. */
  3802. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3803. /**
  3804. * Unproject from screen space to object space
  3805. * @param source defines the screen space Vector3 to use
  3806. * @param viewportWidth defines the current width of the viewport
  3807. * @param viewportHeight defines the current height of the viewport
  3808. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3809. * @param view defines the view matrix to use
  3810. * @param projection defines the projection matrix to use
  3811. * @returns the new Vector3
  3812. */
  3813. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3814. /**
  3815. * Unproject from screen space to object space
  3816. * @param source defines the screen space Vector3 to use
  3817. * @param viewportWidth defines the current width of the viewport
  3818. * @param viewportHeight defines the current height of the viewport
  3819. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3820. * @param view defines the view matrix to use
  3821. * @param projection defines the projection matrix to use
  3822. * @param result defines the Vector3 where to store the result
  3823. */
  3824. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3825. /**
  3826. * Unproject from screen space to object space
  3827. * @param sourceX defines the screen space x coordinate to use
  3828. * @param sourceY defines the screen space y coordinate to use
  3829. * @param sourceZ defines the screen space z coordinate to use
  3830. * @param viewportWidth defines the current width of the viewport
  3831. * @param viewportHeight defines the current height of the viewport
  3832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3833. * @param view defines the view matrix to use
  3834. * @param projection defines the projection matrix to use
  3835. * @param result defines the Vector3 where to store the result
  3836. */
  3837. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3838. /**
  3839. * Gets the minimal coordinate values between two Vector3
  3840. * @param left defines the first operand
  3841. * @param right defines the second operand
  3842. * @returns the new Vector3
  3843. */
  3844. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3845. /**
  3846. * Gets the maximal coordinate values between two Vector3
  3847. * @param left defines the first operand
  3848. * @param right defines the second operand
  3849. * @returns the new Vector3
  3850. */
  3851. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3852. /**
  3853. * Returns the distance between the vectors "value1" and "value2"
  3854. * @param value1 defines the first operand
  3855. * @param value2 defines the second operand
  3856. * @returns the distance
  3857. */
  3858. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3859. /**
  3860. * Returns the squared distance between the vectors "value1" and "value2"
  3861. * @param value1 defines the first operand
  3862. * @param value2 defines the second operand
  3863. * @returns the squared distance
  3864. */
  3865. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3866. /**
  3867. * Returns a new Vector3 located at the center between "value1" and "value2"
  3868. * @param value1 defines the first operand
  3869. * @param value2 defines the second operand
  3870. * @returns the new Vector3
  3871. */
  3872. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3873. /**
  3874. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3875. * @param value1 defines first vector
  3876. * @param value2 defines second vector
  3877. * @param ref defines third vector
  3878. * @returns ref
  3879. */
  3880. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3881. /**
  3882. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3883. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3884. * to something in order to rotate it from its local system to the given target system
  3885. * Note: axis1, axis2 and axis3 are normalized during this operation
  3886. * @param axis1 defines the first axis
  3887. * @param axis2 defines the second axis
  3888. * @param axis3 defines the third axis
  3889. * @returns a new Vector3
  3890. */
  3891. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3892. /**
  3893. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3894. * @param axis1 defines the first axis
  3895. * @param axis2 defines the second axis
  3896. * @param axis3 defines the third axis
  3897. * @param ref defines the Vector3 where to store the result
  3898. */
  3899. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3900. }
  3901. /**
  3902. * Vector4 class created for EulerAngle class conversion to Quaternion
  3903. */
  3904. export class Vector4 {
  3905. /** x value of the vector */
  3906. x: number;
  3907. /** y value of the vector */
  3908. y: number;
  3909. /** z value of the vector */
  3910. z: number;
  3911. /** w value of the vector */
  3912. w: number;
  3913. /**
  3914. * Creates a Vector4 object from the given floats.
  3915. * @param x x value of the vector
  3916. * @param y y value of the vector
  3917. * @param z z value of the vector
  3918. * @param w w value of the vector
  3919. */
  3920. constructor(
  3921. /** x value of the vector */
  3922. x: number,
  3923. /** y value of the vector */
  3924. y: number,
  3925. /** z value of the vector */
  3926. z: number,
  3927. /** w value of the vector */
  3928. w: number);
  3929. /**
  3930. * Returns the string with the Vector4 coordinates.
  3931. * @returns a string containing all the vector values
  3932. */
  3933. toString(): string;
  3934. /**
  3935. * Returns the string "Vector4".
  3936. * @returns "Vector4"
  3937. */
  3938. getClassName(): string;
  3939. /**
  3940. * Returns the Vector4 hash code.
  3941. * @returns a unique hash code
  3942. */
  3943. getHashCode(): number;
  3944. /**
  3945. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3946. * @returns the resulting array
  3947. */
  3948. asArray(): number[];
  3949. /**
  3950. * Populates the given array from the given index with the Vector4 coordinates.
  3951. * @param array array to populate
  3952. * @param index index of the array to start at (default: 0)
  3953. * @returns the Vector4.
  3954. */
  3955. toArray(array: FloatArray, index?: number): Vector4;
  3956. /**
  3957. * Update the current vector from an array
  3958. * @param array defines the destination array
  3959. * @param index defines the offset in the destination array
  3960. * @returns the current Vector3
  3961. */
  3962. fromArray(array: FloatArray, index?: number): Vector4;
  3963. /**
  3964. * Adds the given vector to the current Vector4.
  3965. * @param otherVector the vector to add
  3966. * @returns the updated Vector4.
  3967. */
  3968. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3969. /**
  3970. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3971. * @param otherVector the vector to add
  3972. * @returns the resulting vector
  3973. */
  3974. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3975. /**
  3976. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3977. * @param otherVector the vector to add
  3978. * @param result the vector to store the result
  3979. * @returns the current Vector4.
  3980. */
  3981. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3982. /**
  3983. * Subtract in place the given vector from the current Vector4.
  3984. * @param otherVector the vector to subtract
  3985. * @returns the updated Vector4.
  3986. */
  3987. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3988. /**
  3989. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3990. * @param otherVector the vector to add
  3991. * @returns the new vector with the result
  3992. */
  3993. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3994. /**
  3995. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3996. * @param otherVector the vector to subtract
  3997. * @param result the vector to store the result
  3998. * @returns the current Vector4.
  3999. */
  4000. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4001. /**
  4002. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4003. */
  4004. /**
  4005. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4006. * @param x value to subtract
  4007. * @param y value to subtract
  4008. * @param z value to subtract
  4009. * @param w value to subtract
  4010. * @returns new vector containing the result
  4011. */
  4012. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4013. /**
  4014. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4015. * @param x value to subtract
  4016. * @param y value to subtract
  4017. * @param z value to subtract
  4018. * @param w value to subtract
  4019. * @param result the vector to store the result in
  4020. * @returns the current Vector4.
  4021. */
  4022. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4023. /**
  4024. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4025. * @returns a new vector with the negated values
  4026. */
  4027. negate(): Vector4;
  4028. /**
  4029. * Negate this vector in place
  4030. * @returns this
  4031. */
  4032. negateInPlace(): Vector4;
  4033. /**
  4034. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4035. * @param result defines the Vector3 object where to store the result
  4036. * @returns the current Vector4
  4037. */
  4038. negateToRef(result: Vector4): Vector4;
  4039. /**
  4040. * Multiplies the current Vector4 coordinates by scale (float).
  4041. * @param scale the number to scale with
  4042. * @returns the updated Vector4.
  4043. */
  4044. scaleInPlace(scale: number): Vector4;
  4045. /**
  4046. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4047. * @param scale the number to scale with
  4048. * @returns a new vector with the result
  4049. */
  4050. scale(scale: number): Vector4;
  4051. /**
  4052. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4053. * @param scale the number to scale with
  4054. * @param result a vector to store the result in
  4055. * @returns the current Vector4.
  4056. */
  4057. scaleToRef(scale: number, result: Vector4): Vector4;
  4058. /**
  4059. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4060. * @param scale defines the scale factor
  4061. * @param result defines the Vector4 object where to store the result
  4062. * @returns the unmodified current Vector4
  4063. */
  4064. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4065. /**
  4066. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4067. * @param otherVector the vector to compare against
  4068. * @returns true if they are equal
  4069. */
  4070. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4071. /**
  4072. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4073. * @param otherVector vector to compare against
  4074. * @param epsilon (Default: very small number)
  4075. * @returns true if they are equal
  4076. */
  4077. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4078. /**
  4079. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4080. * @param x x value to compare against
  4081. * @param y y value to compare against
  4082. * @param z z value to compare against
  4083. * @param w w value to compare against
  4084. * @returns true if equal
  4085. */
  4086. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4087. /**
  4088. * Multiplies in place the current Vector4 by the given one.
  4089. * @param otherVector vector to multiple with
  4090. * @returns the updated Vector4.
  4091. */
  4092. multiplyInPlace(otherVector: Vector4): Vector4;
  4093. /**
  4094. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4095. * @param otherVector vector to multiple with
  4096. * @returns resulting new vector
  4097. */
  4098. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4099. /**
  4100. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4101. * @param otherVector vector to multiple with
  4102. * @param result vector to store the result
  4103. * @returns the current Vector4.
  4104. */
  4105. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4106. /**
  4107. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4108. * @param x x value multiply with
  4109. * @param y y value multiply with
  4110. * @param z z value multiply with
  4111. * @param w w value multiply with
  4112. * @returns resulting new vector
  4113. */
  4114. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4115. /**
  4116. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4117. * @param otherVector vector to devide with
  4118. * @returns resulting new vector
  4119. */
  4120. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4121. /**
  4122. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4123. * @param otherVector vector to devide with
  4124. * @param result vector to store the result
  4125. * @returns the current Vector4.
  4126. */
  4127. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4128. /**
  4129. * Divides the current Vector3 coordinates by the given ones.
  4130. * @param otherVector vector to devide with
  4131. * @returns the updated Vector3.
  4132. */
  4133. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4134. /**
  4135. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4136. * @param other defines the second operand
  4137. * @returns the current updated Vector4
  4138. */
  4139. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4140. /**
  4141. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4142. * @param other defines the second operand
  4143. * @returns the current updated Vector4
  4144. */
  4145. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4146. /**
  4147. * Gets a new Vector4 from current Vector4 floored values
  4148. * @returns a new Vector4
  4149. */
  4150. floor(): Vector4;
  4151. /**
  4152. * Gets a new Vector4 from current Vector3 floored values
  4153. * @returns a new Vector4
  4154. */
  4155. fract(): Vector4;
  4156. /**
  4157. * Returns the Vector4 length (float).
  4158. * @returns the length
  4159. */
  4160. length(): number;
  4161. /**
  4162. * Returns the Vector4 squared length (float).
  4163. * @returns the length squared
  4164. */
  4165. lengthSquared(): number;
  4166. /**
  4167. * Normalizes in place the Vector4.
  4168. * @returns the updated Vector4.
  4169. */
  4170. normalize(): Vector4;
  4171. /**
  4172. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4173. * @returns this converted to a new vector3
  4174. */
  4175. toVector3(): Vector3;
  4176. /**
  4177. * Returns a new Vector4 copied from the current one.
  4178. * @returns the new cloned vector
  4179. */
  4180. clone(): Vector4;
  4181. /**
  4182. * Updates the current Vector4 with the given one coordinates.
  4183. * @param source the source vector to copy from
  4184. * @returns the updated Vector4.
  4185. */
  4186. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4187. /**
  4188. * Updates the current Vector4 coordinates with the given floats.
  4189. * @param x float to copy from
  4190. * @param y float to copy from
  4191. * @param z float to copy from
  4192. * @param w float to copy from
  4193. * @returns the updated Vector4.
  4194. */
  4195. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4196. /**
  4197. * Updates the current Vector4 coordinates with the given floats.
  4198. * @param x float to set from
  4199. * @param y float to set from
  4200. * @param z float to set from
  4201. * @param w float to set from
  4202. * @returns the updated Vector4.
  4203. */
  4204. set(x: number, y: number, z: number, w: number): Vector4;
  4205. /**
  4206. * Copies the given float to the current Vector3 coordinates
  4207. * @param v defines the x, y, z and w coordinates of the operand
  4208. * @returns the current updated Vector3
  4209. */
  4210. setAll(v: number): Vector4;
  4211. /**
  4212. * Returns a new Vector4 set from the starting index of the given array.
  4213. * @param array the array to pull values from
  4214. * @param offset the offset into the array to start at
  4215. * @returns the new vector
  4216. */
  4217. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4218. /**
  4219. * Updates the given vector "result" from the starting index of the given array.
  4220. * @param array the array to pull values from
  4221. * @param offset the offset into the array to start at
  4222. * @param result the vector to store the result in
  4223. */
  4224. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4225. /**
  4226. * Updates the given vector "result" from the starting index of the given Float32Array.
  4227. * @param array the array to pull values from
  4228. * @param offset the offset into the array to start at
  4229. * @param result the vector to store the result in
  4230. */
  4231. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4232. /**
  4233. * Updates the given vector "result" coordinates from the given floats.
  4234. * @param x float to set from
  4235. * @param y float to set from
  4236. * @param z float to set from
  4237. * @param w float to set from
  4238. * @param result the vector to the floats in
  4239. */
  4240. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4241. /**
  4242. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4243. * @returns the new vector
  4244. */
  4245. static Zero(): Vector4;
  4246. /**
  4247. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4248. * @returns the new vector
  4249. */
  4250. static One(): Vector4;
  4251. /**
  4252. * Returns a new normalized Vector4 from the given one.
  4253. * @param vector the vector to normalize
  4254. * @returns the vector
  4255. */
  4256. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4257. /**
  4258. * Updates the given vector "result" from the normalization of the given one.
  4259. * @param vector the vector to normalize
  4260. * @param result the vector to store the result in
  4261. */
  4262. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4263. /**
  4264. * Returns a vector with the minimum values from the left and right vectors
  4265. * @param left left vector to minimize
  4266. * @param right right vector to minimize
  4267. * @returns a new vector with the minimum of the left and right vector values
  4268. */
  4269. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4270. /**
  4271. * Returns a vector with the maximum values from the left and right vectors
  4272. * @param left left vector to maximize
  4273. * @param right right vector to maximize
  4274. * @returns a new vector with the maximum of the left and right vector values
  4275. */
  4276. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4277. /**
  4278. * Returns the distance (float) between the vectors "value1" and "value2".
  4279. * @param value1 value to calulate the distance between
  4280. * @param value2 value to calulate the distance between
  4281. * @return the distance between the two vectors
  4282. */
  4283. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4284. /**
  4285. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4286. * @param value1 value to calulate the distance between
  4287. * @param value2 value to calulate the distance between
  4288. * @return the distance between the two vectors squared
  4289. */
  4290. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4291. /**
  4292. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4293. * @param value1 value to calulate the center between
  4294. * @param value2 value to calulate the center between
  4295. * @return the center between the two vectors
  4296. */
  4297. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4298. /**
  4299. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4300. * @param value1 defines first vector
  4301. * @param value2 defines second vector
  4302. * @param ref defines third vector
  4303. * @returns ref
  4304. */
  4305. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4306. /**
  4307. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4308. * This methods computes transformed normalized direction vectors only.
  4309. * @param vector the vector to transform
  4310. * @param transformation the transformation matrix to apply
  4311. * @returns the new vector
  4312. */
  4313. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4314. /**
  4315. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4316. * This methods computes transformed normalized direction vectors only.
  4317. * @param vector the vector to transform
  4318. * @param transformation the transformation matrix to apply
  4319. * @param result the vector to store the result in
  4320. */
  4321. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4322. /**
  4323. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4324. * This methods computes transformed normalized direction vectors only.
  4325. * @param x value to transform
  4326. * @param y value to transform
  4327. * @param z value to transform
  4328. * @param w value to transform
  4329. * @param transformation the transformation matrix to apply
  4330. * @param result the vector to store the results in
  4331. */
  4332. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4333. /**
  4334. * Creates a new Vector4 from a Vector3
  4335. * @param source defines the source data
  4336. * @param w defines the 4th component (default is 0)
  4337. * @returns a new Vector4
  4338. */
  4339. static FromVector3(source: Vector3, w?: number): Vector4;
  4340. }
  4341. /**
  4342. * Class used to store quaternion data
  4343. * @see https://en.wikipedia.org/wiki/Quaternion
  4344. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4345. */
  4346. export class Quaternion {
  4347. /** @hidden */
  4348. _x: number;
  4349. /** @hidden */
  4350. _y: number;
  4351. /** @hidden */
  4352. _z: number;
  4353. /** @hidden */
  4354. _w: number;
  4355. /** @hidden */
  4356. _isDirty: boolean;
  4357. /** Gets or sets the x coordinate */
  4358. get x(): number;
  4359. set x(value: number);
  4360. /** Gets or sets the y coordinate */
  4361. get y(): number;
  4362. set y(value: number);
  4363. /** Gets or sets the z coordinate */
  4364. get z(): number;
  4365. set z(value: number);
  4366. /** Gets or sets the w coordinate */
  4367. get w(): number;
  4368. set w(value: number);
  4369. /**
  4370. * Creates a new Quaternion from the given floats
  4371. * @param x defines the first component (0 by default)
  4372. * @param y defines the second component (0 by default)
  4373. * @param z defines the third component (0 by default)
  4374. * @param w defines the fourth component (1.0 by default)
  4375. */
  4376. constructor(x?: number, y?: number, z?: number, w?: number);
  4377. /**
  4378. * Gets a string representation for the current quaternion
  4379. * @returns a string with the Quaternion coordinates
  4380. */
  4381. toString(): string;
  4382. /**
  4383. * Gets the class name of the quaternion
  4384. * @returns the string "Quaternion"
  4385. */
  4386. getClassName(): string;
  4387. /**
  4388. * Gets a hash code for this quaternion
  4389. * @returns the quaternion hash code
  4390. */
  4391. getHashCode(): number;
  4392. /**
  4393. * Copy the quaternion to an array
  4394. * @returns a new array populated with 4 elements from the quaternion coordinates
  4395. */
  4396. asArray(): number[];
  4397. /**
  4398. * Check if two quaternions are equals
  4399. * @param otherQuaternion defines the second operand
  4400. * @return true if the current quaternion and the given one coordinates are strictly equals
  4401. */
  4402. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4403. /**
  4404. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4405. * @param otherQuaternion defines the other quaternion
  4406. * @param epsilon defines the minimal distance to consider equality
  4407. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4408. */
  4409. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4410. /**
  4411. * Clone the current quaternion
  4412. * @returns a new quaternion copied from the current one
  4413. */
  4414. clone(): Quaternion;
  4415. /**
  4416. * Copy a quaternion to the current one
  4417. * @param other defines the other quaternion
  4418. * @returns the updated current quaternion
  4419. */
  4420. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4421. /**
  4422. * Updates the current quaternion with the given float coordinates
  4423. * @param x defines the x coordinate
  4424. * @param y defines the y coordinate
  4425. * @param z defines the z coordinate
  4426. * @param w defines the w coordinate
  4427. * @returns the updated current quaternion
  4428. */
  4429. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4430. /**
  4431. * Updates the current quaternion from the given float coordinates
  4432. * @param x defines the x coordinate
  4433. * @param y defines the y coordinate
  4434. * @param z defines the z coordinate
  4435. * @param w defines the w coordinate
  4436. * @returns the updated current quaternion
  4437. */
  4438. set(x: number, y: number, z: number, w: number): Quaternion;
  4439. /**
  4440. * Adds two quaternions
  4441. * @param other defines the second operand
  4442. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4443. */
  4444. add(other: DeepImmutable<Quaternion>): Quaternion;
  4445. /**
  4446. * Add a quaternion to the current one
  4447. * @param other defines the quaternion to add
  4448. * @returns the current quaternion
  4449. */
  4450. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4451. /**
  4452. * Subtract two quaternions
  4453. * @param other defines the second operand
  4454. * @returns a new quaternion as the subtraction result of the given one from the current one
  4455. */
  4456. subtract(other: Quaternion): Quaternion;
  4457. /**
  4458. * Multiplies the current quaternion by a scale factor
  4459. * @param value defines the scale factor
  4460. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4461. */
  4462. scale(value: number): Quaternion;
  4463. /**
  4464. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4465. * @param scale defines the scale factor
  4466. * @param result defines the Quaternion object where to store the result
  4467. * @returns the unmodified current quaternion
  4468. */
  4469. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4470. /**
  4471. * Multiplies in place the current quaternion by a scale factor
  4472. * @param value defines the scale factor
  4473. * @returns the current modified quaternion
  4474. */
  4475. scaleInPlace(value: number): Quaternion;
  4476. /**
  4477. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4478. * @param scale defines the scale factor
  4479. * @param result defines the Quaternion object where to store the result
  4480. * @returns the unmodified current quaternion
  4481. */
  4482. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4483. /**
  4484. * Multiplies two quaternions
  4485. * @param q1 defines the second operand
  4486. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4487. */
  4488. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4489. /**
  4490. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4491. * @param q1 defines the second operand
  4492. * @param result defines the target quaternion
  4493. * @returns the current quaternion
  4494. */
  4495. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4496. /**
  4497. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4498. * @param q1 defines the second operand
  4499. * @returns the currentupdated quaternion
  4500. */
  4501. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4502. /**
  4503. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4504. * @param ref defines the target quaternion
  4505. * @returns the current quaternion
  4506. */
  4507. conjugateToRef(ref: Quaternion): Quaternion;
  4508. /**
  4509. * Conjugates in place (1-q) the current quaternion
  4510. * @returns the current updated quaternion
  4511. */
  4512. conjugateInPlace(): Quaternion;
  4513. /**
  4514. * Conjugates in place (1-q) the current quaternion
  4515. * @returns a new quaternion
  4516. */
  4517. conjugate(): Quaternion;
  4518. /**
  4519. * Gets length of current quaternion
  4520. * @returns the quaternion length (float)
  4521. */
  4522. length(): number;
  4523. /**
  4524. * Normalize in place the current quaternion
  4525. * @returns the current updated quaternion
  4526. */
  4527. normalize(): Quaternion;
  4528. /**
  4529. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4530. * @param order is a reserved parameter and is ignored for now
  4531. * @returns a new Vector3 containing the Euler angles
  4532. */
  4533. toEulerAngles(order?: string): Vector3;
  4534. /**
  4535. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4536. * @param result defines the vector which will be filled with the Euler angles
  4537. * @returns the current unchanged quaternion
  4538. */
  4539. toEulerAnglesToRef(result: Vector3): Quaternion;
  4540. /**
  4541. * Updates the given rotation matrix with the current quaternion values
  4542. * @param result defines the target matrix
  4543. * @returns the current unchanged quaternion
  4544. */
  4545. toRotationMatrix(result: Matrix): Quaternion;
  4546. /**
  4547. * Updates the current quaternion from the given rotation matrix values
  4548. * @param matrix defines the source matrix
  4549. * @returns the current updated quaternion
  4550. */
  4551. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4552. /**
  4553. * Creates a new quaternion from a rotation matrix
  4554. * @param matrix defines the source matrix
  4555. * @returns a new quaternion created from the given rotation matrix values
  4556. */
  4557. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4558. /**
  4559. * Updates the given quaternion with the given rotation matrix values
  4560. * @param matrix defines the source matrix
  4561. * @param result defines the target quaternion
  4562. */
  4563. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4564. /**
  4565. * Returns the dot product (float) between the quaternions "left" and "right"
  4566. * @param left defines the left operand
  4567. * @param right defines the right operand
  4568. * @returns the dot product
  4569. */
  4570. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4571. /**
  4572. * Checks if the two quaternions are close to each other
  4573. * @param quat0 defines the first quaternion to check
  4574. * @param quat1 defines the second quaternion to check
  4575. * @returns true if the two quaternions are close to each other
  4576. */
  4577. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4578. /**
  4579. * Creates an empty quaternion
  4580. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4581. */
  4582. static Zero(): Quaternion;
  4583. /**
  4584. * Inverse a given quaternion
  4585. * @param q defines the source quaternion
  4586. * @returns a new quaternion as the inverted current quaternion
  4587. */
  4588. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4589. /**
  4590. * Inverse a given quaternion
  4591. * @param q defines the source quaternion
  4592. * @param result the quaternion the result will be stored in
  4593. * @returns the result quaternion
  4594. */
  4595. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4596. /**
  4597. * Creates an identity quaternion
  4598. * @returns the identity quaternion
  4599. */
  4600. static Identity(): Quaternion;
  4601. /**
  4602. * Gets a boolean indicating if the given quaternion is identity
  4603. * @param quaternion defines the quaternion to check
  4604. * @returns true if the quaternion is identity
  4605. */
  4606. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4607. /**
  4608. * Creates a quaternion from a rotation around an axis
  4609. * @param axis defines the axis to use
  4610. * @param angle defines the angle to use
  4611. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4612. */
  4613. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4614. /**
  4615. * Creates a rotation around an axis and stores it into the given quaternion
  4616. * @param axis defines the axis to use
  4617. * @param angle defines the angle to use
  4618. * @param result defines the target quaternion
  4619. * @returns the target quaternion
  4620. */
  4621. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4622. /**
  4623. * Creates a new quaternion from data stored into an array
  4624. * @param array defines the data source
  4625. * @param offset defines the offset in the source array where the data starts
  4626. * @returns a new quaternion
  4627. */
  4628. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4629. /**
  4630. * Updates the given quaternion "result" from the starting index of the given array.
  4631. * @param array the array to pull values from
  4632. * @param offset the offset into the array to start at
  4633. * @param result the quaternion to store the result in
  4634. */
  4635. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4636. /**
  4637. * Create a quaternion from Euler rotation angles
  4638. * @param x Pitch
  4639. * @param y Yaw
  4640. * @param z Roll
  4641. * @returns the new Quaternion
  4642. */
  4643. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4644. /**
  4645. * Updates a quaternion from Euler rotation angles
  4646. * @param x Pitch
  4647. * @param y Yaw
  4648. * @param z Roll
  4649. * @param result the quaternion to store the result
  4650. * @returns the updated quaternion
  4651. */
  4652. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4653. /**
  4654. * Create a quaternion from Euler rotation vector
  4655. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4656. * @returns the new Quaternion
  4657. */
  4658. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4659. /**
  4660. * Updates a quaternion from Euler rotation vector
  4661. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4662. * @param result the quaternion to store the result
  4663. * @returns the updated quaternion
  4664. */
  4665. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4666. /**
  4667. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  4668. * @param vecFrom defines the direction vector from which to rotate
  4669. * @param vecTo defines the direction vector to which to rotate
  4670. * @param result the quaternion to store the result
  4671. * @returns the updated quaternion
  4672. */
  4673. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4674. /**
  4675. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4676. * @param yaw defines the rotation around Y axis
  4677. * @param pitch defines the rotation around X axis
  4678. * @param roll defines the rotation around Z axis
  4679. * @returns the new quaternion
  4680. */
  4681. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4682. /**
  4683. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4684. * @param yaw defines the rotation around Y axis
  4685. * @param pitch defines the rotation around X axis
  4686. * @param roll defines the rotation around Z axis
  4687. * @param result defines the target quaternion
  4688. */
  4689. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4690. /**
  4691. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4692. * @param alpha defines the rotation around first axis
  4693. * @param beta defines the rotation around second axis
  4694. * @param gamma defines the rotation around third axis
  4695. * @returns the new quaternion
  4696. */
  4697. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4698. /**
  4699. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4700. * @param alpha defines the rotation around first axis
  4701. * @param beta defines the rotation around second axis
  4702. * @param gamma defines the rotation around third axis
  4703. * @param result defines the target quaternion
  4704. */
  4705. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4706. /**
  4707. * 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)
  4708. * @param axis1 defines the first axis
  4709. * @param axis2 defines the second axis
  4710. * @param axis3 defines the third axis
  4711. * @returns the new quaternion
  4712. */
  4713. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4714. /**
  4715. * 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
  4716. * @param axis1 defines the first axis
  4717. * @param axis2 defines the second axis
  4718. * @param axis3 defines the third axis
  4719. * @param ref defines the target quaternion
  4720. */
  4721. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4722. /**
  4723. * Interpolates between two quaternions
  4724. * @param left defines first quaternion
  4725. * @param right defines second quaternion
  4726. * @param amount defines the gradient to use
  4727. * @returns the new interpolated quaternion
  4728. */
  4729. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4730. /**
  4731. * Interpolates between two quaternions and stores it into a target quaternion
  4732. * @param left defines first quaternion
  4733. * @param right defines second quaternion
  4734. * @param amount defines the gradient to use
  4735. * @param result defines the target quaternion
  4736. */
  4737. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4738. /**
  4739. * Interpolate between two quaternions using Hermite interpolation
  4740. * @param value1 defines first quaternion
  4741. * @param tangent1 defines the incoming tangent
  4742. * @param value2 defines second quaternion
  4743. * @param tangent2 defines the outgoing tangent
  4744. * @param amount defines the target quaternion
  4745. * @returns the new interpolated quaternion
  4746. */
  4747. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4748. }
  4749. /**
  4750. * Class used to store matrix data (4x4)
  4751. */
  4752. export class Matrix {
  4753. /**
  4754. * Gets the precision of matrix computations
  4755. */
  4756. static get Use64Bits(): boolean;
  4757. private static _updateFlagSeed;
  4758. private static _identityReadOnly;
  4759. private _isIdentity;
  4760. private _isIdentityDirty;
  4761. private _isIdentity3x2;
  4762. private _isIdentity3x2Dirty;
  4763. /**
  4764. * Gets the update flag of the matrix which is an unique number for the matrix.
  4765. * It will be incremented every time the matrix data change.
  4766. * You can use it to speed the comparison between two versions of the same matrix.
  4767. */
  4768. updateFlag: number;
  4769. private readonly _m;
  4770. /**
  4771. * Gets the internal data of the matrix
  4772. */
  4773. get m(): DeepImmutable<Float32Array | Array<number>>;
  4774. /** @hidden */
  4775. _markAsUpdated(): void;
  4776. /** @hidden */
  4777. private _updateIdentityStatus;
  4778. /**
  4779. * Creates an empty matrix (filled with zeros)
  4780. */
  4781. constructor();
  4782. /**
  4783. * Check if the current matrix is identity
  4784. * @returns true is the matrix is the identity matrix
  4785. */
  4786. isIdentity(): boolean;
  4787. /**
  4788. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4789. * @returns true is the matrix is the identity matrix
  4790. */
  4791. isIdentityAs3x2(): boolean;
  4792. /**
  4793. * Gets the determinant of the matrix
  4794. * @returns the matrix determinant
  4795. */
  4796. determinant(): number;
  4797. /**
  4798. * Returns the matrix as a Float32Array or Array<number>
  4799. * @returns the matrix underlying array
  4800. */
  4801. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4802. /**
  4803. * Returns the matrix as a Float32Array or Array<number>
  4804. * @returns the matrix underlying array.
  4805. */
  4806. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4807. /**
  4808. * Inverts the current matrix in place
  4809. * @returns the current inverted matrix
  4810. */
  4811. invert(): Matrix;
  4812. /**
  4813. * Sets all the matrix elements to zero
  4814. * @returns the current matrix
  4815. */
  4816. reset(): Matrix;
  4817. /**
  4818. * Adds the current matrix with a second one
  4819. * @param other defines the matrix to add
  4820. * @returns a new matrix as the addition of the current matrix and the given one
  4821. */
  4822. add(other: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4825. * @param other defines the matrix to add
  4826. * @param result defines the target matrix
  4827. * @returns the current matrix
  4828. */
  4829. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4830. /**
  4831. * Adds in place the given matrix to the current matrix
  4832. * @param other defines the second operand
  4833. * @returns the current updated matrix
  4834. */
  4835. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4836. /**
  4837. * Sets the given matrix to the current inverted Matrix
  4838. * @param other defines the target matrix
  4839. * @returns the unmodified current matrix
  4840. */
  4841. invertToRef(other: Matrix): Matrix;
  4842. /**
  4843. * add a value at the specified position in the current Matrix
  4844. * @param index the index of the value within the matrix. between 0 and 15.
  4845. * @param value the value to be added
  4846. * @returns the current updated matrix
  4847. */
  4848. addAtIndex(index: number, value: number): Matrix;
  4849. /**
  4850. * mutiply the specified position in the current Matrix by a value
  4851. * @param index the index of the value within the matrix. between 0 and 15.
  4852. * @param value the value to be added
  4853. * @returns the current updated matrix
  4854. */
  4855. multiplyAtIndex(index: number, value: number): Matrix;
  4856. /**
  4857. * Inserts the translation vector (using 3 floats) in the current matrix
  4858. * @param x defines the 1st component of the translation
  4859. * @param y defines the 2nd component of the translation
  4860. * @param z defines the 3rd component of the translation
  4861. * @returns the current updated matrix
  4862. */
  4863. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4864. /**
  4865. * Adds the translation vector (using 3 floats) in the current matrix
  4866. * @param x defines the 1st component of the translation
  4867. * @param y defines the 2nd component of the translation
  4868. * @param z defines the 3rd component of the translation
  4869. * @returns the current updated matrix
  4870. */
  4871. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4872. /**
  4873. * Inserts the translation vector in the current matrix
  4874. * @param vector3 defines the translation to insert
  4875. * @returns the current updated matrix
  4876. */
  4877. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4878. /**
  4879. * Gets the translation value of the current matrix
  4880. * @returns a new Vector3 as the extracted translation from the matrix
  4881. */
  4882. getTranslation(): Vector3;
  4883. /**
  4884. * Fill a Vector3 with the extracted translation from the matrix
  4885. * @param result defines the Vector3 where to store the translation
  4886. * @returns the current matrix
  4887. */
  4888. getTranslationToRef(result: Vector3): Matrix;
  4889. /**
  4890. * Remove rotation and scaling part from the matrix
  4891. * @returns the updated matrix
  4892. */
  4893. removeRotationAndScaling(): Matrix;
  4894. /**
  4895. * Multiply two matrices
  4896. * @param other defines the second operand
  4897. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4898. */
  4899. multiply(other: DeepImmutable<Matrix>): Matrix;
  4900. /**
  4901. * Copy the current matrix from the given one
  4902. * @param other defines the source matrix
  4903. * @returns the current updated matrix
  4904. */
  4905. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4906. /**
  4907. * Populates the given array from the starting index with the current matrix values
  4908. * @param array defines the target array
  4909. * @param offset defines the offset in the target array where to start storing values
  4910. * @returns the current matrix
  4911. */
  4912. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4913. /**
  4914. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4915. * @param other defines the second operand
  4916. * @param result defines the matrix where to store the multiplication
  4917. * @returns the current matrix
  4918. */
  4919. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4920. /**
  4921. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4922. * @param other defines the second operand
  4923. * @param result defines the array where to store the multiplication
  4924. * @param offset defines the offset in the target array where to start storing values
  4925. * @returns the current matrix
  4926. */
  4927. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4928. /**
  4929. * Check equality between this matrix and a second one
  4930. * @param value defines the second matrix to compare
  4931. * @returns true is the current matrix and the given one values are strictly equal
  4932. */
  4933. equals(value: DeepImmutable<Matrix>): boolean;
  4934. /**
  4935. * Clone the current matrix
  4936. * @returns a new matrix from the current matrix
  4937. */
  4938. clone(): Matrix;
  4939. /**
  4940. * Returns the name of the current matrix class
  4941. * @returns the string "Matrix"
  4942. */
  4943. getClassName(): string;
  4944. /**
  4945. * Gets the hash code of the current matrix
  4946. * @returns the hash code
  4947. */
  4948. getHashCode(): number;
  4949. /**
  4950. * Decomposes the current Matrix into a translation, rotation and scaling components
  4951. * @param scale defines the scale vector3 given as a reference to update
  4952. * @param rotation defines the rotation quaternion given as a reference to update
  4953. * @param translation defines the translation vector3 given as a reference to update
  4954. * @returns true if operation was successful
  4955. */
  4956. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4957. /**
  4958. * Gets specific row of the matrix
  4959. * @param index defines the number of the row to get
  4960. * @returns the index-th row of the current matrix as a new Vector4
  4961. */
  4962. getRow(index: number): Nullable<Vector4>;
  4963. /**
  4964. * Sets the index-th row of the current matrix to the vector4 values
  4965. * @param index defines the number of the row to set
  4966. * @param row defines the target vector4
  4967. * @returns the updated current matrix
  4968. */
  4969. setRow(index: number, row: Vector4): Matrix;
  4970. /**
  4971. * Compute the transpose of the matrix
  4972. * @returns the new transposed matrix
  4973. */
  4974. transpose(): Matrix;
  4975. /**
  4976. * Compute the transpose of the matrix and store it in a given matrix
  4977. * @param result defines the target matrix
  4978. * @returns the current matrix
  4979. */
  4980. transposeToRef(result: Matrix): Matrix;
  4981. /**
  4982. * Sets the index-th row of the current matrix with the given 4 x float values
  4983. * @param index defines the row index
  4984. * @param x defines the x component to set
  4985. * @param y defines the y component to set
  4986. * @param z defines the z component to set
  4987. * @param w defines the w component to set
  4988. * @returns the updated current matrix
  4989. */
  4990. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4991. /**
  4992. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4993. * @param scale defines the scale factor
  4994. * @returns a new matrix
  4995. */
  4996. scale(scale: number): Matrix;
  4997. /**
  4998. * Scale the current matrix values by a factor to a given result matrix
  4999. * @param scale defines the scale factor
  5000. * @param result defines the matrix to store the result
  5001. * @returns the current matrix
  5002. */
  5003. scaleToRef(scale: number, result: Matrix): Matrix;
  5004. /**
  5005. * Scale the current matrix values by a factor and add the result to a given matrix
  5006. * @param scale defines the scale factor
  5007. * @param result defines the Matrix to store the result
  5008. * @returns the current matrix
  5009. */
  5010. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5011. /**
  5012. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5013. * @param ref matrix to store the result
  5014. */
  5015. toNormalMatrix(ref: Matrix): void;
  5016. /**
  5017. * Gets only rotation part of the current matrix
  5018. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5019. */
  5020. getRotationMatrix(): Matrix;
  5021. /**
  5022. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5023. * @param result defines the target matrix to store data to
  5024. * @returns the current matrix
  5025. */
  5026. getRotationMatrixToRef(result: Matrix): Matrix;
  5027. /**
  5028. * Toggles model matrix from being right handed to left handed in place and vice versa
  5029. */
  5030. toggleModelMatrixHandInPlace(): void;
  5031. /**
  5032. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5033. */
  5034. toggleProjectionMatrixHandInPlace(): void;
  5035. /**
  5036. * Creates a matrix from an array
  5037. * @param array defines the source array
  5038. * @param offset defines an offset in the source array
  5039. * @returns a new Matrix set from the starting index of the given array
  5040. */
  5041. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5042. /**
  5043. * Copy the content of an array into a given matrix
  5044. * @param array defines the source array
  5045. * @param offset defines an offset in the source array
  5046. * @param result defines the target matrix
  5047. */
  5048. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5049. /**
  5050. * Stores an array into a matrix after having multiplied each component by a given factor
  5051. * @param array defines the source array
  5052. * @param offset defines the offset in the source array
  5053. * @param scale defines the scaling factor
  5054. * @param result defines the target matrix
  5055. */
  5056. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5057. /**
  5058. * Gets an identity matrix that must not be updated
  5059. */
  5060. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5061. /**
  5062. * Stores a list of values (16) inside a given matrix
  5063. * @param initialM11 defines 1st value of 1st row
  5064. * @param initialM12 defines 2nd value of 1st row
  5065. * @param initialM13 defines 3rd value of 1st row
  5066. * @param initialM14 defines 4th value of 1st row
  5067. * @param initialM21 defines 1st value of 2nd row
  5068. * @param initialM22 defines 2nd value of 2nd row
  5069. * @param initialM23 defines 3rd value of 2nd row
  5070. * @param initialM24 defines 4th value of 2nd row
  5071. * @param initialM31 defines 1st value of 3rd row
  5072. * @param initialM32 defines 2nd value of 3rd row
  5073. * @param initialM33 defines 3rd value of 3rd row
  5074. * @param initialM34 defines 4th value of 3rd row
  5075. * @param initialM41 defines 1st value of 4th row
  5076. * @param initialM42 defines 2nd value of 4th row
  5077. * @param initialM43 defines 3rd value of 4th row
  5078. * @param initialM44 defines 4th value of 4th row
  5079. * @param result defines the target matrix
  5080. */
  5081. 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;
  5082. /**
  5083. * Creates new matrix from a list of values (16)
  5084. * @param initialM11 defines 1st value of 1st row
  5085. * @param initialM12 defines 2nd value of 1st row
  5086. * @param initialM13 defines 3rd value of 1st row
  5087. * @param initialM14 defines 4th value of 1st row
  5088. * @param initialM21 defines 1st value of 2nd row
  5089. * @param initialM22 defines 2nd value of 2nd row
  5090. * @param initialM23 defines 3rd value of 2nd row
  5091. * @param initialM24 defines 4th value of 2nd row
  5092. * @param initialM31 defines 1st value of 3rd row
  5093. * @param initialM32 defines 2nd value of 3rd row
  5094. * @param initialM33 defines 3rd value of 3rd row
  5095. * @param initialM34 defines 4th value of 3rd row
  5096. * @param initialM41 defines 1st value of 4th row
  5097. * @param initialM42 defines 2nd value of 4th row
  5098. * @param initialM43 defines 3rd value of 4th row
  5099. * @param initialM44 defines 4th value of 4th row
  5100. * @returns the new matrix
  5101. */
  5102. 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;
  5103. /**
  5104. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5105. * @param scale defines the scale vector3
  5106. * @param rotation defines the rotation quaternion
  5107. * @param translation defines the translation vector3
  5108. * @returns a new matrix
  5109. */
  5110. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5111. /**
  5112. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5113. * @param scale defines the scale vector3
  5114. * @param rotation defines the rotation quaternion
  5115. * @param translation defines the translation vector3
  5116. * @param result defines the target matrix
  5117. */
  5118. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5119. /**
  5120. * Creates a new identity matrix
  5121. * @returns a new identity matrix
  5122. */
  5123. static Identity(): Matrix;
  5124. /**
  5125. * Creates a new identity matrix and stores the result in a given matrix
  5126. * @param result defines the target matrix
  5127. */
  5128. static IdentityToRef(result: Matrix): void;
  5129. /**
  5130. * Creates a new zero matrix
  5131. * @returns a new zero matrix
  5132. */
  5133. static Zero(): Matrix;
  5134. /**
  5135. * Creates a new rotation matrix for "angle" radians around the X axis
  5136. * @param angle defines the angle (in radians) to use
  5137. * @return the new matrix
  5138. */
  5139. static RotationX(angle: number): Matrix;
  5140. /**
  5141. * Creates a new matrix as the invert of a given matrix
  5142. * @param source defines the source matrix
  5143. * @returns the new matrix
  5144. */
  5145. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5146. /**
  5147. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5148. * @param angle defines the angle (in radians) to use
  5149. * @param result defines the target matrix
  5150. */
  5151. static RotationXToRef(angle: number, result: Matrix): void;
  5152. /**
  5153. * Creates a new rotation matrix for "angle" radians around the Y axis
  5154. * @param angle defines the angle (in radians) to use
  5155. * @return the new matrix
  5156. */
  5157. static RotationY(angle: number): Matrix;
  5158. /**
  5159. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5160. * @param angle defines the angle (in radians) to use
  5161. * @param result defines the target matrix
  5162. */
  5163. static RotationYToRef(angle: number, result: Matrix): void;
  5164. /**
  5165. * Creates a new rotation matrix for "angle" radians around the Z axis
  5166. * @param angle defines the angle (in radians) to use
  5167. * @return the new matrix
  5168. */
  5169. static RotationZ(angle: number): Matrix;
  5170. /**
  5171. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5172. * @param angle defines the angle (in radians) to use
  5173. * @param result defines the target matrix
  5174. */
  5175. static RotationZToRef(angle: number, result: Matrix): void;
  5176. /**
  5177. * Creates a new rotation matrix for "angle" radians around the given axis
  5178. * @param axis defines the axis to use
  5179. * @param angle defines the angle (in radians) to use
  5180. * @return the new matrix
  5181. */
  5182. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5183. /**
  5184. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5185. * @param axis defines the axis to use
  5186. * @param angle defines the angle (in radians) to use
  5187. * @param result defines the target matrix
  5188. */
  5189. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5190. /**
  5191. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5192. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5193. * @param from defines the vector to align
  5194. * @param to defines the vector to align to
  5195. * @param result defines the target matrix
  5196. */
  5197. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5198. /**
  5199. * Creates a rotation matrix
  5200. * @param yaw defines the yaw angle in radians (Y axis)
  5201. * @param pitch defines the pitch angle in radians (X axis)
  5202. * @param roll defines the roll angle in radians (Z axis)
  5203. * @returns the new rotation matrix
  5204. */
  5205. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5206. /**
  5207. * Creates a rotation matrix and stores it in a given matrix
  5208. * @param yaw defines the yaw angle in radians (Y axis)
  5209. * @param pitch defines the pitch angle in radians (X axis)
  5210. * @param roll defines the roll angle in radians (Z axis)
  5211. * @param result defines the target matrix
  5212. */
  5213. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5214. /**
  5215. * Creates a scaling matrix
  5216. * @param x defines the scale factor on X axis
  5217. * @param y defines the scale factor on Y axis
  5218. * @param z defines the scale factor on Z axis
  5219. * @returns the new matrix
  5220. */
  5221. static Scaling(x: number, y: number, z: number): Matrix;
  5222. /**
  5223. * Creates a scaling matrix and stores it in a given matrix
  5224. * @param x defines the scale factor on X axis
  5225. * @param y defines the scale factor on Y axis
  5226. * @param z defines the scale factor on Z axis
  5227. * @param result defines the target matrix
  5228. */
  5229. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5230. /**
  5231. * Creates a translation matrix
  5232. * @param x defines the translation on X axis
  5233. * @param y defines the translation on Y axis
  5234. * @param z defines the translationon Z axis
  5235. * @returns the new matrix
  5236. */
  5237. static Translation(x: number, y: number, z: number): Matrix;
  5238. /**
  5239. * Creates a translation matrix and stores it in a given matrix
  5240. * @param x defines the translation on X axis
  5241. * @param y defines the translation on Y axis
  5242. * @param z defines the translationon Z axis
  5243. * @param result defines the target matrix
  5244. */
  5245. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5246. /**
  5247. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5248. * @param startValue defines the start value
  5249. * @param endValue defines the end value
  5250. * @param gradient defines the gradient factor
  5251. * @returns the new matrix
  5252. */
  5253. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5254. /**
  5255. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5256. * @param startValue defines the start value
  5257. * @param endValue defines the end value
  5258. * @param gradient defines the gradient factor
  5259. * @param result defines the Matrix object where to store data
  5260. */
  5261. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5262. /**
  5263. * Builds a new matrix whose values are computed by:
  5264. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5265. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5266. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5267. * @param startValue defines the first matrix
  5268. * @param endValue defines the second matrix
  5269. * @param gradient defines the gradient between the two matrices
  5270. * @returns the new matrix
  5271. */
  5272. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5273. /**
  5274. * Update a matrix to values which are computed by:
  5275. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5276. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5277. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5278. * @param startValue defines the first matrix
  5279. * @param endValue defines the second matrix
  5280. * @param gradient defines the gradient between the two matrices
  5281. * @param result defines the target matrix
  5282. */
  5283. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5284. /**
  5285. * 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"
  5286. * This function works in left handed mode
  5287. * @param eye defines the final position of the entity
  5288. * @param target defines where the entity should look at
  5289. * @param up defines the up vector for the entity
  5290. * @returns the new matrix
  5291. */
  5292. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5293. /**
  5294. * 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".
  5295. * This function works in left handed mode
  5296. * @param eye defines the final position of the entity
  5297. * @param target defines where the entity should look at
  5298. * @param up defines the up vector for the entity
  5299. * @param result defines the target matrix
  5300. */
  5301. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5302. /**
  5303. * 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"
  5304. * This function works in right handed mode
  5305. * @param eye defines the final position of the entity
  5306. * @param target defines where the entity should look at
  5307. * @param up defines the up vector for the entity
  5308. * @returns the new matrix
  5309. */
  5310. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5311. /**
  5312. * 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".
  5313. * This function works in right handed mode
  5314. * @param eye defines the final position of the entity
  5315. * @param target defines where the entity should look at
  5316. * @param up defines the up vector for the entity
  5317. * @param result defines the target matrix
  5318. */
  5319. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5320. /**
  5321. * Create a left-handed orthographic projection matrix
  5322. * @param width defines the viewport width
  5323. * @param height defines the viewport height
  5324. * @param znear defines the near clip plane
  5325. * @param zfar defines the far clip plane
  5326. * @returns a new matrix as a left-handed orthographic projection matrix
  5327. */
  5328. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5329. /**
  5330. * Store a left-handed orthographic projection to a given matrix
  5331. * @param width defines the viewport width
  5332. * @param height defines the viewport height
  5333. * @param znear defines the near clip plane
  5334. * @param zfar defines the far clip plane
  5335. * @param result defines the target matrix
  5336. */
  5337. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5338. /**
  5339. * Create a left-handed orthographic projection matrix
  5340. * @param left defines the viewport left coordinate
  5341. * @param right defines the viewport right coordinate
  5342. * @param bottom defines the viewport bottom coordinate
  5343. * @param top defines the viewport top coordinate
  5344. * @param znear defines the near clip plane
  5345. * @param zfar defines the far clip plane
  5346. * @returns a new matrix as a left-handed orthographic projection matrix
  5347. */
  5348. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5349. /**
  5350. * Stores a left-handed orthographic projection into a given matrix
  5351. * @param left defines the viewport left coordinate
  5352. * @param right defines the viewport right coordinate
  5353. * @param bottom defines the viewport bottom coordinate
  5354. * @param top defines the viewport top coordinate
  5355. * @param znear defines the near clip plane
  5356. * @param zfar defines the far clip plane
  5357. * @param result defines the target matrix
  5358. */
  5359. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5360. /**
  5361. * Creates a right-handed orthographic projection matrix
  5362. * @param left defines the viewport left coordinate
  5363. * @param right defines the viewport right coordinate
  5364. * @param bottom defines the viewport bottom coordinate
  5365. * @param top defines the viewport top coordinate
  5366. * @param znear defines the near clip plane
  5367. * @param zfar defines the far clip plane
  5368. * @returns a new matrix as a right-handed orthographic projection matrix
  5369. */
  5370. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5371. /**
  5372. * Stores a right-handed orthographic projection into a given matrix
  5373. * @param left defines the viewport left coordinate
  5374. * @param right defines the viewport right coordinate
  5375. * @param bottom defines the viewport bottom coordinate
  5376. * @param top defines the viewport top coordinate
  5377. * @param znear defines the near clip plane
  5378. * @param zfar defines the far clip plane
  5379. * @param result defines the target matrix
  5380. */
  5381. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5382. /**
  5383. * Creates a left-handed perspective projection matrix
  5384. * @param width defines the viewport width
  5385. * @param height defines the viewport height
  5386. * @param znear defines the near clip plane
  5387. * @param zfar defines the far clip plane
  5388. * @returns a new matrix as a left-handed perspective projection matrix
  5389. */
  5390. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5391. /**
  5392. * Creates a left-handed perspective projection matrix
  5393. * @param fov defines the horizontal field of view
  5394. * @param aspect defines the aspect ratio
  5395. * @param znear defines the near clip plane
  5396. * @param zfar defines the far clip plane
  5397. * @returns a new matrix as a left-handed perspective projection matrix
  5398. */
  5399. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5400. /**
  5401. * Stores a left-handed perspective projection into a given matrix
  5402. * @param fov defines the horizontal field of view
  5403. * @param aspect defines the aspect ratio
  5404. * @param znear defines the near clip plane
  5405. * @param zfar defines the far clip plane
  5406. * @param result defines the target matrix
  5407. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5408. */
  5409. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5410. /**
  5411. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5412. * @param fov defines the horizontal field of view
  5413. * @param aspect defines the aspect ratio
  5414. * @param znear defines the near clip plane
  5415. * @param zfar not used as infinity is used as far clip
  5416. * @param result defines the target matrix
  5417. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5418. */
  5419. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5420. /**
  5421. * Creates a right-handed perspective projection matrix
  5422. * @param fov defines the horizontal field of view
  5423. * @param aspect defines the aspect ratio
  5424. * @param znear defines the near clip plane
  5425. * @param zfar defines the far clip plane
  5426. * @returns a new matrix as a right-handed perspective projection matrix
  5427. */
  5428. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5429. /**
  5430. * Stores a right-handed perspective projection into a given matrix
  5431. * @param fov defines the horizontal field of view
  5432. * @param aspect defines the aspect ratio
  5433. * @param znear defines the near clip plane
  5434. * @param zfar defines the far clip plane
  5435. * @param result defines the target matrix
  5436. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5437. */
  5438. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5439. /**
  5440. * Stores a right-handed perspective projection into a given matrix
  5441. * @param fov defines the horizontal field of view
  5442. * @param aspect defines the aspect ratio
  5443. * @param znear defines the near clip plane
  5444. * @param zfar not used as infinity is used as far clip
  5445. * @param result defines the target matrix
  5446. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5447. */
  5448. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5449. /**
  5450. * Stores a perspective projection for WebVR info a given matrix
  5451. * @param fov defines the field of view
  5452. * @param znear defines the near clip plane
  5453. * @param zfar defines the far clip plane
  5454. * @param result defines the target matrix
  5455. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5456. */
  5457. static PerspectiveFovWebVRToRef(fov: {
  5458. upDegrees: number;
  5459. downDegrees: number;
  5460. leftDegrees: number;
  5461. rightDegrees: number;
  5462. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5463. /**
  5464. * Computes a complete transformation matrix
  5465. * @param viewport defines the viewport to use
  5466. * @param world defines the world matrix
  5467. * @param view defines the view matrix
  5468. * @param projection defines the projection matrix
  5469. * @param zmin defines the near clip plane
  5470. * @param zmax defines the far clip plane
  5471. * @returns the transformation matrix
  5472. */
  5473. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5474. /**
  5475. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5476. * @param matrix defines the matrix to use
  5477. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5478. */
  5479. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5480. /**
  5481. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5482. * @param matrix defines the matrix to use
  5483. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5484. */
  5485. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5486. /**
  5487. * Compute the transpose of a given matrix
  5488. * @param matrix defines the matrix to transpose
  5489. * @returns the new matrix
  5490. */
  5491. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5492. /**
  5493. * Compute the transpose of a matrix and store it in a target matrix
  5494. * @param matrix defines the matrix to transpose
  5495. * @param result defines the target matrix
  5496. */
  5497. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5498. /**
  5499. * Computes a reflection matrix from a plane
  5500. * @param plane defines the reflection plane
  5501. * @returns a new matrix
  5502. */
  5503. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5504. /**
  5505. * Computes a reflection matrix from a plane
  5506. * @param plane defines the reflection plane
  5507. * @param result defines the target matrix
  5508. */
  5509. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5510. /**
  5511. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5512. * @param xaxis defines the value of the 1st axis
  5513. * @param yaxis defines the value of the 2nd axis
  5514. * @param zaxis defines the value of the 3rd axis
  5515. * @param result defines the target matrix
  5516. */
  5517. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5518. /**
  5519. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5520. * @param quat defines the quaternion to use
  5521. * @param result defines the target matrix
  5522. */
  5523. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5524. }
  5525. /**
  5526. * @hidden
  5527. */
  5528. export class TmpVectors {
  5529. static Vector2: Vector2[];
  5530. static Vector3: Vector3[];
  5531. static Vector4: Vector4[];
  5532. static Quaternion: Quaternion[];
  5533. static Matrix: Matrix[];
  5534. }
  5535. }
  5536. declare module BABYLON {
  5537. /**
  5538. * Defines potential orientation for back face culling
  5539. */
  5540. export enum Orientation {
  5541. /**
  5542. * Clockwise
  5543. */
  5544. CW = 0,
  5545. /** Counter clockwise */
  5546. CCW = 1
  5547. }
  5548. /** Class used to represent a Bezier curve */
  5549. export class BezierCurve {
  5550. /**
  5551. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5552. * @param t defines the time
  5553. * @param x1 defines the left coordinate on X axis
  5554. * @param y1 defines the left coordinate on Y axis
  5555. * @param x2 defines the right coordinate on X axis
  5556. * @param y2 defines the right coordinate on Y axis
  5557. * @returns the interpolated value
  5558. */
  5559. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5560. }
  5561. /**
  5562. * Defines angle representation
  5563. */
  5564. export class Angle {
  5565. private _radians;
  5566. /**
  5567. * Creates an Angle object of "radians" radians (float).
  5568. * @param radians the angle in radians
  5569. */
  5570. constructor(radians: number);
  5571. /**
  5572. * Get value in degrees
  5573. * @returns the Angle value in degrees (float)
  5574. */
  5575. degrees(): number;
  5576. /**
  5577. * Get value in radians
  5578. * @returns the Angle value in radians (float)
  5579. */
  5580. radians(): number;
  5581. /**
  5582. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5583. * @param a defines first point as the origin
  5584. * @param b defines point
  5585. * @returns a new Angle
  5586. */
  5587. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5588. /**
  5589. * Gets a new Angle object from the given float in radians
  5590. * @param radians defines the angle value in radians
  5591. * @returns a new Angle
  5592. */
  5593. static FromRadians(radians: number): Angle;
  5594. /**
  5595. * Gets a new Angle object from the given float in degrees
  5596. * @param degrees defines the angle value in degrees
  5597. * @returns a new Angle
  5598. */
  5599. static FromDegrees(degrees: number): Angle;
  5600. }
  5601. /**
  5602. * This represents an arc in a 2d space.
  5603. */
  5604. export class Arc2 {
  5605. /** Defines the start point of the arc */
  5606. startPoint: Vector2;
  5607. /** Defines the mid point of the arc */
  5608. midPoint: Vector2;
  5609. /** Defines the end point of the arc */
  5610. endPoint: Vector2;
  5611. /**
  5612. * Defines the center point of the arc.
  5613. */
  5614. centerPoint: Vector2;
  5615. /**
  5616. * Defines the radius of the arc.
  5617. */
  5618. radius: number;
  5619. /**
  5620. * Defines the angle of the arc (from mid point to end point).
  5621. */
  5622. angle: Angle;
  5623. /**
  5624. * Defines the start angle of the arc (from start point to middle point).
  5625. */
  5626. startAngle: Angle;
  5627. /**
  5628. * Defines the orientation of the arc (clock wise/counter clock wise).
  5629. */
  5630. orientation: Orientation;
  5631. /**
  5632. * Creates an Arc object from the three given points : start, middle and end.
  5633. * @param startPoint Defines the start point of the arc
  5634. * @param midPoint Defines the midlle point of the arc
  5635. * @param endPoint Defines the end point of the arc
  5636. */
  5637. constructor(
  5638. /** Defines the start point of the arc */
  5639. startPoint: Vector2,
  5640. /** Defines the mid point of the arc */
  5641. midPoint: Vector2,
  5642. /** Defines the end point of the arc */
  5643. endPoint: Vector2);
  5644. }
  5645. /**
  5646. * Represents a 2D path made up of multiple 2D points
  5647. */
  5648. export class Path2 {
  5649. private _points;
  5650. private _length;
  5651. /**
  5652. * If the path start and end point are the same
  5653. */
  5654. closed: boolean;
  5655. /**
  5656. * Creates a Path2 object from the starting 2D coordinates x and y.
  5657. * @param x the starting points x value
  5658. * @param y the starting points y value
  5659. */
  5660. constructor(x: number, y: number);
  5661. /**
  5662. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5663. * @param x the added points x value
  5664. * @param y the added points y value
  5665. * @returns the updated Path2.
  5666. */
  5667. addLineTo(x: number, y: number): Path2;
  5668. /**
  5669. * 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.
  5670. * @param midX middle point x value
  5671. * @param midY middle point y value
  5672. * @param endX end point x value
  5673. * @param endY end point y value
  5674. * @param numberOfSegments (default: 36)
  5675. * @returns the updated Path2.
  5676. */
  5677. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5678. /**
  5679. * Closes the Path2.
  5680. * @returns the Path2.
  5681. */
  5682. close(): Path2;
  5683. /**
  5684. * Gets the sum of the distance between each sequential point in the path
  5685. * @returns the Path2 total length (float).
  5686. */
  5687. length(): number;
  5688. /**
  5689. * Gets the points which construct the path
  5690. * @returns the Path2 internal array of points.
  5691. */
  5692. getPoints(): Vector2[];
  5693. /**
  5694. * Retreives the point at the distance aways from the starting point
  5695. * @param normalizedLengthPosition the length along the path to retreive the point from
  5696. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5697. */
  5698. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5699. /**
  5700. * Creates a new path starting from an x and y position
  5701. * @param x starting x value
  5702. * @param y starting y value
  5703. * @returns a new Path2 starting at the coordinates (x, y).
  5704. */
  5705. static StartingAt(x: number, y: number): Path2;
  5706. }
  5707. /**
  5708. * Represents a 3D path made up of multiple 3D points
  5709. */
  5710. export class Path3D {
  5711. /**
  5712. * an array of Vector3, the curve axis of the Path3D
  5713. */
  5714. path: Vector3[];
  5715. private _curve;
  5716. private _distances;
  5717. private _tangents;
  5718. private _normals;
  5719. private _binormals;
  5720. private _raw;
  5721. private _alignTangentsWithPath;
  5722. private readonly _pointAtData;
  5723. /**
  5724. * new Path3D(path, normal, raw)
  5725. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5726. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5727. * @param path an array of Vector3, the curve axis of the Path3D
  5728. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5729. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5730. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5731. */
  5732. constructor(
  5733. /**
  5734. * an array of Vector3, the curve axis of the Path3D
  5735. */
  5736. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5737. /**
  5738. * Returns the Path3D array of successive Vector3 designing its curve.
  5739. * @returns the Path3D array of successive Vector3 designing its curve.
  5740. */
  5741. getCurve(): Vector3[];
  5742. /**
  5743. * Returns the Path3D array of successive Vector3 designing its curve.
  5744. * @returns the Path3D array of successive Vector3 designing its curve.
  5745. */
  5746. getPoints(): Vector3[];
  5747. /**
  5748. * @returns the computed length (float) of the path.
  5749. */
  5750. length(): number;
  5751. /**
  5752. * Returns an array populated with tangent vectors on each Path3D curve point.
  5753. * @returns an array populated with tangent vectors on each Path3D curve point.
  5754. */
  5755. getTangents(): Vector3[];
  5756. /**
  5757. * Returns an array populated with normal vectors on each Path3D curve point.
  5758. * @returns an array populated with normal vectors on each Path3D curve point.
  5759. */
  5760. getNormals(): Vector3[];
  5761. /**
  5762. * Returns an array populated with binormal vectors on each Path3D curve point.
  5763. * @returns an array populated with binormal vectors on each Path3D curve point.
  5764. */
  5765. getBinormals(): Vector3[];
  5766. /**
  5767. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5768. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5769. */
  5770. getDistances(): number[];
  5771. /**
  5772. * Returns an interpolated point along this path
  5773. * @param position the position of the point along this path, from 0.0 to 1.0
  5774. * @returns a new Vector3 as the point
  5775. */
  5776. getPointAt(position: number): Vector3;
  5777. /**
  5778. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5779. * @param position the position of the point along this path, from 0.0 to 1.0
  5780. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5781. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5782. */
  5783. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5784. /**
  5785. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5786. * @param position the position of the point along this path, from 0.0 to 1.0
  5787. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5788. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5789. */
  5790. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5791. /**
  5792. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5793. * @param position the position of the point along this path, from 0.0 to 1.0
  5794. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5795. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5796. */
  5797. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5798. /**
  5799. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5800. * @param position the position of the point along this path, from 0.0 to 1.0
  5801. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5802. */
  5803. getDistanceAt(position: number): number;
  5804. /**
  5805. * Returns the array index of the previous point of an interpolated point along this path
  5806. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5807. * @returns the array index
  5808. */
  5809. getPreviousPointIndexAt(position: number): number;
  5810. /**
  5811. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5812. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5813. * @returns the sub position
  5814. */
  5815. getSubPositionAt(position: number): number;
  5816. /**
  5817. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5818. * @param target the vector of which to get the closest position to
  5819. * @returns the position of the closest virtual point on this path to the target vector
  5820. */
  5821. getClosestPositionTo(target: Vector3): number;
  5822. /**
  5823. * Returns a sub path (slice) of this path
  5824. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5825. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5826. * @returns a sub path (slice) of this path
  5827. */
  5828. slice(start?: number, end?: number): Path3D;
  5829. /**
  5830. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5831. * @param path path which all values are copied into the curves points
  5832. * @param firstNormal which should be projected onto the curve
  5833. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5834. * @returns the same object updated.
  5835. */
  5836. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5837. private _compute;
  5838. private _getFirstNonNullVector;
  5839. private _getLastNonNullVector;
  5840. private _normalVector;
  5841. /**
  5842. * Updates the point at data for an interpolated point along this curve
  5843. * @param position the position of the point along this curve, from 0.0 to 1.0
  5844. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5845. * @returns the (updated) point at data
  5846. */
  5847. private _updatePointAtData;
  5848. /**
  5849. * Updates the point at data from the specified parameters
  5850. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5851. * @param point the interpolated point
  5852. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5853. */
  5854. private _setPointAtData;
  5855. /**
  5856. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5857. */
  5858. private _updateInterpolationMatrix;
  5859. }
  5860. /**
  5861. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5862. * A Curve3 is designed from a series of successive Vector3.
  5863. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5864. */
  5865. export class Curve3 {
  5866. private _points;
  5867. private _length;
  5868. /**
  5869. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5870. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5871. * @param v1 (Vector3) the control point
  5872. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5873. * @param nbPoints (integer) the wanted number of points in the curve
  5874. * @returns the created Curve3
  5875. */
  5876. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5877. /**
  5878. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5879. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5880. * @param v1 (Vector3) the first control point
  5881. * @param v2 (Vector3) the second control point
  5882. * @param v3 (Vector3) the end point of the Cubic Bezier
  5883. * @param nbPoints (integer) the wanted number of points in the curve
  5884. * @returns the created Curve3
  5885. */
  5886. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5887. /**
  5888. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5889. * @param p1 (Vector3) the origin point of the Hermite Spline
  5890. * @param t1 (Vector3) the tangent vector at the origin point
  5891. * @param p2 (Vector3) the end point of the Hermite Spline
  5892. * @param t2 (Vector3) the tangent vector at the end point
  5893. * @param nbPoints (integer) the wanted number of points in the curve
  5894. * @returns the created Curve3
  5895. */
  5896. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5897. /**
  5898. * Returns a Curve3 object along a CatmullRom Spline curve :
  5899. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5900. * @param nbPoints (integer) the wanted number of points between each curve control points
  5901. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5902. * @returns the created Curve3
  5903. */
  5904. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5905. /**
  5906. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5907. * A Curve3 is designed from a series of successive Vector3.
  5908. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5909. * @param points points which make up the curve
  5910. */
  5911. constructor(points: Vector3[]);
  5912. /**
  5913. * @returns the Curve3 stored array of successive Vector3
  5914. */
  5915. getPoints(): Vector3[];
  5916. /**
  5917. * @returns the computed length (float) of the curve.
  5918. */
  5919. length(): number;
  5920. /**
  5921. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5922. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5923. * curveA and curveB keep unchanged.
  5924. * @param curve the curve to continue from this curve
  5925. * @returns the newly constructed curve
  5926. */
  5927. continue(curve: DeepImmutable<Curve3>): Curve3;
  5928. private _computeLength;
  5929. }
  5930. }
  5931. declare module BABYLON {
  5932. /**
  5933. * This represents the main contract an easing function should follow.
  5934. * Easing functions are used throughout the animation system.
  5935. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5936. */
  5937. export interface IEasingFunction {
  5938. /**
  5939. * Given an input gradient between 0 and 1, this returns the corresponding value
  5940. * of the easing function.
  5941. * The link below provides some of the most common examples of easing functions.
  5942. * @see https://easings.net/
  5943. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5944. * @returns the corresponding value on the curve defined by the easing function
  5945. */
  5946. ease(gradient: number): number;
  5947. }
  5948. /**
  5949. * Base class used for every default easing function.
  5950. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5951. */
  5952. export class EasingFunction implements IEasingFunction {
  5953. /**
  5954. * Interpolation follows the mathematical formula associated with the easing function.
  5955. */
  5956. static readonly EASINGMODE_EASEIN: number;
  5957. /**
  5958. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5959. */
  5960. static readonly EASINGMODE_EASEOUT: number;
  5961. /**
  5962. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5963. */
  5964. static readonly EASINGMODE_EASEINOUT: number;
  5965. private _easingMode;
  5966. /**
  5967. * Sets the easing mode of the current function.
  5968. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5969. */
  5970. setEasingMode(easingMode: number): void;
  5971. /**
  5972. * Gets the current easing mode.
  5973. * @returns the easing mode
  5974. */
  5975. getEasingMode(): number;
  5976. /**
  5977. * @hidden
  5978. */
  5979. easeInCore(gradient: number): number;
  5980. /**
  5981. * Given an input gradient between 0 and 1, this returns the corresponding value
  5982. * of the easing function.
  5983. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5984. * @returns the corresponding value on the curve defined by the easing function
  5985. */
  5986. ease(gradient: number): number;
  5987. }
  5988. /**
  5989. * Easing function with a circle shape (see link below).
  5990. * @see https://easings.net/#easeInCirc
  5991. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5992. */
  5993. export class CircleEase extends EasingFunction implements IEasingFunction {
  5994. /** @hidden */
  5995. easeInCore(gradient: number): number;
  5996. }
  5997. /**
  5998. * Easing function with a ease back shape (see link below).
  5999. * @see https://easings.net/#easeInBack
  6000. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6001. */
  6002. export class BackEase extends EasingFunction implements IEasingFunction {
  6003. /** Defines the amplitude of the function */
  6004. amplitude: number;
  6005. /**
  6006. * Instantiates a back ease easing
  6007. * @see https://easings.net/#easeInBack
  6008. * @param amplitude Defines the amplitude of the function
  6009. */
  6010. constructor(
  6011. /** Defines the amplitude of the function */
  6012. amplitude?: number);
  6013. /** @hidden */
  6014. easeInCore(gradient: number): number;
  6015. }
  6016. /**
  6017. * Easing function with a bouncing shape (see link below).
  6018. * @see https://easings.net/#easeInBounce
  6019. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6020. */
  6021. export class BounceEase extends EasingFunction implements IEasingFunction {
  6022. /** Defines the number of bounces */
  6023. bounces: number;
  6024. /** Defines the amplitude of the bounce */
  6025. bounciness: number;
  6026. /**
  6027. * Instantiates a bounce easing
  6028. * @see https://easings.net/#easeInBounce
  6029. * @param bounces Defines the number of bounces
  6030. * @param bounciness Defines the amplitude of the bounce
  6031. */
  6032. constructor(
  6033. /** Defines the number of bounces */
  6034. bounces?: number,
  6035. /** Defines the amplitude of the bounce */
  6036. bounciness?: number);
  6037. /** @hidden */
  6038. easeInCore(gradient: number): number;
  6039. }
  6040. /**
  6041. * Easing function with a power of 3 shape (see link below).
  6042. * @see https://easings.net/#easeInCubic
  6043. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6044. */
  6045. export class CubicEase extends EasingFunction implements IEasingFunction {
  6046. /** @hidden */
  6047. easeInCore(gradient: number): number;
  6048. }
  6049. /**
  6050. * Easing function with an elastic shape (see link below).
  6051. * @see https://easings.net/#easeInElastic
  6052. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6053. */
  6054. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6055. /** Defines the number of oscillations*/
  6056. oscillations: number;
  6057. /** Defines the amplitude of the oscillations*/
  6058. springiness: number;
  6059. /**
  6060. * Instantiates an elastic easing function
  6061. * @see https://easings.net/#easeInElastic
  6062. * @param oscillations Defines the number of oscillations
  6063. * @param springiness Defines the amplitude of the oscillations
  6064. */
  6065. constructor(
  6066. /** Defines the number of oscillations*/
  6067. oscillations?: number,
  6068. /** Defines the amplitude of the oscillations*/
  6069. springiness?: number);
  6070. /** @hidden */
  6071. easeInCore(gradient: number): number;
  6072. }
  6073. /**
  6074. * Easing function with an exponential shape (see link below).
  6075. * @see https://easings.net/#easeInExpo
  6076. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6077. */
  6078. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6079. /** Defines the exponent of the function */
  6080. exponent: number;
  6081. /**
  6082. * Instantiates an exponential easing function
  6083. * @see https://easings.net/#easeInExpo
  6084. * @param exponent Defines the exponent of the function
  6085. */
  6086. constructor(
  6087. /** Defines the exponent of the function */
  6088. exponent?: number);
  6089. /** @hidden */
  6090. easeInCore(gradient: number): number;
  6091. }
  6092. /**
  6093. * Easing function with a power shape (see link below).
  6094. * @see https://easings.net/#easeInQuad
  6095. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6096. */
  6097. export class PowerEase extends EasingFunction implements IEasingFunction {
  6098. /** Defines the power of the function */
  6099. power: number;
  6100. /**
  6101. * Instantiates an power base easing function
  6102. * @see https://easings.net/#easeInQuad
  6103. * @param power Defines the power of the function
  6104. */
  6105. constructor(
  6106. /** Defines the power of the function */
  6107. power?: number);
  6108. /** @hidden */
  6109. easeInCore(gradient: number): number;
  6110. }
  6111. /**
  6112. * Easing function with a power of 2 shape (see link below).
  6113. * @see https://easings.net/#easeInQuad
  6114. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6115. */
  6116. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6117. /** @hidden */
  6118. easeInCore(gradient: number): number;
  6119. }
  6120. /**
  6121. * Easing function with a power of 4 shape (see link below).
  6122. * @see https://easings.net/#easeInQuart
  6123. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6124. */
  6125. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6126. /** @hidden */
  6127. easeInCore(gradient: number): number;
  6128. }
  6129. /**
  6130. * Easing function with a power of 5 shape (see link below).
  6131. * @see https://easings.net/#easeInQuint
  6132. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6133. */
  6134. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6135. /** @hidden */
  6136. easeInCore(gradient: number): number;
  6137. }
  6138. /**
  6139. * Easing function with a sin shape (see link below).
  6140. * @see https://easings.net/#easeInSine
  6141. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6142. */
  6143. export class SineEase extends EasingFunction implements IEasingFunction {
  6144. /** @hidden */
  6145. easeInCore(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a bezier shape (see link below).
  6149. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6150. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6153. /** Defines the x component of the start tangent in the bezier curve */
  6154. x1: number;
  6155. /** Defines the y component of the start tangent in the bezier curve */
  6156. y1: number;
  6157. /** Defines the x component of the end tangent in the bezier curve */
  6158. x2: number;
  6159. /** Defines the y component of the end tangent in the bezier curve */
  6160. y2: number;
  6161. /**
  6162. * Instantiates a bezier function
  6163. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6164. * @param x1 Defines the x component of the start tangent in the bezier curve
  6165. * @param y1 Defines the y component of the start tangent in the bezier curve
  6166. * @param x2 Defines the x component of the end tangent in the bezier curve
  6167. * @param y2 Defines the y component of the end tangent in the bezier curve
  6168. */
  6169. constructor(
  6170. /** Defines the x component of the start tangent in the bezier curve */
  6171. x1?: number,
  6172. /** Defines the y component of the start tangent in the bezier curve */
  6173. y1?: number,
  6174. /** Defines the x component of the end tangent in the bezier curve */
  6175. x2?: number,
  6176. /** Defines the y component of the end tangent in the bezier curve */
  6177. y2?: number);
  6178. /** @hidden */
  6179. easeInCore(gradient: number): number;
  6180. }
  6181. }
  6182. declare module BABYLON {
  6183. /**
  6184. * Class used to hold a RGB color
  6185. */
  6186. export class Color3 {
  6187. /**
  6188. * Defines the red component (between 0 and 1, default is 0)
  6189. */
  6190. r: number;
  6191. /**
  6192. * Defines the green component (between 0 and 1, default is 0)
  6193. */
  6194. g: number;
  6195. /**
  6196. * Defines the blue component (between 0 and 1, default is 0)
  6197. */
  6198. b: number;
  6199. /**
  6200. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6201. * @param r defines the red component (between 0 and 1, default is 0)
  6202. * @param g defines the green component (between 0 and 1, default is 0)
  6203. * @param b defines the blue component (between 0 and 1, default is 0)
  6204. */
  6205. constructor(
  6206. /**
  6207. * Defines the red component (between 0 and 1, default is 0)
  6208. */
  6209. r?: number,
  6210. /**
  6211. * Defines the green component (between 0 and 1, default is 0)
  6212. */
  6213. g?: number,
  6214. /**
  6215. * Defines the blue component (between 0 and 1, default is 0)
  6216. */
  6217. b?: number);
  6218. /**
  6219. * Creates a string with the Color3 current values
  6220. * @returns the string representation of the Color3 object
  6221. */
  6222. toString(): string;
  6223. /**
  6224. * Returns the string "Color3"
  6225. * @returns "Color3"
  6226. */
  6227. getClassName(): string;
  6228. /**
  6229. * Compute the Color3 hash code
  6230. * @returns an unique number that can be used to hash Color3 objects
  6231. */
  6232. getHashCode(): number;
  6233. /**
  6234. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6235. * @param array defines the array where to store the r,g,b components
  6236. * @param index defines an optional index in the target array to define where to start storing values
  6237. * @returns the current Color3 object
  6238. */
  6239. toArray(array: FloatArray, index?: number): Color3;
  6240. /**
  6241. * Update the current color with values stored in an array from the starting index of the given array
  6242. * @param array defines the source array
  6243. * @param offset defines an offset in the source array
  6244. * @returns the current Color3 object
  6245. */
  6246. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6247. /**
  6248. * Returns a new Color4 object from the current Color3 and the given alpha
  6249. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6250. * @returns a new Color4 object
  6251. */
  6252. toColor4(alpha?: number): Color4;
  6253. /**
  6254. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6255. * @returns the new array
  6256. */
  6257. asArray(): number[];
  6258. /**
  6259. * Returns the luminance value
  6260. * @returns a float value
  6261. */
  6262. toLuminance(): number;
  6263. /**
  6264. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6265. * @param otherColor defines the second operand
  6266. * @returns the new Color3 object
  6267. */
  6268. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6269. /**
  6270. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6271. * @param otherColor defines the second operand
  6272. * @param result defines the Color3 object where to store the result
  6273. * @returns the current Color3
  6274. */
  6275. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6276. /**
  6277. * Determines equality between Color3 objects
  6278. * @param otherColor defines the second operand
  6279. * @returns true if the rgb values are equal to the given ones
  6280. */
  6281. equals(otherColor: DeepImmutable<Color3>): boolean;
  6282. /**
  6283. * Determines equality between the current Color3 object and a set of r,b,g values
  6284. * @param r defines the red component to check
  6285. * @param g defines the green component to check
  6286. * @param b defines the blue component to check
  6287. * @returns true if the rgb values are equal to the given ones
  6288. */
  6289. equalsFloats(r: number, g: number, b: number): boolean;
  6290. /**
  6291. * Multiplies in place each rgb value by scale
  6292. * @param scale defines the scaling factor
  6293. * @returns the updated Color3
  6294. */
  6295. scale(scale: number): Color3;
  6296. /**
  6297. * Multiplies the rgb values by scale and stores the result into "result"
  6298. * @param scale defines the scaling factor
  6299. * @param result defines the Color3 object where to store the result
  6300. * @returns the unmodified current Color3
  6301. */
  6302. scaleToRef(scale: number, result: Color3): Color3;
  6303. /**
  6304. * Scale the current Color3 values by a factor and add the result to a given Color3
  6305. * @param scale defines the scale factor
  6306. * @param result defines color to store the result into
  6307. * @returns the unmodified current Color3
  6308. */
  6309. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6310. /**
  6311. * Clamps the rgb values by the min and max values and stores the result into "result"
  6312. * @param min defines minimum clamping value (default is 0)
  6313. * @param max defines maximum clamping value (default is 1)
  6314. * @param result defines color to store the result into
  6315. * @returns the original Color3
  6316. */
  6317. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6318. /**
  6319. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6320. * @param otherColor defines the second operand
  6321. * @returns the new Color3
  6322. */
  6323. add(otherColor: DeepImmutable<Color3>): Color3;
  6324. /**
  6325. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6326. * @param otherColor defines the second operand
  6327. * @param result defines Color3 object to store the result into
  6328. * @returns the unmodified current Color3
  6329. */
  6330. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6331. /**
  6332. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6333. * @param otherColor defines the second operand
  6334. * @returns the new Color3
  6335. */
  6336. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6337. /**
  6338. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6339. * @param otherColor defines the second operand
  6340. * @param result defines Color3 object to store the result into
  6341. * @returns the unmodified current Color3
  6342. */
  6343. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6344. /**
  6345. * Copy the current object
  6346. * @returns a new Color3 copied the current one
  6347. */
  6348. clone(): Color3;
  6349. /**
  6350. * Copies the rgb values from the source in the current Color3
  6351. * @param source defines the source Color3 object
  6352. * @returns the updated Color3 object
  6353. */
  6354. copyFrom(source: DeepImmutable<Color3>): Color3;
  6355. /**
  6356. * Updates the Color3 rgb values from the given floats
  6357. * @param r defines the red component to read from
  6358. * @param g defines the green component to read from
  6359. * @param b defines the blue component to read from
  6360. * @returns the current Color3 object
  6361. */
  6362. copyFromFloats(r: number, g: number, b: number): Color3;
  6363. /**
  6364. * Updates the Color3 rgb values from the given floats
  6365. * @param r defines the red component to read from
  6366. * @param g defines the green component to read from
  6367. * @param b defines the blue component to read from
  6368. * @returns the current Color3 object
  6369. */
  6370. set(r: number, g: number, b: number): Color3;
  6371. /**
  6372. * Compute the Color3 hexadecimal code as a string
  6373. * @returns a string containing the hexadecimal representation of the Color3 object
  6374. */
  6375. toHexString(): string;
  6376. /**
  6377. * Computes a new Color3 converted from the current one to linear space
  6378. * @returns a new Color3 object
  6379. */
  6380. toLinearSpace(): Color3;
  6381. /**
  6382. * Converts current color in rgb space to HSV values
  6383. * @returns a new color3 representing the HSV values
  6384. */
  6385. toHSV(): Color3;
  6386. /**
  6387. * Converts current color in rgb space to HSV values
  6388. * @param result defines the Color3 where to store the HSV values
  6389. */
  6390. toHSVToRef(result: Color3): void;
  6391. /**
  6392. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6393. * @param convertedColor defines the Color3 object where to store the linear space version
  6394. * @returns the unmodified Color3
  6395. */
  6396. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6397. /**
  6398. * Computes a new Color3 converted from the current one to gamma space
  6399. * @returns a new Color3 object
  6400. */
  6401. toGammaSpace(): Color3;
  6402. /**
  6403. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6404. * @param convertedColor defines the Color3 object where to store the gamma space version
  6405. * @returns the unmodified Color3
  6406. */
  6407. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6408. private static _BlackReadOnly;
  6409. /**
  6410. * Convert Hue, saturation and value to a Color3 (RGB)
  6411. * @param hue defines the hue
  6412. * @param saturation defines the saturation
  6413. * @param value defines the value
  6414. * @param result defines the Color3 where to store the RGB values
  6415. */
  6416. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6417. /**
  6418. * Creates a new Color3 from the string containing valid hexadecimal values
  6419. * @param hex defines a string containing valid hexadecimal values
  6420. * @returns a new Color3 object
  6421. */
  6422. static FromHexString(hex: string): Color3;
  6423. /**
  6424. * Creates a new Color3 from the starting index of the given array
  6425. * @param array defines the source array
  6426. * @param offset defines an offset in the source array
  6427. * @returns a new Color3 object
  6428. */
  6429. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6430. /**
  6431. * Creates a new Color3 from the starting index element of the given array
  6432. * @param array defines the source array to read from
  6433. * @param offset defines the offset in the source array
  6434. * @param result defines the target Color3 object
  6435. */
  6436. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6437. /**
  6438. * Creates a new Color3 from integer values (< 256)
  6439. * @param r defines the red component to read from (value between 0 and 255)
  6440. * @param g defines the green component to read from (value between 0 and 255)
  6441. * @param b defines the blue component to read from (value between 0 and 255)
  6442. * @returns a new Color3 object
  6443. */
  6444. static FromInts(r: number, g: number, b: number): Color3;
  6445. /**
  6446. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6447. * @param start defines the start Color3 value
  6448. * @param end defines the end Color3 value
  6449. * @param amount defines the gradient value between start and end
  6450. * @returns a new Color3 object
  6451. */
  6452. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6453. /**
  6454. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6455. * @param left defines the start value
  6456. * @param right defines the end value
  6457. * @param amount defines the gradient factor
  6458. * @param result defines the Color3 object where to store the result
  6459. */
  6460. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6461. /**
  6462. * Returns a Color3 value containing a red color
  6463. * @returns a new Color3 object
  6464. */
  6465. static Red(): Color3;
  6466. /**
  6467. * Returns a Color3 value containing a green color
  6468. * @returns a new Color3 object
  6469. */
  6470. static Green(): Color3;
  6471. /**
  6472. * Returns a Color3 value containing a blue color
  6473. * @returns a new Color3 object
  6474. */
  6475. static Blue(): Color3;
  6476. /**
  6477. * Returns a Color3 value containing a black color
  6478. * @returns a new Color3 object
  6479. */
  6480. static Black(): Color3;
  6481. /**
  6482. * Gets a Color3 value containing a black color that must not be updated
  6483. */
  6484. static get BlackReadOnly(): DeepImmutable<Color3>;
  6485. /**
  6486. * Returns a Color3 value containing a white color
  6487. * @returns a new Color3 object
  6488. */
  6489. static White(): Color3;
  6490. /**
  6491. * Returns a Color3 value containing a purple color
  6492. * @returns a new Color3 object
  6493. */
  6494. static Purple(): Color3;
  6495. /**
  6496. * Returns a Color3 value containing a magenta color
  6497. * @returns a new Color3 object
  6498. */
  6499. static Magenta(): Color3;
  6500. /**
  6501. * Returns a Color3 value containing a yellow color
  6502. * @returns a new Color3 object
  6503. */
  6504. static Yellow(): Color3;
  6505. /**
  6506. * Returns a Color3 value containing a gray color
  6507. * @returns a new Color3 object
  6508. */
  6509. static Gray(): Color3;
  6510. /**
  6511. * Returns a Color3 value containing a teal color
  6512. * @returns a new Color3 object
  6513. */
  6514. static Teal(): Color3;
  6515. /**
  6516. * Returns a Color3 value containing a random color
  6517. * @returns a new Color3 object
  6518. */
  6519. static Random(): Color3;
  6520. }
  6521. /**
  6522. * Class used to hold a RBGA color
  6523. */
  6524. export class Color4 {
  6525. /**
  6526. * Defines the red component (between 0 and 1, default is 0)
  6527. */
  6528. r: number;
  6529. /**
  6530. * Defines the green component (between 0 and 1, default is 0)
  6531. */
  6532. g: number;
  6533. /**
  6534. * Defines the blue component (between 0 and 1, default is 0)
  6535. */
  6536. b: number;
  6537. /**
  6538. * Defines the alpha component (between 0 and 1, default is 1)
  6539. */
  6540. a: number;
  6541. /**
  6542. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6543. * @param r defines the red component (between 0 and 1, default is 0)
  6544. * @param g defines the green component (between 0 and 1, default is 0)
  6545. * @param b defines the blue component (between 0 and 1, default is 0)
  6546. * @param a defines the alpha component (between 0 and 1, default is 1)
  6547. */
  6548. constructor(
  6549. /**
  6550. * Defines the red component (between 0 and 1, default is 0)
  6551. */
  6552. r?: number,
  6553. /**
  6554. * Defines the green component (between 0 and 1, default is 0)
  6555. */
  6556. g?: number,
  6557. /**
  6558. * Defines the blue component (between 0 and 1, default is 0)
  6559. */
  6560. b?: number,
  6561. /**
  6562. * Defines the alpha component (between 0 and 1, default is 1)
  6563. */
  6564. a?: number);
  6565. /**
  6566. * Adds in place the given Color4 values to the current Color4 object
  6567. * @param right defines the second operand
  6568. * @returns the current updated Color4 object
  6569. */
  6570. addInPlace(right: DeepImmutable<Color4>): Color4;
  6571. /**
  6572. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6573. * @returns the new array
  6574. */
  6575. asArray(): number[];
  6576. /**
  6577. * Stores from the starting index in the given array the Color4 successive values
  6578. * @param array defines the array where to store the r,g,b components
  6579. * @param index defines an optional index in the target array to define where to start storing values
  6580. * @returns the current Color4 object
  6581. */
  6582. toArray(array: number[], index?: number): Color4;
  6583. /**
  6584. * Update the current color with values stored in an array from the starting index of the given array
  6585. * @param array defines the source array
  6586. * @param offset defines an offset in the source array
  6587. * @returns the current Color4 object
  6588. */
  6589. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6590. /**
  6591. * Determines equality between Color4 objects
  6592. * @param otherColor defines the second operand
  6593. * @returns true if the rgba values are equal to the given ones
  6594. */
  6595. equals(otherColor: DeepImmutable<Color4>): boolean;
  6596. /**
  6597. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6598. * @param right defines the second operand
  6599. * @returns a new Color4 object
  6600. */
  6601. add(right: DeepImmutable<Color4>): Color4;
  6602. /**
  6603. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6604. * @param right defines the second operand
  6605. * @returns a new Color4 object
  6606. */
  6607. subtract(right: DeepImmutable<Color4>): Color4;
  6608. /**
  6609. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6610. * @param right defines the second operand
  6611. * @param result defines the Color4 object where to store the result
  6612. * @returns the current Color4 object
  6613. */
  6614. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6615. /**
  6616. * Creates a new Color4 with the current Color4 values multiplied by scale
  6617. * @param scale defines the scaling factor to apply
  6618. * @returns a new Color4 object
  6619. */
  6620. scale(scale: number): Color4;
  6621. /**
  6622. * Multiplies the current Color4 values by scale and stores the result in "result"
  6623. * @param scale defines the scaling factor to apply
  6624. * @param result defines the Color4 object where to store the result
  6625. * @returns the current unmodified Color4
  6626. */
  6627. scaleToRef(scale: number, result: Color4): Color4;
  6628. /**
  6629. * Scale the current Color4 values by a factor and add the result to a given Color4
  6630. * @param scale defines the scale factor
  6631. * @param result defines the Color4 object where to store the result
  6632. * @returns the unmodified current Color4
  6633. */
  6634. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6635. /**
  6636. * Clamps the rgb values by the min and max values and stores the result into "result"
  6637. * @param min defines minimum clamping value (default is 0)
  6638. * @param max defines maximum clamping value (default is 1)
  6639. * @param result defines color to store the result into.
  6640. * @returns the cuurent Color4
  6641. */
  6642. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6643. /**
  6644. * Multipy an Color4 value by another and return a new Color4 object
  6645. * @param color defines the Color4 value to multiply by
  6646. * @returns a new Color4 object
  6647. */
  6648. multiply(color: Color4): Color4;
  6649. /**
  6650. * Multipy a Color4 value by another and push the result in a reference value
  6651. * @param color defines the Color4 value to multiply by
  6652. * @param result defines the Color4 to fill the result in
  6653. * @returns the result Color4
  6654. */
  6655. multiplyToRef(color: Color4, result: Color4): Color4;
  6656. /**
  6657. * Creates a string with the Color4 current values
  6658. * @returns the string representation of the Color4 object
  6659. */
  6660. toString(): string;
  6661. /**
  6662. * Returns the string "Color4"
  6663. * @returns "Color4"
  6664. */
  6665. getClassName(): string;
  6666. /**
  6667. * Compute the Color4 hash code
  6668. * @returns an unique number that can be used to hash Color4 objects
  6669. */
  6670. getHashCode(): number;
  6671. /**
  6672. * Creates a new Color4 copied from the current one
  6673. * @returns a new Color4 object
  6674. */
  6675. clone(): Color4;
  6676. /**
  6677. * Copies the given Color4 values into the current one
  6678. * @param source defines the source Color4 object
  6679. * @returns the current updated Color4 object
  6680. */
  6681. copyFrom(source: Color4): Color4;
  6682. /**
  6683. * Copies the given float values into the current one
  6684. * @param r defines the red component to read from
  6685. * @param g defines the green component to read from
  6686. * @param b defines the blue component to read from
  6687. * @param a defines the alpha component to read from
  6688. * @returns the current updated Color4 object
  6689. */
  6690. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6691. /**
  6692. * Copies the given float values into the current one
  6693. * @param r defines the red component to read from
  6694. * @param g defines the green component to read from
  6695. * @param b defines the blue component to read from
  6696. * @param a defines the alpha component to read from
  6697. * @returns the current updated Color4 object
  6698. */
  6699. set(r: number, g: number, b: number, a: number): Color4;
  6700. /**
  6701. * Compute the Color4 hexadecimal code as a string
  6702. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6703. * @returns a string containing the hexadecimal representation of the Color4 object
  6704. */
  6705. toHexString(returnAsColor3?: boolean): string;
  6706. /**
  6707. * Computes a new Color4 converted from the current one to linear space
  6708. * @returns a new Color4 object
  6709. */
  6710. toLinearSpace(): Color4;
  6711. /**
  6712. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6713. * @param convertedColor defines the Color4 object where to store the linear space version
  6714. * @returns the unmodified Color4
  6715. */
  6716. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6717. /**
  6718. * Computes a new Color4 converted from the current one to gamma space
  6719. * @returns a new Color4 object
  6720. */
  6721. toGammaSpace(): Color4;
  6722. /**
  6723. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6724. * @param convertedColor defines the Color4 object where to store the gamma space version
  6725. * @returns the unmodified Color4
  6726. */
  6727. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6728. /**
  6729. * Creates a new Color4 from the string containing valid hexadecimal values
  6730. * @param hex defines a string containing valid hexadecimal values
  6731. * @returns a new Color4 object
  6732. */
  6733. static FromHexString(hex: string): Color4;
  6734. /**
  6735. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6736. * @param left defines the start value
  6737. * @param right defines the end value
  6738. * @param amount defines the gradient factor
  6739. * @returns a new Color4 object
  6740. */
  6741. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6742. /**
  6743. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6744. * @param left defines the start value
  6745. * @param right defines the end value
  6746. * @param amount defines the gradient factor
  6747. * @param result defines the Color4 object where to store data
  6748. */
  6749. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6750. /**
  6751. * Creates a new Color4 from a Color3 and an alpha value
  6752. * @param color3 defines the source Color3 to read from
  6753. * @param alpha defines the alpha component (1.0 by default)
  6754. * @returns a new Color4 object
  6755. */
  6756. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6757. /**
  6758. * Creates a new Color4 from the starting index element of the given array
  6759. * @param array defines the source array to read from
  6760. * @param offset defines the offset in the source array
  6761. * @returns a new Color4 object
  6762. */
  6763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6764. /**
  6765. * Creates a new Color4 from the starting index element of the given array
  6766. * @param array defines the source array to read from
  6767. * @param offset defines the offset in the source array
  6768. * @param result defines the target Color4 object
  6769. */
  6770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6771. /**
  6772. * Creates a new Color3 from integer values (< 256)
  6773. * @param r defines the red component to read from (value between 0 and 255)
  6774. * @param g defines the green component to read from (value between 0 and 255)
  6775. * @param b defines the blue component to read from (value between 0 and 255)
  6776. * @param a defines the alpha component to read from (value between 0 and 255)
  6777. * @returns a new Color3 object
  6778. */
  6779. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6780. /**
  6781. * Check the content of a given array and convert it to an array containing RGBA data
  6782. * If the original array was already containing count * 4 values then it is returned directly
  6783. * @param colors defines the array to check
  6784. * @param count defines the number of RGBA data to expect
  6785. * @returns an array containing count * 4 values (RGBA)
  6786. */
  6787. static CheckColors4(colors: number[], count: number): number[];
  6788. }
  6789. /**
  6790. * @hidden
  6791. */
  6792. export class TmpColors {
  6793. static Color3: Color3[];
  6794. static Color4: Color4[];
  6795. }
  6796. }
  6797. declare module BABYLON {
  6798. /**
  6799. * Defines an interface which represents an animation key frame
  6800. */
  6801. export interface IAnimationKey {
  6802. /**
  6803. * Frame of the key frame
  6804. */
  6805. frame: number;
  6806. /**
  6807. * Value at the specifies key frame
  6808. */
  6809. value: any;
  6810. /**
  6811. * The input tangent for the cubic hermite spline
  6812. */
  6813. inTangent?: any;
  6814. /**
  6815. * The output tangent for the cubic hermite spline
  6816. */
  6817. outTangent?: any;
  6818. /**
  6819. * The animation interpolation type
  6820. */
  6821. interpolation?: AnimationKeyInterpolation;
  6822. }
  6823. /**
  6824. * Enum for the animation key frame interpolation type
  6825. */
  6826. export enum AnimationKeyInterpolation {
  6827. /**
  6828. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6829. */
  6830. STEP = 1
  6831. }
  6832. }
  6833. declare module BABYLON {
  6834. /**
  6835. * Represents the range of an animation
  6836. */
  6837. export class AnimationRange {
  6838. /**The name of the animation range**/
  6839. name: string;
  6840. /**The starting frame of the animation */
  6841. from: number;
  6842. /**The ending frame of the animation*/
  6843. to: number;
  6844. /**
  6845. * Initializes the range of an animation
  6846. * @param name The name of the animation range
  6847. * @param from The starting frame of the animation
  6848. * @param to The ending frame of the animation
  6849. */
  6850. constructor(
  6851. /**The name of the animation range**/
  6852. name: string,
  6853. /**The starting frame of the animation */
  6854. from: number,
  6855. /**The ending frame of the animation*/
  6856. to: number);
  6857. /**
  6858. * Makes a copy of the animation range
  6859. * @returns A copy of the animation range
  6860. */
  6861. clone(): AnimationRange;
  6862. }
  6863. }
  6864. declare module BABYLON {
  6865. /**
  6866. * Composed of a frame, and an action function
  6867. */
  6868. export class AnimationEvent {
  6869. /** The frame for which the event is triggered **/
  6870. frame: number;
  6871. /** The event to perform when triggered **/
  6872. action: (currentFrame: number) => void;
  6873. /** Specifies if the event should be triggered only once**/
  6874. onlyOnce?: boolean | undefined;
  6875. /**
  6876. * Specifies if the animation event is done
  6877. */
  6878. isDone: boolean;
  6879. /**
  6880. * Initializes the animation event
  6881. * @param frame The frame for which the event is triggered
  6882. * @param action The event to perform when triggered
  6883. * @param onlyOnce Specifies if the event should be triggered only once
  6884. */
  6885. constructor(
  6886. /** The frame for which the event is triggered **/
  6887. frame: number,
  6888. /** The event to perform when triggered **/
  6889. action: (currentFrame: number) => void,
  6890. /** Specifies if the event should be triggered only once**/
  6891. onlyOnce?: boolean | undefined);
  6892. /** @hidden */
  6893. _clone(): AnimationEvent;
  6894. }
  6895. }
  6896. declare module BABYLON {
  6897. /**
  6898. * Interface used to define a behavior
  6899. */
  6900. export interface Behavior<T> {
  6901. /** gets or sets behavior's name */
  6902. name: string;
  6903. /**
  6904. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6905. */
  6906. init(): void;
  6907. /**
  6908. * Called when the behavior is attached to a target
  6909. * @param target defines the target where the behavior is attached to
  6910. */
  6911. attach(target: T): void;
  6912. /**
  6913. * Called when the behavior is detached from its target
  6914. */
  6915. detach(): void;
  6916. }
  6917. /**
  6918. * Interface implemented by classes supporting behaviors
  6919. */
  6920. export interface IBehaviorAware<T> {
  6921. /**
  6922. * Attach a behavior
  6923. * @param behavior defines the behavior to attach
  6924. * @returns the current host
  6925. */
  6926. addBehavior(behavior: Behavior<T>): T;
  6927. /**
  6928. * Remove a behavior from the current object
  6929. * @param behavior defines the behavior to detach
  6930. * @returns the current host
  6931. */
  6932. removeBehavior(behavior: Behavior<T>): T;
  6933. /**
  6934. * Gets a behavior using its name to search
  6935. * @param name defines the name to search
  6936. * @returns the behavior or null if not found
  6937. */
  6938. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6939. }
  6940. }
  6941. declare module BABYLON {
  6942. /**
  6943. * Class used to provide helpers for slicing
  6944. */
  6945. export class SliceTools {
  6946. /**
  6947. * Provides a slice function that will work even on IE
  6948. * @param data defines the array to slice
  6949. * @param start defines the start of the data (optional)
  6950. * @param end defines the end of the data (optional)
  6951. * @returns the new sliced array
  6952. */
  6953. static Slice<T>(data: T, start?: number, end?: number): T;
  6954. /**
  6955. * Provides a slice function that will work even on IE
  6956. * The difference between this and Slice is that this will force-convert to array
  6957. * @param data defines the array to slice
  6958. * @param start defines the start of the data (optional)
  6959. * @param end defines the end of the data (optional)
  6960. * @returns the new sliced array
  6961. */
  6962. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  6963. }
  6964. }
  6965. declare module BABYLON {
  6966. /**
  6967. * Class used to store data that will be store in GPU memory
  6968. */
  6969. export class Buffer {
  6970. private _engine;
  6971. private _buffer;
  6972. /** @hidden */
  6973. _data: Nullable<DataArray>;
  6974. private _updatable;
  6975. private _instanced;
  6976. private _divisor;
  6977. private _isAlreadyOwned;
  6978. /**
  6979. * Gets the byte stride.
  6980. */
  6981. readonly byteStride: number;
  6982. /**
  6983. * Constructor
  6984. * @param engine the engine
  6985. * @param data the data to use for this buffer
  6986. * @param updatable whether the data is updatable
  6987. * @param stride the stride (optional)
  6988. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6989. * @param instanced whether the buffer is instanced (optional)
  6990. * @param useBytes set to true if the stride in in bytes (optional)
  6991. * @param divisor sets an optional divisor for instances (1 by default)
  6992. */
  6993. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6994. /**
  6995. * Create a new VertexBuffer based on the current buffer
  6996. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6997. * @param offset defines offset in the buffer (0 by default)
  6998. * @param size defines the size in floats of attributes (position is 3 for instance)
  6999. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  7000. * @param instanced defines if the vertex buffer contains indexed data
  7001. * @param useBytes defines if the offset and stride are in bytes *
  7002. * @param divisor sets an optional divisor for instances (1 by default)
  7003. * @returns the new vertex buffer
  7004. */
  7005. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  7006. /**
  7007. * Gets a boolean indicating if the Buffer is updatable?
  7008. * @returns true if the buffer is updatable
  7009. */
  7010. isUpdatable(): boolean;
  7011. /**
  7012. * Gets current buffer's data
  7013. * @returns a DataArray or null
  7014. */
  7015. getData(): Nullable<DataArray>;
  7016. /**
  7017. * Gets underlying native buffer
  7018. * @returns underlying native buffer
  7019. */
  7020. getBuffer(): Nullable<DataBuffer>;
  7021. /**
  7022. * Gets the stride in float32 units (i.e. byte stride / 4).
  7023. * May not be an integer if the byte stride is not divisible by 4.
  7024. * @returns the stride in float32 units
  7025. * @deprecated Please use byteStride instead.
  7026. */
  7027. getStrideSize(): number;
  7028. /**
  7029. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7030. * @param data defines the data to store
  7031. */
  7032. create(data?: Nullable<DataArray>): void;
  7033. /** @hidden */
  7034. _rebuild(): void;
  7035. /**
  7036. * Update current buffer data
  7037. * @param data defines the data to store
  7038. */
  7039. update(data: DataArray): void;
  7040. /**
  7041. * Updates the data directly.
  7042. * @param data the new data
  7043. * @param offset the new offset
  7044. * @param vertexCount the vertex count (optional)
  7045. * @param useBytes set to true if the offset is in bytes
  7046. */
  7047. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7048. /** @hidden */
  7049. _increaseReferences(): void;
  7050. /**
  7051. * Release all resources
  7052. */
  7053. dispose(): void;
  7054. }
  7055. /**
  7056. * Specialized buffer used to store vertex data
  7057. */
  7058. export class VertexBuffer {
  7059. private static _Counter;
  7060. /** @hidden */
  7061. _buffer: Buffer;
  7062. private _kind;
  7063. private _size;
  7064. private _ownsBuffer;
  7065. private _instanced;
  7066. private _instanceDivisor;
  7067. /**
  7068. * The byte type.
  7069. */
  7070. static readonly BYTE: number;
  7071. /**
  7072. * The unsigned byte type.
  7073. */
  7074. static readonly UNSIGNED_BYTE: number;
  7075. /**
  7076. * The short type.
  7077. */
  7078. static readonly SHORT: number;
  7079. /**
  7080. * The unsigned short type.
  7081. */
  7082. static readonly UNSIGNED_SHORT: number;
  7083. /**
  7084. * The integer type.
  7085. */
  7086. static readonly INT: number;
  7087. /**
  7088. * The unsigned integer type.
  7089. */
  7090. static readonly UNSIGNED_INT: number;
  7091. /**
  7092. * The float type.
  7093. */
  7094. static readonly FLOAT: number;
  7095. /**
  7096. * Gets or sets the instance divisor when in instanced mode
  7097. */
  7098. get instanceDivisor(): number;
  7099. set instanceDivisor(value: number);
  7100. /**
  7101. * Gets the byte stride.
  7102. */
  7103. readonly byteStride: number;
  7104. /**
  7105. * Gets the byte offset.
  7106. */
  7107. readonly byteOffset: number;
  7108. /**
  7109. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7110. */
  7111. readonly normalized: boolean;
  7112. /**
  7113. * Gets the data type of each component in the array.
  7114. */
  7115. readonly type: number;
  7116. /**
  7117. * Gets the unique id of this vertex buffer
  7118. */
  7119. readonly uniqueId: number;
  7120. /**
  7121. * Constructor
  7122. * @param engine the engine
  7123. * @param data the data to use for this vertex buffer
  7124. * @param kind the vertex buffer kind
  7125. * @param updatable whether the data is updatable
  7126. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7127. * @param stride the stride (optional)
  7128. * @param instanced whether the buffer is instanced (optional)
  7129. * @param offset the offset of the data (optional)
  7130. * @param size the number of components (optional)
  7131. * @param type the type of the component (optional)
  7132. * @param normalized whether the data contains normalized data (optional)
  7133. * @param useBytes set to true if stride and offset are in bytes (optional)
  7134. * @param divisor defines the instance divisor to use (1 by default)
  7135. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7136. */
  7137. 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, divisor?: number, takeBufferOwnership?: boolean);
  7138. /** @hidden */
  7139. _rebuild(): void;
  7140. /**
  7141. * Returns the kind of the VertexBuffer (string)
  7142. * @returns a string
  7143. */
  7144. getKind(): string;
  7145. /**
  7146. * Gets a boolean indicating if the VertexBuffer is updatable?
  7147. * @returns true if the buffer is updatable
  7148. */
  7149. isUpdatable(): boolean;
  7150. /**
  7151. * Gets current buffer's data
  7152. * @returns a DataArray or null
  7153. */
  7154. getData(): Nullable<DataArray>;
  7155. /**
  7156. * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.
  7157. * @param totalVertices number of vertices in the buffer to take into account
  7158. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  7159. * @returns a float array containing vertex data
  7160. */
  7161. getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray>;
  7162. /**
  7163. * Gets underlying native buffer
  7164. * @returns underlying native buffer
  7165. */
  7166. getBuffer(): Nullable<DataBuffer>;
  7167. /**
  7168. * Gets the stride in float32 units (i.e. byte stride / 4).
  7169. * May not be an integer if the byte stride is not divisible by 4.
  7170. * @returns the stride in float32 units
  7171. * @deprecated Please use byteStride instead.
  7172. */
  7173. getStrideSize(): number;
  7174. /**
  7175. * Returns the offset as a multiple of the type byte length.
  7176. * @returns the offset in bytes
  7177. * @deprecated Please use byteOffset instead.
  7178. */
  7179. getOffset(): number;
  7180. /**
  7181. * Returns the number of components per vertex attribute (integer)
  7182. * @returns the size in float
  7183. */
  7184. getSize(): number;
  7185. /**
  7186. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7187. * @returns true if this buffer is instanced
  7188. */
  7189. getIsInstanced(): boolean;
  7190. /**
  7191. * Returns the instancing divisor, zero for non-instanced (integer).
  7192. * @returns a number
  7193. */
  7194. getInstanceDivisor(): number;
  7195. /**
  7196. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7197. * @param data defines the data to store
  7198. */
  7199. create(data?: DataArray): void;
  7200. /**
  7201. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7202. * This function will create a new buffer if the current one is not updatable
  7203. * @param data defines the data to store
  7204. */
  7205. update(data: DataArray): void;
  7206. /**
  7207. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7208. * Returns the directly updated WebGLBuffer.
  7209. * @param data the new data
  7210. * @param offset the new offset
  7211. * @param useBytes set to true if the offset is in bytes
  7212. */
  7213. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7214. /**
  7215. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7216. */
  7217. dispose(): void;
  7218. /**
  7219. * Enumerates each value of this vertex buffer as numbers.
  7220. * @param count the number of values to enumerate
  7221. * @param callback the callback function called for each value
  7222. */
  7223. forEach(count: number, callback: (value: number, index: number) => void): void;
  7224. /**
  7225. * Positions
  7226. */
  7227. static readonly PositionKind: string;
  7228. /**
  7229. * Normals
  7230. */
  7231. static readonly NormalKind: string;
  7232. /**
  7233. * Tangents
  7234. */
  7235. static readonly TangentKind: string;
  7236. /**
  7237. * Texture coordinates
  7238. */
  7239. static readonly UVKind: string;
  7240. /**
  7241. * Texture coordinates 2
  7242. */
  7243. static readonly UV2Kind: string;
  7244. /**
  7245. * Texture coordinates 3
  7246. */
  7247. static readonly UV3Kind: string;
  7248. /**
  7249. * Texture coordinates 4
  7250. */
  7251. static readonly UV4Kind: string;
  7252. /**
  7253. * Texture coordinates 5
  7254. */
  7255. static readonly UV5Kind: string;
  7256. /**
  7257. * Texture coordinates 6
  7258. */
  7259. static readonly UV6Kind: string;
  7260. /**
  7261. * Colors
  7262. */
  7263. static readonly ColorKind: string;
  7264. /**
  7265. * Matrix indices (for bones)
  7266. */
  7267. static readonly MatricesIndicesKind: string;
  7268. /**
  7269. * Matrix weights (for bones)
  7270. */
  7271. static readonly MatricesWeightsKind: string;
  7272. /**
  7273. * Additional matrix indices (for bones)
  7274. */
  7275. static readonly MatricesIndicesExtraKind: string;
  7276. /**
  7277. * Additional matrix weights (for bones)
  7278. */
  7279. static readonly MatricesWeightsExtraKind: string;
  7280. /**
  7281. * Deduces the stride given a kind.
  7282. * @param kind The kind string to deduce
  7283. * @returns The deduced stride
  7284. */
  7285. static DeduceStride(kind: string): number;
  7286. /**
  7287. * Gets the byte length of the given type.
  7288. * @param type the type
  7289. * @returns the number of bytes
  7290. */
  7291. static GetTypeByteLength(type: number): number;
  7292. /**
  7293. * Enumerates each value of the given parameters as numbers.
  7294. * @param data the data to enumerate
  7295. * @param byteOffset the byte offset of the data
  7296. * @param byteStride the byte stride of the data
  7297. * @param componentCount the number of components per element
  7298. * @param componentType the type of the component
  7299. * @param count the number of values to enumerate
  7300. * @param normalized whether the data is normalized
  7301. * @param callback the callback function called for each value
  7302. */
  7303. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7304. private static _GetFloatValue;
  7305. }
  7306. }
  7307. declare module BABYLON {
  7308. /**
  7309. * @hidden
  7310. */
  7311. export class IntersectionInfo {
  7312. bu: Nullable<number>;
  7313. bv: Nullable<number>;
  7314. distance: number;
  7315. faceId: number;
  7316. subMeshId: number;
  7317. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * Class used to store bounding sphere information
  7323. */
  7324. export class BoundingSphere {
  7325. /**
  7326. * Gets the center of the bounding sphere in local space
  7327. */
  7328. readonly center: Vector3;
  7329. /**
  7330. * Radius of the bounding sphere in local space
  7331. */
  7332. radius: number;
  7333. /**
  7334. * Gets the center of the bounding sphere in world space
  7335. */
  7336. readonly centerWorld: Vector3;
  7337. /**
  7338. * Radius of the bounding sphere in world space
  7339. */
  7340. radiusWorld: number;
  7341. /**
  7342. * Gets the minimum vector in local space
  7343. */
  7344. readonly minimum: Vector3;
  7345. /**
  7346. * Gets the maximum vector in local space
  7347. */
  7348. readonly maximum: Vector3;
  7349. private _worldMatrix;
  7350. private static readonly TmpVector3;
  7351. /**
  7352. * Creates a new bounding sphere
  7353. * @param min defines the minimum vector (in local space)
  7354. * @param max defines the maximum vector (in local space)
  7355. * @param worldMatrix defines the new world matrix
  7356. */
  7357. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7358. /**
  7359. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7360. * @param min defines the new minimum vector (in local space)
  7361. * @param max defines the new maximum vector (in local space)
  7362. * @param worldMatrix defines the new world matrix
  7363. */
  7364. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7365. /**
  7366. * Scale the current bounding sphere by applying a scale factor
  7367. * @param factor defines the scale factor to apply
  7368. * @returns the current bounding box
  7369. */
  7370. scale(factor: number): BoundingSphere;
  7371. /**
  7372. * Gets the world matrix of the bounding box
  7373. * @returns a matrix
  7374. */
  7375. getWorldMatrix(): DeepImmutable<Matrix>;
  7376. /** @hidden */
  7377. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7378. /**
  7379. * Tests if the bounding sphere is intersecting the frustum planes
  7380. * @param frustumPlanes defines the frustum planes to test
  7381. * @returns true if there is an intersection
  7382. */
  7383. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7384. /**
  7385. * Tests if the bounding sphere center is in between the frustum planes.
  7386. * Used for optimistic fast inclusion.
  7387. * @param frustumPlanes defines the frustum planes to test
  7388. * @returns true if the sphere center is in between the frustum planes
  7389. */
  7390. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7391. /**
  7392. * Tests if a point is inside the bounding sphere
  7393. * @param point defines the point to test
  7394. * @returns true if the point is inside the bounding sphere
  7395. */
  7396. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7397. /**
  7398. * Checks if two sphere intersect
  7399. * @param sphere0 sphere 0
  7400. * @param sphere1 sphere 1
  7401. * @returns true if the spheres intersect
  7402. */
  7403. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7404. }
  7405. }
  7406. declare module BABYLON {
  7407. /**
  7408. * Class used to store bounding box information
  7409. */
  7410. export class BoundingBox implements ICullable {
  7411. /**
  7412. * Gets the 8 vectors representing the bounding box in local space
  7413. */
  7414. readonly vectors: Vector3[];
  7415. /**
  7416. * Gets the center of the bounding box in local space
  7417. */
  7418. readonly center: Vector3;
  7419. /**
  7420. * Gets the center of the bounding box in world space
  7421. */
  7422. readonly centerWorld: Vector3;
  7423. /**
  7424. * Gets the extend size in local space
  7425. */
  7426. readonly extendSize: Vector3;
  7427. /**
  7428. * Gets the extend size in world space
  7429. */
  7430. readonly extendSizeWorld: Vector3;
  7431. /**
  7432. * Gets the OBB (object bounding box) directions
  7433. */
  7434. readonly directions: Vector3[];
  7435. /**
  7436. * Gets the 8 vectors representing the bounding box in world space
  7437. */
  7438. readonly vectorsWorld: Vector3[];
  7439. /**
  7440. * Gets the minimum vector in world space
  7441. */
  7442. readonly minimumWorld: Vector3;
  7443. /**
  7444. * Gets the maximum vector in world space
  7445. */
  7446. readonly maximumWorld: Vector3;
  7447. /**
  7448. * Gets the minimum vector in local space
  7449. */
  7450. readonly minimum: Vector3;
  7451. /**
  7452. * Gets the maximum vector in local space
  7453. */
  7454. readonly maximum: Vector3;
  7455. private _worldMatrix;
  7456. private static readonly TmpVector3;
  7457. /**
  7458. * @hidden
  7459. */
  7460. _tag: number;
  7461. /**
  7462. * Creates a new bounding box
  7463. * @param min defines the minimum vector (in local space)
  7464. * @param max defines the maximum vector (in local space)
  7465. * @param worldMatrix defines the new world matrix
  7466. */
  7467. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7468. /**
  7469. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7470. * @param min defines the new minimum vector (in local space)
  7471. * @param max defines the new maximum vector (in local space)
  7472. * @param worldMatrix defines the new world matrix
  7473. */
  7474. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7475. /**
  7476. * Scale the current bounding box by applying a scale factor
  7477. * @param factor defines the scale factor to apply
  7478. * @returns the current bounding box
  7479. */
  7480. scale(factor: number): BoundingBox;
  7481. /**
  7482. * Gets the world matrix of the bounding box
  7483. * @returns a matrix
  7484. */
  7485. getWorldMatrix(): DeepImmutable<Matrix>;
  7486. /** @hidden */
  7487. _update(world: DeepImmutable<Matrix>): void;
  7488. /**
  7489. * Tests if the bounding box is intersecting the frustum planes
  7490. * @param frustumPlanes defines the frustum planes to test
  7491. * @returns true if there is an intersection
  7492. */
  7493. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7494. /**
  7495. * Tests if the bounding box is entirely inside the frustum planes
  7496. * @param frustumPlanes defines the frustum planes to test
  7497. * @returns true if there is an inclusion
  7498. */
  7499. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7500. /**
  7501. * Tests if a point is inside the bounding box
  7502. * @param point defines the point to test
  7503. * @returns true if the point is inside the bounding box
  7504. */
  7505. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7506. /**
  7507. * Tests if the bounding box intersects with a bounding sphere
  7508. * @param sphere defines the sphere to test
  7509. * @returns true if there is an intersection
  7510. */
  7511. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7512. /**
  7513. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7514. * @param min defines the min vector to use
  7515. * @param max defines the max vector to use
  7516. * @returns true if there is an intersection
  7517. */
  7518. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7519. /**
  7520. * Tests if two bounding boxes are intersections
  7521. * @param box0 defines the first box to test
  7522. * @param box1 defines the second box to test
  7523. * @returns true if there is an intersection
  7524. */
  7525. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7526. /**
  7527. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7528. * @param minPoint defines the minimum vector of the bounding box
  7529. * @param maxPoint defines the maximum vector of the bounding box
  7530. * @param sphereCenter defines the sphere center
  7531. * @param sphereRadius defines the sphere radius
  7532. * @returns true if there is an intersection
  7533. */
  7534. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7535. /**
  7536. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7537. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7538. * @param frustumPlanes defines the frustum planes to test
  7539. * @return true if there is an inclusion
  7540. */
  7541. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7542. /**
  7543. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7544. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7545. * @param frustumPlanes defines the frustum planes to test
  7546. * @return true if there is an intersection
  7547. */
  7548. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7549. }
  7550. }
  7551. declare module BABYLON {
  7552. /** @hidden */
  7553. export class Collider {
  7554. /** Define if a collision was found */
  7555. collisionFound: boolean;
  7556. /**
  7557. * Define last intersection point in local space
  7558. */
  7559. intersectionPoint: Vector3;
  7560. /**
  7561. * Define last collided mesh
  7562. */
  7563. collidedMesh: Nullable<AbstractMesh>;
  7564. private _collisionPoint;
  7565. private _planeIntersectionPoint;
  7566. private _tempVector;
  7567. private _tempVector2;
  7568. private _tempVector3;
  7569. private _tempVector4;
  7570. private _edge;
  7571. private _baseToVertex;
  7572. private _destinationPoint;
  7573. private _slidePlaneNormal;
  7574. private _displacementVector;
  7575. /** @hidden */
  7576. _radius: Vector3;
  7577. /** @hidden */
  7578. _retry: number;
  7579. private _velocity;
  7580. private _basePoint;
  7581. private _epsilon;
  7582. /** @hidden */
  7583. _velocityWorldLength: number;
  7584. /** @hidden */
  7585. _basePointWorld: Vector3;
  7586. private _velocityWorld;
  7587. private _normalizedVelocity;
  7588. /** @hidden */
  7589. _initialVelocity: Vector3;
  7590. /** @hidden */
  7591. _initialPosition: Vector3;
  7592. private _nearestDistance;
  7593. private _collisionMask;
  7594. get collisionMask(): number;
  7595. set collisionMask(mask: number);
  7596. /**
  7597. * Gets the plane normal used to compute the sliding response (in local space)
  7598. */
  7599. get slidePlaneNormal(): Vector3;
  7600. /** @hidden */
  7601. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7602. /** @hidden */
  7603. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7604. /** @hidden */
  7605. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7606. /** @hidden */
  7607. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7608. /** @hidden */
  7609. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7610. /** @hidden */
  7611. _getResponse(pos: Vector3, vel: Vector3): void;
  7612. }
  7613. }
  7614. declare module BABYLON {
  7615. /**
  7616. * Interface for cullable objects
  7617. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7618. */
  7619. export interface ICullable {
  7620. /**
  7621. * Checks if the object or part of the object is in the frustum
  7622. * @param frustumPlanes Camera near/planes
  7623. * @returns true if the object is in frustum otherwise false
  7624. */
  7625. isInFrustum(frustumPlanes: Plane[]): boolean;
  7626. /**
  7627. * Checks if a cullable object (mesh...) is in the camera frustum
  7628. * Unlike isInFrustum this checks the full bounding box
  7629. * @param frustumPlanes Camera near/planes
  7630. * @returns true if the object is in frustum otherwise false
  7631. */
  7632. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7633. }
  7634. /**
  7635. * Info for a bounding data of a mesh
  7636. */
  7637. export class BoundingInfo implements ICullable {
  7638. /**
  7639. * Bounding box for the mesh
  7640. */
  7641. readonly boundingBox: BoundingBox;
  7642. /**
  7643. * Bounding sphere for the mesh
  7644. */
  7645. readonly boundingSphere: BoundingSphere;
  7646. private _isLocked;
  7647. private static readonly TmpVector3;
  7648. /**
  7649. * Constructs bounding info
  7650. * @param minimum min vector of the bounding box/sphere
  7651. * @param maximum max vector of the bounding box/sphere
  7652. * @param worldMatrix defines the new world matrix
  7653. */
  7654. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7655. /**
  7656. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7657. * @param min defines the new minimum vector (in local space)
  7658. * @param max defines the new maximum vector (in local space)
  7659. * @param worldMatrix defines the new world matrix
  7660. */
  7661. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7662. /**
  7663. * min vector of the bounding box/sphere
  7664. */
  7665. get minimum(): Vector3;
  7666. /**
  7667. * max vector of the bounding box/sphere
  7668. */
  7669. get maximum(): Vector3;
  7670. /**
  7671. * If the info is locked and won't be updated to avoid perf overhead
  7672. */
  7673. get isLocked(): boolean;
  7674. set isLocked(value: boolean);
  7675. /**
  7676. * Updates the bounding sphere and box
  7677. * @param world world matrix to be used to update
  7678. */
  7679. update(world: DeepImmutable<Matrix>): void;
  7680. /**
  7681. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7682. * @param center New center of the bounding info
  7683. * @param extend New extend of the bounding info
  7684. * @returns the current bounding info
  7685. */
  7686. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7687. /**
  7688. * Grows the bounding info to include the given point.
  7689. * @param point The point that will be included in the current bounding info
  7690. * @returns the current bounding info
  7691. */
  7692. encapsulate(point: Vector3): BoundingInfo;
  7693. /**
  7694. * Grows the bounding info to encapsulate the given bounding info.
  7695. * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info
  7696. * @returns the current bounding info
  7697. */
  7698. encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo;
  7699. /**
  7700. * Scale the current bounding info by applying a scale factor
  7701. * @param factor defines the scale factor to apply
  7702. * @returns the current bounding info
  7703. */
  7704. scale(factor: number): BoundingInfo;
  7705. /**
  7706. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7707. * @param frustumPlanes defines the frustum to test
  7708. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7709. * @returns true if the bounding info is in the frustum planes
  7710. */
  7711. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7712. /**
  7713. * Gets the world distance between the min and max points of the bounding box
  7714. */
  7715. get diagonalLength(): number;
  7716. /**
  7717. * Checks if a cullable object (mesh...) is in the camera frustum
  7718. * Unlike isInFrustum this checks the full bounding box
  7719. * @param frustumPlanes Camera near/planes
  7720. * @returns true if the object is in frustum otherwise false
  7721. */
  7722. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7723. /** @hidden */
  7724. _checkCollision(collider: Collider): boolean;
  7725. /**
  7726. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7727. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7728. * @param point the point to check intersection with
  7729. * @returns if the point intersects
  7730. */
  7731. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7732. /**
  7733. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7734. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7735. * @param boundingInfo the bounding info to check intersection with
  7736. * @param precise if the intersection should be done using OBB
  7737. * @returns if the bounding info intersects
  7738. */
  7739. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7740. }
  7741. }
  7742. declare module BABYLON {
  7743. /**
  7744. * Extracts minimum and maximum values from a list of indexed positions
  7745. * @param positions defines the positions to use
  7746. * @param indices defines the indices to the positions
  7747. * @param indexStart defines the start index
  7748. * @param indexCount defines the end index
  7749. * @param bias defines bias value to add to the result
  7750. * @return minimum and maximum values
  7751. */
  7752. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7753. minimum: Vector3;
  7754. maximum: Vector3;
  7755. };
  7756. /**
  7757. * Extracts minimum and maximum values from a list of positions
  7758. * @param positions defines the positions to use
  7759. * @param start defines the start index in the positions array
  7760. * @param count defines the number of positions to handle
  7761. * @param bias defines bias value to add to the result
  7762. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7763. * @return minimum and maximum values
  7764. */
  7765. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7766. minimum: Vector3;
  7767. maximum: Vector3;
  7768. };
  7769. }
  7770. declare module BABYLON {
  7771. /**
  7772. * Class used to manipulate GUIDs
  7773. */
  7774. export class GUID {
  7775. /**
  7776. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7777. * Be aware Math.random() could cause collisions, but:
  7778. * "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"
  7779. * @returns a pseudo random id
  7780. */
  7781. static RandomId(): string;
  7782. }
  7783. }
  7784. declare module BABYLON {
  7785. /**
  7786. * Base class of all the textures in babylon.
  7787. * It groups all the common properties the materials, post process, lights... might need
  7788. * in order to make a correct use of the texture.
  7789. */
  7790. export class BaseTexture extends ThinTexture implements IAnimatable {
  7791. /**
  7792. * Default anisotropic filtering level for the application.
  7793. * It is set to 4 as a good tradeoff between perf and quality.
  7794. */
  7795. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7796. /**
  7797. * Gets or sets the unique id of the texture
  7798. */
  7799. uniqueId: number;
  7800. /**
  7801. * Define the name of the texture.
  7802. */
  7803. name: string;
  7804. /**
  7805. * Gets or sets an object used to store user defined information.
  7806. */
  7807. metadata: any;
  7808. /**
  7809. * For internal use only. Please do not use.
  7810. */
  7811. reservedDataStore: any;
  7812. private _hasAlpha;
  7813. /**
  7814. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7815. */
  7816. set hasAlpha(value: boolean);
  7817. get hasAlpha(): boolean;
  7818. /**
  7819. * Defines if the alpha value should be determined via the rgb values.
  7820. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7821. */
  7822. getAlphaFromRGB: boolean;
  7823. /**
  7824. * Intensity or strength of the texture.
  7825. * It is commonly used by materials to fine tune the intensity of the texture
  7826. */
  7827. level: number;
  7828. /**
  7829. * Define the UV channel to use starting from 0 and defaulting to 0.
  7830. * This is part of the texture as textures usually maps to one uv set.
  7831. */
  7832. coordinatesIndex: number;
  7833. protected _coordinatesMode: number;
  7834. /**
  7835. * How a texture is mapped.
  7836. *
  7837. * | Value | Type | Description |
  7838. * | ----- | ----------------------------------- | ----------- |
  7839. * | 0 | EXPLICIT_MODE | |
  7840. * | 1 | SPHERICAL_MODE | |
  7841. * | 2 | PLANAR_MODE | |
  7842. * | 3 | CUBIC_MODE | |
  7843. * | 4 | PROJECTION_MODE | |
  7844. * | 5 | SKYBOX_MODE | |
  7845. * | 6 | INVCUBIC_MODE | |
  7846. * | 7 | EQUIRECTANGULAR_MODE | |
  7847. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7848. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7849. */
  7850. set coordinatesMode(value: number);
  7851. get coordinatesMode(): number;
  7852. /**
  7853. * | Value | Type | Description |
  7854. * | ----- | ------------------ | ----------- |
  7855. * | 0 | CLAMP_ADDRESSMODE | |
  7856. * | 1 | WRAP_ADDRESSMODE | |
  7857. * | 2 | MIRROR_ADDRESSMODE | |
  7858. */
  7859. get wrapU(): number;
  7860. set wrapU(value: number);
  7861. /**
  7862. * | Value | Type | Description |
  7863. * | ----- | ------------------ | ----------- |
  7864. * | 0 | CLAMP_ADDRESSMODE | |
  7865. * | 1 | WRAP_ADDRESSMODE | |
  7866. * | 2 | MIRROR_ADDRESSMODE | |
  7867. */
  7868. get wrapV(): number;
  7869. set wrapV(value: number);
  7870. /**
  7871. * | Value | Type | Description |
  7872. * | ----- | ------------------ | ----------- |
  7873. * | 0 | CLAMP_ADDRESSMODE | |
  7874. * | 1 | WRAP_ADDRESSMODE | |
  7875. * | 2 | MIRROR_ADDRESSMODE | |
  7876. */
  7877. wrapR: number;
  7878. /**
  7879. * With compliant hardware and browser (supporting anisotropic filtering)
  7880. * this defines the level of anisotropic filtering in the texture.
  7881. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7882. */
  7883. anisotropicFilteringLevel: number;
  7884. private _isCube;
  7885. /**
  7886. * Define if the texture is a cube texture or if false a 2d texture.
  7887. */
  7888. get isCube(): boolean;
  7889. set isCube(value: boolean);
  7890. /**
  7891. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7892. */
  7893. get is3D(): boolean;
  7894. set is3D(value: boolean);
  7895. /**
  7896. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7897. */
  7898. get is2DArray(): boolean;
  7899. set is2DArray(value: boolean);
  7900. private _gammaSpace;
  7901. /**
  7902. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7903. * HDR texture are usually stored in linear space.
  7904. * This only impacts the PBR and Background materials
  7905. */
  7906. get gammaSpace(): boolean;
  7907. set gammaSpace(gamma: boolean);
  7908. /**
  7909. * Gets or sets whether or not the texture contains RGBD data.
  7910. */
  7911. get isRGBD(): boolean;
  7912. set isRGBD(value: boolean);
  7913. /**
  7914. * Is Z inverted in the texture (useful in a cube texture).
  7915. */
  7916. invertZ: boolean;
  7917. /**
  7918. * Are mip maps generated for this texture or not.
  7919. */
  7920. get noMipmap(): boolean;
  7921. /**
  7922. * @hidden
  7923. */
  7924. lodLevelInAlpha: boolean;
  7925. /**
  7926. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7927. */
  7928. get lodGenerationOffset(): number;
  7929. set lodGenerationOffset(value: number);
  7930. /**
  7931. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7932. */
  7933. get lodGenerationScale(): number;
  7934. set lodGenerationScale(value: number);
  7935. /**
  7936. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7937. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7938. * average roughness values.
  7939. */
  7940. get linearSpecularLOD(): boolean;
  7941. set linearSpecularLOD(value: boolean);
  7942. /**
  7943. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7944. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7945. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7946. */
  7947. get irradianceTexture(): Nullable<BaseTexture>;
  7948. set irradianceTexture(value: Nullable<BaseTexture>);
  7949. /**
  7950. * Define if the texture is a render target.
  7951. */
  7952. isRenderTarget: boolean;
  7953. /**
  7954. * Define the unique id of the texture in the scene.
  7955. */
  7956. get uid(): string;
  7957. /** @hidden */
  7958. _prefiltered: boolean;
  7959. /**
  7960. * Return a string representation of the texture.
  7961. * @returns the texture as a string
  7962. */
  7963. toString(): string;
  7964. /**
  7965. * Get the class name of the texture.
  7966. * @returns "BaseTexture"
  7967. */
  7968. getClassName(): string;
  7969. /**
  7970. * Define the list of animation attached to the texture.
  7971. */
  7972. animations: Animation[];
  7973. /**
  7974. * An event triggered when the texture is disposed.
  7975. */
  7976. onDisposeObservable: Observable<BaseTexture>;
  7977. private _onDisposeObserver;
  7978. /**
  7979. * Callback triggered when the texture has been disposed.
  7980. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7981. */
  7982. set onDispose(callback: () => void);
  7983. protected _scene: Nullable<Scene>;
  7984. /** @hidden */
  7985. _texture: Nullable<InternalTexture>;
  7986. private _uid;
  7987. /**
  7988. * Define if the texture is preventing a material to render or not.
  7989. * If not and the texture is not ready, the engine will use a default black texture instead.
  7990. */
  7991. get isBlocking(): boolean;
  7992. /**
  7993. * Instantiates a new BaseTexture.
  7994. * Base class of all the textures in babylon.
  7995. * It groups all the common properties the materials, post process, lights... might need
  7996. * in order to make a correct use of the texture.
  7997. * @param sceneOrEngine Define the scene or engine the texture belongs to
  7998. */
  7999. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  8000. /**
  8001. * Get the scene the texture belongs to.
  8002. * @returns the scene or null if undefined
  8003. */
  8004. getScene(): Nullable<Scene>;
  8005. /** @hidden */
  8006. protected _getEngine(): Nullable<ThinEngine>;
  8007. /**
  8008. * Checks if the texture has the same transform matrix than another texture
  8009. * @param texture texture to check against
  8010. * @returns true if the transforms are the same, else false
  8011. */
  8012. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  8013. /**
  8014. * Get the texture transform matrix used to offset tile the texture for instance.
  8015. * @returns the transformation matrix
  8016. */
  8017. getTextureMatrix(): Matrix;
  8018. /**
  8019. * Get the texture reflection matrix used to rotate/transform the reflection.
  8020. * @returns the reflection matrix
  8021. */
  8022. getReflectionTextureMatrix(): Matrix;
  8023. /**
  8024. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  8025. * @returns true if ready or not blocking
  8026. */
  8027. isReadyOrNotBlocking(): boolean;
  8028. /**
  8029. * Scales the texture if is `canRescale()`
  8030. * @param ratio the resize factor we want to use to rescale
  8031. */
  8032. scale(ratio: number): void;
  8033. /**
  8034. * Get if the texture can rescale.
  8035. */
  8036. get canRescale(): boolean;
  8037. /** @hidden */
  8038. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  8039. /** @hidden */
  8040. _rebuild(): void;
  8041. /**
  8042. * Clones the texture.
  8043. * @returns the cloned texture
  8044. */
  8045. clone(): Nullable<BaseTexture>;
  8046. /**
  8047. * Get the texture underlying type (INT, FLOAT...)
  8048. */
  8049. get textureType(): number;
  8050. /**
  8051. * Get the texture underlying format (RGB, RGBA...)
  8052. */
  8053. get textureFormat(): number;
  8054. /**
  8055. * Indicates that textures need to be re-calculated for all materials
  8056. */
  8057. protected _markAllSubMeshesAsTexturesDirty(): void;
  8058. /**
  8059. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8060. * This will returns an RGBA array buffer containing either in values (0-255) or
  8061. * float values (0-1) depending of the underlying buffer type.
  8062. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8063. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8064. * @param buffer defines a user defined buffer to fill with data (can be null)
  8065. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8066. * @returns The Array buffer promise containing the pixels data.
  8067. */
  8068. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8069. /** @hidden */
  8070. _readPixelsSync(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<ArrayBufferView>;
  8071. /** @hidden */
  8072. get _lodTextureHigh(): Nullable<BaseTexture>;
  8073. /** @hidden */
  8074. get _lodTextureMid(): Nullable<BaseTexture>;
  8075. /** @hidden */
  8076. get _lodTextureLow(): Nullable<BaseTexture>;
  8077. /**
  8078. * Dispose the texture and release its associated resources.
  8079. */
  8080. dispose(): void;
  8081. /**
  8082. * Serialize the texture into a JSON representation that can be parsed later on.
  8083. * @returns the JSON representation of the texture
  8084. */
  8085. serialize(): any;
  8086. /**
  8087. * Helper function to be called back once a list of texture contains only ready textures.
  8088. * @param textures Define the list of textures to wait for
  8089. * @param callback Define the callback triggered once the entire list will be ready
  8090. */
  8091. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8092. private static _isScene;
  8093. }
  8094. }
  8095. declare module BABYLON {
  8096. /** @hidden */
  8097. export class WebGLDataBuffer extends DataBuffer {
  8098. private _buffer;
  8099. constructor(resource: WebGLBuffer);
  8100. get underlyingResource(): any;
  8101. }
  8102. }
  8103. declare module BABYLON {
  8104. /** @hidden */
  8105. export class WebGLPipelineContext implements IPipelineContext {
  8106. private _valueCache;
  8107. private _uniforms;
  8108. engine: ThinEngine;
  8109. program: Nullable<WebGLProgram>;
  8110. context?: WebGLRenderingContext;
  8111. vertexShader?: WebGLShader;
  8112. fragmentShader?: WebGLShader;
  8113. isParallelCompiled: boolean;
  8114. onCompiled?: () => void;
  8115. transformFeedback?: WebGLTransformFeedback | null;
  8116. vertexCompilationError: Nullable<string>;
  8117. fragmentCompilationError: Nullable<string>;
  8118. programLinkError: Nullable<string>;
  8119. programValidationError: Nullable<string>;
  8120. get isAsync(): boolean;
  8121. get isReady(): boolean;
  8122. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8123. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8124. [key: string]: number;
  8125. }, uniformsNames: string[], uniforms: {
  8126. [key: string]: Nullable<WebGLUniformLocation>;
  8127. }, samplerList: string[], samplers: {
  8128. [key: string]: number;
  8129. }, attributesNames: string[], attributes: number[]): void;
  8130. /**
  8131. * Release all associated resources.
  8132. **/
  8133. dispose(): void;
  8134. /** @hidden */
  8135. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8136. /** @hidden */
  8137. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8138. /** @hidden */
  8139. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8140. /** @hidden */
  8141. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8142. /**
  8143. * Sets an integer value on a uniform variable.
  8144. * @param uniformName Name of the variable.
  8145. * @param value Value to be set.
  8146. */
  8147. setInt(uniformName: string, value: number): void;
  8148. /**
  8149. * Sets a int2 on a uniform variable.
  8150. * @param uniformName Name of the variable.
  8151. * @param x First int in int2.
  8152. * @param y Second int in int2.
  8153. */
  8154. setInt2(uniformName: string, x: number, y: number): void;
  8155. /**
  8156. * Sets a int3 on a uniform variable.
  8157. * @param uniformName Name of the variable.
  8158. * @param x First int in int3.
  8159. * @param y Second int in int3.
  8160. * @param y Third int in int3.
  8161. */
  8162. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8163. /**
  8164. * Sets a int4 on a uniform variable.
  8165. * @param uniformName Name of the variable.
  8166. * @param x First int in int4.
  8167. * @param y Second int in int4.
  8168. * @param y Third int in int4.
  8169. * @param w Fourth int in int4.
  8170. */
  8171. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8172. /**
  8173. * Sets an int array on a uniform variable.
  8174. * @param uniformName Name of the variable.
  8175. * @param array array to be set.
  8176. */
  8177. setIntArray(uniformName: string, array: Int32Array): void;
  8178. /**
  8179. * 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)
  8180. * @param uniformName Name of the variable.
  8181. * @param array array to be set.
  8182. */
  8183. setIntArray2(uniformName: string, array: Int32Array): void;
  8184. /**
  8185. * 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)
  8186. * @param uniformName Name of the variable.
  8187. * @param array array to be set.
  8188. */
  8189. setIntArray3(uniformName: string, array: Int32Array): void;
  8190. /**
  8191. * 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)
  8192. * @param uniformName Name of the variable.
  8193. * @param array array to be set.
  8194. */
  8195. setIntArray4(uniformName: string, array: Int32Array): void;
  8196. /**
  8197. * Sets an array on a uniform variable.
  8198. * @param uniformName Name of the variable.
  8199. * @param array array to be set.
  8200. */
  8201. setArray(uniformName: string, array: number[]): void;
  8202. /**
  8203. * 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)
  8204. * @param uniformName Name of the variable.
  8205. * @param array array to be set.
  8206. */
  8207. setArray2(uniformName: string, array: number[]): void;
  8208. /**
  8209. * 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)
  8210. * @param uniformName Name of the variable.
  8211. * @param array array to be set.
  8212. * @returns this effect.
  8213. */
  8214. setArray3(uniformName: string, array: number[]): void;
  8215. /**
  8216. * 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)
  8217. * @param uniformName Name of the variable.
  8218. * @param array array to be set.
  8219. */
  8220. setArray4(uniformName: string, array: number[]): void;
  8221. /**
  8222. * Sets matrices on a uniform variable.
  8223. * @param uniformName Name of the variable.
  8224. * @param matrices matrices to be set.
  8225. */
  8226. setMatrices(uniformName: string, matrices: Float32Array): void;
  8227. /**
  8228. * Sets matrix on a uniform variable.
  8229. * @param uniformName Name of the variable.
  8230. * @param matrix matrix to be set.
  8231. */
  8232. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8233. /**
  8234. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  8235. * @param uniformName Name of the variable.
  8236. * @param matrix matrix to be set.
  8237. */
  8238. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8239. /**
  8240. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8241. * @param uniformName Name of the variable.
  8242. * @param matrix matrix to be set.
  8243. */
  8244. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8245. /**
  8246. * Sets a float on a uniform variable.
  8247. * @param uniformName Name of the variable.
  8248. * @param value value to be set.
  8249. * @returns this effect.
  8250. */
  8251. setFloat(uniformName: string, value: number): void;
  8252. /**
  8253. * Sets a Vector2 on a uniform variable.
  8254. * @param uniformName Name of the variable.
  8255. * @param vector2 vector2 to be set.
  8256. */
  8257. setVector2(uniformName: string, vector2: IVector2Like): void;
  8258. /**
  8259. * Sets a float2 on a uniform variable.
  8260. * @param uniformName Name of the variable.
  8261. * @param x First float in float2.
  8262. * @param y Second float in float2.
  8263. */
  8264. setFloat2(uniformName: string, x: number, y: number): void;
  8265. /**
  8266. * Sets a Vector3 on a uniform variable.
  8267. * @param uniformName Name of the variable.
  8268. * @param vector3 Value to be set.
  8269. */
  8270. setVector3(uniformName: string, vector3: IVector3Like): void;
  8271. /**
  8272. * Sets a float3 on a uniform variable.
  8273. * @param uniformName Name of the variable.
  8274. * @param x First float in float3.
  8275. * @param y Second float in float3.
  8276. * @param z Third float in float3.
  8277. */
  8278. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8279. /**
  8280. * Sets a Vector4 on a uniform variable.
  8281. * @param uniformName Name of the variable.
  8282. * @param vector4 Value to be set.
  8283. */
  8284. setVector4(uniformName: string, vector4: IVector4Like): void;
  8285. /**
  8286. * Sets a float4 on a uniform variable.
  8287. * @param uniformName Name of the variable.
  8288. * @param x First float in float4.
  8289. * @param y Second float in float4.
  8290. * @param z Third float in float4.
  8291. * @param w Fourth float in float4.
  8292. * @returns this effect.
  8293. */
  8294. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8295. /**
  8296. * Sets a Color3 on a uniform variable.
  8297. * @param uniformName Name of the variable.
  8298. * @param color3 Value to be set.
  8299. */
  8300. setColor3(uniformName: string, color3: IColor3Like): void;
  8301. /**
  8302. * Sets a Color4 on a uniform variable.
  8303. * @param uniformName Name of the variable.
  8304. * @param color3 Value to be set.
  8305. * @param alpha Alpha value to be set.
  8306. */
  8307. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8308. /**
  8309. * Sets a Color4 on a uniform variable
  8310. * @param uniformName defines the name of the variable
  8311. * @param color4 defines the value to be set
  8312. */
  8313. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8314. _getVertexShaderCode(): string | null;
  8315. _getFragmentShaderCode(): string | null;
  8316. }
  8317. }
  8318. declare module BABYLON {
  8319. interface ThinEngine {
  8320. /**
  8321. * Create an uniform buffer
  8322. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8323. * @param elements defines the content of the uniform buffer
  8324. * @returns the webGL uniform buffer
  8325. */
  8326. createUniformBuffer(elements: FloatArray): DataBuffer;
  8327. /**
  8328. * Create a dynamic uniform buffer
  8329. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8330. * @param elements defines the content of the uniform buffer
  8331. * @returns the webGL uniform buffer
  8332. */
  8333. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8334. /**
  8335. * Update an existing uniform buffer
  8336. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8337. * @param uniformBuffer defines the target uniform buffer
  8338. * @param elements defines the content to update
  8339. * @param offset defines the offset in the uniform buffer where update should start
  8340. * @param count defines the size of the data to update
  8341. */
  8342. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8343. /**
  8344. * Bind an uniform buffer to the current webGL context
  8345. * @param buffer defines the buffer to bind
  8346. */
  8347. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8348. /**
  8349. * Bind a buffer to the current webGL context at a given location
  8350. * @param buffer defines the buffer to bind
  8351. * @param location defines the index where to bind the buffer
  8352. * @param name Name of the uniform variable to bind
  8353. */
  8354. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8355. /**
  8356. * Bind a specific block at a given index in a specific shader program
  8357. * @param pipelineContext defines the pipeline context to use
  8358. * @param blockName defines the block name
  8359. * @param index defines the index where to bind the block
  8360. */
  8361. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8362. }
  8363. }
  8364. declare module BABYLON {
  8365. /**
  8366. * Uniform buffer objects.
  8367. *
  8368. * Handles blocks of uniform on the GPU.
  8369. *
  8370. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8371. *
  8372. * For more information, please refer to :
  8373. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8374. */
  8375. export class UniformBuffer {
  8376. /** @hidden */
  8377. static _updatedUbosInFrame: {
  8378. [name: string]: number;
  8379. };
  8380. private _engine;
  8381. private _buffer;
  8382. private _buffers;
  8383. private _bufferIndex;
  8384. private _createBufferOnWrite;
  8385. private _data;
  8386. private _bufferData;
  8387. private _dynamic?;
  8388. private _uniformLocations;
  8389. private _uniformSizes;
  8390. private _uniformArraySizes;
  8391. private _uniformLocationPointer;
  8392. private _needSync;
  8393. private _noUBO;
  8394. private _currentEffect;
  8395. private _currentEffectName;
  8396. private _name;
  8397. private _currentFrameId;
  8398. /** @hidden */
  8399. _alreadyBound: boolean;
  8400. private static _MAX_UNIFORM_SIZE;
  8401. private static _tempBuffer;
  8402. private static _tempBufferInt32View;
  8403. /**
  8404. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8405. * This is dynamic to allow compat with webgl 1 and 2.
  8406. * You will need to pass the name of the uniform as well as the value.
  8407. */
  8408. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8409. /**
  8410. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8411. * This is dynamic to allow compat with webgl 1 and 2.
  8412. * You will need to pass the name of the uniform as well as the value.
  8413. */
  8414. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8415. /**
  8416. * Lambda to Update a single float in a uniform buffer.
  8417. * This is dynamic to allow compat with webgl 1 and 2.
  8418. * You will need to pass the name of the uniform as well as the value.
  8419. */
  8420. updateFloat: (name: string, x: number) => void;
  8421. /**
  8422. * Lambda to Update a vec2 of float in a uniform buffer.
  8423. * This is dynamic to allow compat with webgl 1 and 2.
  8424. * You will need to pass the name of the uniform as well as the value.
  8425. */
  8426. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8427. /**
  8428. * Lambda to Update a vec3 of float in a uniform buffer.
  8429. * This is dynamic to allow compat with webgl 1 and 2.
  8430. * You will need to pass the name of the uniform as well as the value.
  8431. */
  8432. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8433. /**
  8434. * Lambda to Update a vec4 of float in a uniform buffer.
  8435. * This is dynamic to allow compat with webgl 1 and 2.
  8436. * You will need to pass the name of the uniform as well as the value.
  8437. */
  8438. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8439. /**
  8440. * Lambda to Update an array of float in a uniform buffer.
  8441. * This is dynamic to allow compat with webgl 1 and 2.
  8442. * You will need to pass the name of the uniform as well as the value.
  8443. */
  8444. updateFloatArray: (name: string, array: Float32Array) => void;
  8445. /**
  8446. * Lambda to Update an array of number in a uniform buffer.
  8447. * This is dynamic to allow compat with webgl 1 and 2.
  8448. * You will need to pass the name of the uniform as well as the value.
  8449. */
  8450. updateArray: (name: string, array: number[]) => void;
  8451. /**
  8452. * Lambda to Update an array of number in a uniform buffer.
  8453. * This is dynamic to allow compat with webgl 1 and 2.
  8454. * You will need to pass the name of the uniform as well as the value.
  8455. */
  8456. updateIntArray: (name: string, array: Int32Array) => void;
  8457. /**
  8458. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8459. * This is dynamic to allow compat with webgl 1 and 2.
  8460. * You will need to pass the name of the uniform as well as the value.
  8461. */
  8462. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8463. /**
  8464. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8465. * This is dynamic to allow compat with webgl 1 and 2.
  8466. * You will need to pass the name of the uniform as well as the value.
  8467. */
  8468. updateMatrices: (name: string, mat: Float32Array) => void;
  8469. /**
  8470. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8471. * This is dynamic to allow compat with webgl 1 and 2.
  8472. * You will need to pass the name of the uniform as well as the value.
  8473. */
  8474. updateVector3: (name: string, vector: Vector3) => void;
  8475. /**
  8476. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8477. * This is dynamic to allow compat with webgl 1 and 2.
  8478. * You will need to pass the name of the uniform as well as the value.
  8479. */
  8480. updateVector4: (name: string, vector: Vector4) => void;
  8481. /**
  8482. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8483. * This is dynamic to allow compat with webgl 1 and 2.
  8484. * You will need to pass the name of the uniform as well as the value.
  8485. */
  8486. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8487. /**
  8488. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8489. * This is dynamic to allow compat with webgl 1 and 2.
  8490. * You will need to pass the name of the uniform as well as the value.
  8491. */
  8492. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8493. /**
  8494. * Lambda to Update a int a uniform buffer.
  8495. * This is dynamic to allow compat with webgl 1 and 2.
  8496. * You will need to pass the name of the uniform as well as the value.
  8497. */
  8498. updateInt: (name: string, x: number, suffix?: string) => void;
  8499. /**
  8500. * Lambda to Update a vec2 of int in a uniform buffer.
  8501. * This is dynamic to allow compat with webgl 1 and 2.
  8502. * You will need to pass the name of the uniform as well as the value.
  8503. */
  8504. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8505. /**
  8506. * Lambda to Update a vec3 of int in a uniform buffer.
  8507. * This is dynamic to allow compat with webgl 1 and 2.
  8508. * You will need to pass the name of the uniform as well as the value.
  8509. */
  8510. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8511. /**
  8512. * Lambda to Update a vec4 of int in a uniform buffer.
  8513. * This is dynamic to allow compat with webgl 1 and 2.
  8514. * You will need to pass the name of the uniform as well as the value.
  8515. */
  8516. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8517. /**
  8518. * Instantiates a new Uniform buffer objects.
  8519. *
  8520. * Handles blocks of uniform on the GPU.
  8521. *
  8522. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8523. *
  8524. * For more information, please refer to :
  8525. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8526. * @param engine Define the engine the buffer is associated with
  8527. * @param data Define the data contained in the buffer
  8528. * @param dynamic Define if the buffer is updatable
  8529. * @param name to assign to the buffer (debugging purpose)
  8530. */
  8531. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8532. /**
  8533. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8534. * or just falling back on setUniformXXX calls.
  8535. */
  8536. get useUbo(): boolean;
  8537. /**
  8538. * Indicates if the WebGL underlying uniform buffer is in sync
  8539. * with the javascript cache data.
  8540. */
  8541. get isSync(): boolean;
  8542. /**
  8543. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8544. * Also, a dynamic UniformBuffer will disable cache verification and always
  8545. * update the underlying WebGL uniform buffer to the GPU.
  8546. * @returns if Dynamic, otherwise false
  8547. */
  8548. isDynamic(): boolean;
  8549. /**
  8550. * The data cache on JS side.
  8551. * @returns the underlying data as a float array
  8552. */
  8553. getData(): Float32Array;
  8554. /**
  8555. * The underlying WebGL Uniform buffer.
  8556. * @returns the webgl buffer
  8557. */
  8558. getBuffer(): Nullable<DataBuffer>;
  8559. /**
  8560. * std140 layout specifies how to align data within an UBO structure.
  8561. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8562. * for specs.
  8563. */
  8564. private _fillAlignment;
  8565. /**
  8566. * Adds an uniform in the buffer.
  8567. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8568. * for the layout to be correct !
  8569. * @param name Name of the uniform, as used in the uniform block in the shader.
  8570. * @param size Data size, or data directly.
  8571. * @param arraySize The number of elements in the array, 0 if not an array.
  8572. */
  8573. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8574. /**
  8575. * Adds a Matrix 4x4 to the uniform buffer.
  8576. * @param name Name of the uniform, as used in the uniform block in the shader.
  8577. * @param mat A 4x4 matrix.
  8578. */
  8579. addMatrix(name: string, mat: Matrix): void;
  8580. /**
  8581. * Adds a vec2 to the uniform buffer.
  8582. * @param name Name of the uniform, as used in the uniform block in the shader.
  8583. * @param x Define the x component value of the vec2
  8584. * @param y Define the y component value of the vec2
  8585. */
  8586. addFloat2(name: string, x: number, y: number): void;
  8587. /**
  8588. * Adds a vec3 to the uniform buffer.
  8589. * @param name Name of the uniform, as used in the uniform block in the shader.
  8590. * @param x Define the x component value of the vec3
  8591. * @param y Define the y component value of the vec3
  8592. * @param z Define the z component value of the vec3
  8593. */
  8594. addFloat3(name: string, x: number, y: number, z: number): void;
  8595. /**
  8596. * Adds a vec3 to the uniform buffer.
  8597. * @param name Name of the uniform, as used in the uniform block in the shader.
  8598. * @param color Define the vec3 from a Color
  8599. */
  8600. addColor3(name: string, color: Color3): void;
  8601. /**
  8602. * Adds a vec4 to the uniform buffer.
  8603. * @param name Name of the uniform, as used in the uniform block in the shader.
  8604. * @param color Define the rgb components from a Color
  8605. * @param alpha Define the a component of the vec4
  8606. */
  8607. addColor4(name: string, color: Color3, alpha: number): void;
  8608. /**
  8609. * Adds a vec3 to the uniform buffer.
  8610. * @param name Name of the uniform, as used in the uniform block in the shader.
  8611. * @param vector Define the vec3 components from a Vector
  8612. */
  8613. addVector3(name: string, vector: Vector3): void;
  8614. /**
  8615. * Adds a Matrix 3x3 to the uniform buffer.
  8616. * @param name Name of the uniform, as used in the uniform block in the shader.
  8617. */
  8618. addMatrix3x3(name: string): void;
  8619. /**
  8620. * Adds a Matrix 2x2 to the uniform buffer.
  8621. * @param name Name of the uniform, as used in the uniform block in the shader.
  8622. */
  8623. addMatrix2x2(name: string): void;
  8624. /**
  8625. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8626. */
  8627. create(): void;
  8628. /** @hidden */
  8629. _rebuild(): void;
  8630. /** @hidden */
  8631. get _numBuffers(): number;
  8632. /** @hidden */
  8633. get _indexBuffer(): number;
  8634. /** Gets the name of this buffer */
  8635. get name(): string;
  8636. /**
  8637. * Updates the WebGL Uniform Buffer on the GPU.
  8638. * If the `dynamic` flag is set to true, no cache comparison is done.
  8639. * Otherwise, the buffer will be updated only if the cache differs.
  8640. */
  8641. update(): void;
  8642. private _createNewBuffer;
  8643. private _checkNewFrame;
  8644. /**
  8645. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8646. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8647. * @param data Define the flattened data
  8648. * @param size Define the size of the data.
  8649. */
  8650. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8651. /**
  8652. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8653. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8654. * @param data Define the flattened data
  8655. * @param size Define the size of the data.
  8656. */
  8657. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8658. private _valueCache;
  8659. private _cacheMatrix;
  8660. private _updateMatrix3x3ForUniform;
  8661. private _updateMatrix3x3ForEffect;
  8662. private _updateMatrix2x2ForEffect;
  8663. private _updateMatrix2x2ForUniform;
  8664. private _updateFloatForEffect;
  8665. private _updateFloatForUniform;
  8666. private _updateFloat2ForEffect;
  8667. private _updateFloat2ForUniform;
  8668. private _updateFloat3ForEffect;
  8669. private _updateFloat3ForUniform;
  8670. private _updateFloat4ForEffect;
  8671. private _updateFloat4ForUniform;
  8672. private _updateFloatArrayForEffect;
  8673. private _updateFloatArrayForUniform;
  8674. private _updateArrayForEffect;
  8675. private _updateArrayForUniform;
  8676. private _updateIntArrayForEffect;
  8677. private _updateIntArrayForUniform;
  8678. private _updateMatrixForEffect;
  8679. private _updateMatrixForUniform;
  8680. private _updateMatricesForEffect;
  8681. private _updateMatricesForUniform;
  8682. private _updateVector3ForEffect;
  8683. private _updateVector3ForUniform;
  8684. private _updateVector4ForEffect;
  8685. private _updateVector4ForUniform;
  8686. private _updateColor3ForEffect;
  8687. private _updateColor3ForUniform;
  8688. private _updateColor4ForEffect;
  8689. private _updateColor4ForUniform;
  8690. private _updateIntForEffect;
  8691. private _updateIntForUniform;
  8692. private _updateInt2ForEffect;
  8693. private _updateInt2ForUniform;
  8694. private _updateInt3ForEffect;
  8695. private _updateInt3ForUniform;
  8696. private _updateInt4ForEffect;
  8697. private _updateInt4ForUniform;
  8698. /**
  8699. * Sets a sampler uniform on the effect.
  8700. * @param name Define the name of the sampler.
  8701. * @param texture Define the texture to set in the sampler
  8702. */
  8703. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8704. /**
  8705. * Directly updates the value of the uniform in the cache AND on the GPU.
  8706. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8707. * @param data Define the flattened data
  8708. */
  8709. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8710. /**
  8711. * Binds this uniform buffer to an effect.
  8712. * @param effect Define the effect to bind the buffer to
  8713. * @param name Name of the uniform block in the shader.
  8714. */
  8715. bindToEffect(effect: Effect, name: string): void;
  8716. /**
  8717. * Disposes the uniform buffer.
  8718. */
  8719. dispose(): void;
  8720. }
  8721. }
  8722. declare module BABYLON {
  8723. /**
  8724. * Manages the defines for the Material
  8725. */
  8726. export class MaterialDefines {
  8727. /** @hidden */
  8728. protected _keys: string[];
  8729. private _isDirty;
  8730. /** @hidden */
  8731. _renderId: number;
  8732. /** @hidden */
  8733. _areLightsDirty: boolean;
  8734. /** @hidden */
  8735. _areLightsDisposed: boolean;
  8736. /** @hidden */
  8737. _areAttributesDirty: boolean;
  8738. /** @hidden */
  8739. _areTexturesDirty: boolean;
  8740. /** @hidden */
  8741. _areFresnelDirty: boolean;
  8742. /** @hidden */
  8743. _areMiscDirty: boolean;
  8744. /** @hidden */
  8745. _arePrePassDirty: boolean;
  8746. /** @hidden */
  8747. _areImageProcessingDirty: boolean;
  8748. /** @hidden */
  8749. _normals: boolean;
  8750. /** @hidden */
  8751. _uvs: boolean;
  8752. /** @hidden */
  8753. _needNormals: boolean;
  8754. /** @hidden */
  8755. _needUVs: boolean;
  8756. [id: string]: any;
  8757. /**
  8758. * Specifies if the material needs to be re-calculated
  8759. */
  8760. get isDirty(): boolean;
  8761. /**
  8762. * Marks the material to indicate that it has been re-calculated
  8763. */
  8764. markAsProcessed(): void;
  8765. /**
  8766. * Marks the material to indicate that it needs to be re-calculated
  8767. */
  8768. markAsUnprocessed(): void;
  8769. /**
  8770. * Marks the material to indicate all of its defines need to be re-calculated
  8771. */
  8772. markAllAsDirty(): void;
  8773. /**
  8774. * Marks the material to indicate that image processing needs to be re-calculated
  8775. */
  8776. markAsImageProcessingDirty(): void;
  8777. /**
  8778. * Marks the material to indicate the lights need to be re-calculated
  8779. * @param disposed Defines whether the light is dirty due to dispose or not
  8780. */
  8781. markAsLightDirty(disposed?: boolean): void;
  8782. /**
  8783. * Marks the attribute state as changed
  8784. */
  8785. markAsAttributesDirty(): void;
  8786. /**
  8787. * Marks the texture state as changed
  8788. */
  8789. markAsTexturesDirty(): void;
  8790. /**
  8791. * Marks the fresnel state as changed
  8792. */
  8793. markAsFresnelDirty(): void;
  8794. /**
  8795. * Marks the misc state as changed
  8796. */
  8797. markAsMiscDirty(): void;
  8798. /**
  8799. * Marks the prepass state as changed
  8800. */
  8801. markAsPrePassDirty(): void;
  8802. /**
  8803. * Rebuilds the material defines
  8804. */
  8805. rebuild(): void;
  8806. /**
  8807. * Specifies if two material defines are equal
  8808. * @param other - A material define instance to compare to
  8809. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8810. */
  8811. isEqual(other: MaterialDefines): boolean;
  8812. /**
  8813. * Clones this instance's defines to another instance
  8814. * @param other - material defines to clone values to
  8815. */
  8816. cloneTo(other: MaterialDefines): void;
  8817. /**
  8818. * Resets the material define values
  8819. */
  8820. reset(): void;
  8821. /**
  8822. * Converts the material define values to a string
  8823. * @returns - String of material define information
  8824. */
  8825. toString(): string;
  8826. }
  8827. }
  8828. declare module BABYLON {
  8829. /**
  8830. * Enum that determines the text-wrapping mode to use.
  8831. */
  8832. export enum InspectableType {
  8833. /**
  8834. * Checkbox for booleans
  8835. */
  8836. Checkbox = 0,
  8837. /**
  8838. * Sliders for numbers
  8839. */
  8840. Slider = 1,
  8841. /**
  8842. * Vector3
  8843. */
  8844. Vector3 = 2,
  8845. /**
  8846. * Quaternions
  8847. */
  8848. Quaternion = 3,
  8849. /**
  8850. * Color3
  8851. */
  8852. Color3 = 4,
  8853. /**
  8854. * String
  8855. */
  8856. String = 5
  8857. }
  8858. /**
  8859. * Interface used to define custom inspectable properties.
  8860. * This interface is used by the inspector to display custom property grids
  8861. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8862. */
  8863. export interface IInspectable {
  8864. /**
  8865. * Gets the label to display
  8866. */
  8867. label: string;
  8868. /**
  8869. * Gets the name of the property to edit
  8870. */
  8871. propertyName: string;
  8872. /**
  8873. * Gets the type of the editor to use
  8874. */
  8875. type: InspectableType;
  8876. /**
  8877. * Gets the minimum value of the property when using in "slider" mode
  8878. */
  8879. min?: number;
  8880. /**
  8881. * Gets the maximum value of the property when using in "slider" mode
  8882. */
  8883. max?: number;
  8884. /**
  8885. * Gets the setp to use when using in "slider" mode
  8886. */
  8887. step?: number;
  8888. }
  8889. }
  8890. declare module BABYLON {
  8891. /**
  8892. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8893. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8894. * 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.
  8895. */
  8896. export abstract class Light extends Node {
  8897. /**
  8898. * Falloff Default: light is falling off following the material specification:
  8899. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8900. */
  8901. static readonly FALLOFF_DEFAULT: number;
  8902. /**
  8903. * Falloff Physical: light is falling off following the inverse squared distance law.
  8904. */
  8905. static readonly FALLOFF_PHYSICAL: number;
  8906. /**
  8907. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8908. * to enhance interoperability with other engines.
  8909. */
  8910. static readonly FALLOFF_GLTF: number;
  8911. /**
  8912. * Falloff Standard: light is falling off like in the standard material
  8913. * to enhance interoperability with other materials.
  8914. */
  8915. static readonly FALLOFF_STANDARD: number;
  8916. /**
  8917. * If every light affecting the material is in this lightmapMode,
  8918. * material.lightmapTexture adds or multiplies
  8919. * (depends on material.useLightmapAsShadowmap)
  8920. * after every other light calculations.
  8921. */
  8922. static readonly LIGHTMAP_DEFAULT: number;
  8923. /**
  8924. * material.lightmapTexture as only diffuse lighting from this light
  8925. * adds only specular lighting from this light
  8926. * adds dynamic shadows
  8927. */
  8928. static readonly LIGHTMAP_SPECULAR: number;
  8929. /**
  8930. * material.lightmapTexture as only lighting
  8931. * no light calculation from this light
  8932. * only adds dynamic shadows from this light
  8933. */
  8934. static readonly LIGHTMAP_SHADOWSONLY: number;
  8935. /**
  8936. * Each light type uses the default quantity according to its type:
  8937. * point/spot lights use luminous intensity
  8938. * directional lights use illuminance
  8939. */
  8940. static readonly INTENSITYMODE_AUTOMATIC: number;
  8941. /**
  8942. * lumen (lm)
  8943. */
  8944. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8945. /**
  8946. * candela (lm/sr)
  8947. */
  8948. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8949. /**
  8950. * lux (lm/m^2)
  8951. */
  8952. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8953. /**
  8954. * nit (cd/m^2)
  8955. */
  8956. static readonly INTENSITYMODE_LUMINANCE: number;
  8957. /**
  8958. * Light type const id of the point light.
  8959. */
  8960. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8961. /**
  8962. * Light type const id of the directional light.
  8963. */
  8964. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8965. /**
  8966. * Light type const id of the spot light.
  8967. */
  8968. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8969. /**
  8970. * Light type const id of the hemispheric light.
  8971. */
  8972. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8973. /**
  8974. * Diffuse gives the basic color to an object.
  8975. */
  8976. diffuse: Color3;
  8977. /**
  8978. * Specular produces a highlight color on an object.
  8979. * Note: This is note affecting PBR materials.
  8980. */
  8981. specular: Color3;
  8982. /**
  8983. * Defines the falloff type for this light. This lets overriding how punctual light are
  8984. * falling off base on range or angle.
  8985. * This can be set to any values in Light.FALLOFF_x.
  8986. *
  8987. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8988. * other types of materials.
  8989. */
  8990. falloffType: number;
  8991. /**
  8992. * Strength of the light.
  8993. * Note: By default it is define in the framework own unit.
  8994. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8995. */
  8996. intensity: number;
  8997. private _range;
  8998. protected _inverseSquaredRange: number;
  8999. /**
  9000. * Defines how far from the source the light is impacting in scene units.
  9001. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9002. */
  9003. get range(): number;
  9004. /**
  9005. * Defines how far from the source the light is impacting in scene units.
  9006. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9007. */
  9008. set range(value: number);
  9009. /**
  9010. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9011. * of light.
  9012. */
  9013. private _photometricScale;
  9014. private _intensityMode;
  9015. /**
  9016. * Gets the photometric scale used to interpret the intensity.
  9017. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9018. */
  9019. get intensityMode(): number;
  9020. /**
  9021. * Sets the photometric scale used to interpret the intensity.
  9022. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9023. */
  9024. set intensityMode(value: number);
  9025. private _radius;
  9026. /**
  9027. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9028. */
  9029. get radius(): number;
  9030. /**
  9031. * sets the light radius used by PBR Materials to simulate soft area lights.
  9032. */
  9033. set radius(value: number);
  9034. private _renderPriority;
  9035. /**
  9036. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9037. * exceeding the number allowed of the materials.
  9038. */
  9039. renderPriority: number;
  9040. private _shadowEnabled;
  9041. /**
  9042. * Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9043. * the current shadow generator.
  9044. */
  9045. get shadowEnabled(): boolean;
  9046. /**
  9047. * Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9048. * the current shadow generator.
  9049. */
  9050. set shadowEnabled(value: boolean);
  9051. private _includedOnlyMeshes;
  9052. /**
  9053. * Gets the only meshes impacted by this light.
  9054. */
  9055. get includedOnlyMeshes(): AbstractMesh[];
  9056. /**
  9057. * Sets the only meshes impacted by this light.
  9058. */
  9059. set includedOnlyMeshes(value: AbstractMesh[]);
  9060. private _excludedMeshes;
  9061. /**
  9062. * Gets the meshes not impacted by this light.
  9063. */
  9064. get excludedMeshes(): AbstractMesh[];
  9065. /**
  9066. * Sets the meshes not impacted by this light.
  9067. */
  9068. set excludedMeshes(value: AbstractMesh[]);
  9069. private _excludeWithLayerMask;
  9070. /**
  9071. * Gets the layer id use to find what meshes are not impacted by the light.
  9072. * Inactive if 0
  9073. */
  9074. get excludeWithLayerMask(): number;
  9075. /**
  9076. * Sets the layer id use to find what meshes are not impacted by the light.
  9077. * Inactive if 0
  9078. */
  9079. set excludeWithLayerMask(value: number);
  9080. private _includeOnlyWithLayerMask;
  9081. /**
  9082. * Gets the layer id use to find what meshes are impacted by the light.
  9083. * Inactive if 0
  9084. */
  9085. get includeOnlyWithLayerMask(): number;
  9086. /**
  9087. * Sets the layer id use to find what meshes are impacted by the light.
  9088. * Inactive if 0
  9089. */
  9090. set includeOnlyWithLayerMask(value: number);
  9091. private _lightmapMode;
  9092. /**
  9093. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9094. */
  9095. get lightmapMode(): number;
  9096. /**
  9097. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9098. */
  9099. set lightmapMode(value: number);
  9100. /**
  9101. * Shadow generator associated to the light.
  9102. * @hidden Internal use only.
  9103. */
  9104. _shadowGenerator: Nullable<IShadowGenerator>;
  9105. /**
  9106. * @hidden Internal use only.
  9107. */
  9108. _excludedMeshesIds: string[];
  9109. /**
  9110. * @hidden Internal use only.
  9111. */
  9112. _includedOnlyMeshesIds: string[];
  9113. /**
  9114. * The current light uniform buffer.
  9115. * @hidden Internal use only.
  9116. */
  9117. _uniformBuffer: UniformBuffer;
  9118. /** @hidden */
  9119. _renderId: number;
  9120. /**
  9121. * Creates a Light object in the scene.
  9122. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9123. * @param name The friendly name of the light
  9124. * @param scene The scene the light belongs too
  9125. */
  9126. constructor(name: string, scene: Scene);
  9127. protected abstract _buildUniformLayout(): void;
  9128. /**
  9129. * Sets the passed Effect "effect" with the Light information.
  9130. * @param effect The effect to update
  9131. * @param lightIndex The index of the light in the effect to update
  9132. * @returns The light
  9133. */
  9134. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9135. /**
  9136. * Sets the passed Effect "effect" with the Light textures.
  9137. * @param effect The effect to update
  9138. * @param lightIndex The index of the light in the effect to update
  9139. * @returns The light
  9140. */
  9141. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9142. /**
  9143. * Binds the lights information from the scene to the effect for the given mesh.
  9144. * @param lightIndex Light index
  9145. * @param scene The scene where the light belongs to
  9146. * @param effect The effect we are binding the data to
  9147. * @param useSpecular Defines if specular is supported
  9148. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9149. */
  9150. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9151. /**
  9152. * Sets the passed Effect "effect" with the Light information.
  9153. * @param effect The effect to update
  9154. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9155. * @returns The light
  9156. */
  9157. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9158. /**
  9159. * Returns the string "Light".
  9160. * @returns the class name
  9161. */
  9162. getClassName(): string;
  9163. /** @hidden */
  9164. readonly _isLight: boolean;
  9165. /**
  9166. * Converts the light information to a readable string for debug purpose.
  9167. * @param fullDetails Supports for multiple levels of logging within scene loading
  9168. * @returns the human readable light info
  9169. */
  9170. toString(fullDetails?: boolean): string;
  9171. /** @hidden */
  9172. protected _syncParentEnabledState(): void;
  9173. /**
  9174. * Set the enabled state of this node.
  9175. * @param value - the new enabled state
  9176. */
  9177. setEnabled(value: boolean): void;
  9178. /**
  9179. * Returns the Light associated shadow generator if any.
  9180. * @return the associated shadow generator.
  9181. */
  9182. getShadowGenerator(): Nullable<IShadowGenerator>;
  9183. /**
  9184. * Returns a Vector3, the absolute light position in the World.
  9185. * @returns the world space position of the light
  9186. */
  9187. getAbsolutePosition(): Vector3;
  9188. /**
  9189. * Specifies if the light will affect the passed mesh.
  9190. * @param mesh The mesh to test against the light
  9191. * @return true the mesh is affected otherwise, false.
  9192. */
  9193. canAffectMesh(mesh: AbstractMesh): boolean;
  9194. /**
  9195. * Sort function to order lights for rendering.
  9196. * @param a First Light object to compare to second.
  9197. * @param b Second Light object to compare first.
  9198. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9199. */
  9200. static CompareLightsPriority(a: Light, b: Light): number;
  9201. /**
  9202. * Releases resources associated with this node.
  9203. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9204. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9205. */
  9206. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9207. /**
  9208. * Returns the light type ID (integer).
  9209. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9210. */
  9211. getTypeID(): number;
  9212. /**
  9213. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9214. * @returns the scaled intensity in intensity mode unit
  9215. */
  9216. getScaledIntensity(): number;
  9217. /**
  9218. * Returns a new Light object, named "name", from the current one.
  9219. * @param name The name of the cloned light
  9220. * @param newParent The parent of this light, if it has one
  9221. * @returns the new created light
  9222. */
  9223. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9224. /**
  9225. * Serializes the current light into a Serialization object.
  9226. * @returns the serialized object.
  9227. */
  9228. serialize(): any;
  9229. /**
  9230. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9231. * This new light is named "name" and added to the passed scene.
  9232. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9233. * @param name The friendly name of the light
  9234. * @param scene The scene the new light will belong to
  9235. * @returns the constructor function
  9236. */
  9237. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9238. /**
  9239. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9240. * @param parsedLight The JSON representation of the light
  9241. * @param scene The scene to create the parsed light in
  9242. * @returns the created light after parsing
  9243. */
  9244. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9245. private _hookArrayForExcluded;
  9246. private _hookArrayForIncludedOnly;
  9247. private _resyncMeshes;
  9248. /**
  9249. * Forces the meshes to update their light related information in their rendering used effects
  9250. * @hidden Internal Use Only
  9251. */
  9252. _markMeshesAsLightDirty(): void;
  9253. /**
  9254. * Recomputes the cached photometric scale if needed.
  9255. */
  9256. private _computePhotometricScale;
  9257. /**
  9258. * Returns the Photometric Scale according to the light type and intensity mode.
  9259. */
  9260. private _getPhotometricScale;
  9261. /**
  9262. * Reorder the light in the scene according to their defined priority.
  9263. * @hidden Internal Use Only
  9264. */
  9265. _reorderLightsInScene(): void;
  9266. /**
  9267. * Prepares the list of defines specific to the light type.
  9268. * @param defines the list of defines
  9269. * @param lightIndex defines the index of the light for the effect
  9270. */
  9271. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9272. }
  9273. }
  9274. declare module BABYLON {
  9275. /** Defines supported spaces */
  9276. export enum Space {
  9277. /** Local (object) space */
  9278. LOCAL = 0,
  9279. /** World space */
  9280. WORLD = 1,
  9281. /** Bone space */
  9282. BONE = 2
  9283. }
  9284. /** Defines the 3 main axes */
  9285. export class Axis {
  9286. /** X axis */
  9287. static X: Vector3;
  9288. /** Y axis */
  9289. static Y: Vector3;
  9290. /** Z axis */
  9291. static Z: Vector3;
  9292. }
  9293. /**
  9294. * Defines cartesian components.
  9295. */
  9296. export enum Coordinate {
  9297. /** X axis */
  9298. X = 0,
  9299. /** Y axis */
  9300. Y = 1,
  9301. /** Z axis */
  9302. Z = 2
  9303. }
  9304. }
  9305. declare module BABYLON {
  9306. /**
  9307. * Interface describing all the common properties and methods a shadow light needs to implement.
  9308. * This helps both the shadow generator and materials to generate the corresponding shadow maps
  9309. * as well as binding the different shadow properties to the effects.
  9310. */
  9311. export interface IShadowLight extends Light {
  9312. /**
  9313. * The light id in the scene (used in scene.findLightById for instance)
  9314. */
  9315. id: string;
  9316. /**
  9317. * The position the shadow will be casted from.
  9318. */
  9319. position: Vector3;
  9320. /**
  9321. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9322. */
  9323. direction: Vector3;
  9324. /**
  9325. * The transformed position. Position of the light in world space taking parenting in account.
  9326. */
  9327. transformedPosition: Vector3;
  9328. /**
  9329. * The transformed direction. Direction of the light in world space taking parenting in account.
  9330. */
  9331. transformedDirection: Vector3;
  9332. /**
  9333. * The friendly name of the light in the scene.
  9334. */
  9335. name: string;
  9336. /**
  9337. * Defines the shadow projection clipping minimum z value.
  9338. */
  9339. shadowMinZ: number;
  9340. /**
  9341. * Defines the shadow projection clipping maximum z value.
  9342. */
  9343. shadowMaxZ: number;
  9344. /**
  9345. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9346. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9347. */
  9348. computeTransformedInformation(): boolean;
  9349. /**
  9350. * Gets the scene the light belongs to.
  9351. * @returns The scene
  9352. */
  9353. getScene(): Scene;
  9354. /**
  9355. * Callback defining a custom Projection Matrix Builder.
  9356. * This can be used to override the default projection matrix computation.
  9357. */
  9358. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9359. /**
  9360. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9361. * @param matrix The matrix to updated with the projection information
  9362. * @param viewMatrix The transform matrix of the light
  9363. * @param renderList The list of mesh to render in the map
  9364. * @returns The current light
  9365. */
  9366. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9367. /**
  9368. * Gets the current depth scale used in ESM.
  9369. * @returns The scale
  9370. */
  9371. getDepthScale(): number;
  9372. /**
  9373. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9374. * @returns true if a cube texture needs to be use
  9375. */
  9376. needCube(): boolean;
  9377. /**
  9378. * Detects if the projection matrix requires to be recomputed this frame.
  9379. * @returns true if it requires to be recomputed otherwise, false.
  9380. */
  9381. needProjectionMatrixCompute(): boolean;
  9382. /**
  9383. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9384. */
  9385. forceProjectionMatrixCompute(): void;
  9386. /**
  9387. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9388. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9389. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9390. */
  9391. getShadowDirection(faceIndex?: number): Vector3;
  9392. /**
  9393. * Gets the minZ used for shadow according to both the scene and the light.
  9394. * @param activeCamera The camera we are returning the min for
  9395. * @returns the depth min z
  9396. */
  9397. getDepthMinZ(activeCamera: Camera): number;
  9398. /**
  9399. * Gets the maxZ used for shadow according to both the scene and the light.
  9400. * @param activeCamera The camera we are returning the max for
  9401. * @returns the depth max z
  9402. */
  9403. getDepthMaxZ(activeCamera: Camera): number;
  9404. }
  9405. /**
  9406. * Base implementation IShadowLight
  9407. * It groups all the common behaviour in order to reduce duplication and better follow the DRY pattern.
  9408. */
  9409. export abstract class ShadowLight extends Light implements IShadowLight {
  9410. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9411. protected _position: Vector3;
  9412. protected _setPosition(value: Vector3): void;
  9413. /**
  9414. * Sets the position the shadow will be casted from. Also use as the light position for both
  9415. * point and spot lights.
  9416. */
  9417. get position(): Vector3;
  9418. /**
  9419. * Sets the position the shadow will be casted from. Also use as the light position for both
  9420. * point and spot lights.
  9421. */
  9422. set position(value: Vector3);
  9423. protected _direction: Vector3;
  9424. protected _setDirection(value: Vector3): void;
  9425. /**
  9426. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9427. * Also use as the light direction on spot and directional lights.
  9428. */
  9429. get direction(): Vector3;
  9430. /**
  9431. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9432. * Also use as the light direction on spot and directional lights.
  9433. */
  9434. set direction(value: Vector3);
  9435. protected _shadowMinZ: number;
  9436. /**
  9437. * Gets the shadow projection clipping minimum z value.
  9438. */
  9439. get shadowMinZ(): number;
  9440. /**
  9441. * Sets the shadow projection clipping minimum z value.
  9442. */
  9443. set shadowMinZ(value: number);
  9444. protected _shadowMaxZ: number;
  9445. /**
  9446. * Sets the shadow projection clipping maximum z value.
  9447. */
  9448. get shadowMaxZ(): number;
  9449. /**
  9450. * Gets the shadow projection clipping maximum z value.
  9451. */
  9452. set shadowMaxZ(value: number);
  9453. /**
  9454. * Callback defining a custom Projection Matrix Builder.
  9455. * This can be used to override the default projection matrix computation.
  9456. */
  9457. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9458. /**
  9459. * The transformed position. Position of the light in world space taking parenting in account.
  9460. */
  9461. transformedPosition: Vector3;
  9462. /**
  9463. * The transformed direction. Direction of the light in world space taking parenting in account.
  9464. */
  9465. transformedDirection: Vector3;
  9466. private _needProjectionMatrixCompute;
  9467. /**
  9468. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9469. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9470. */
  9471. computeTransformedInformation(): boolean;
  9472. /**
  9473. * Return the depth scale used for the shadow map.
  9474. * @returns the depth scale.
  9475. */
  9476. getDepthScale(): number;
  9477. /**
  9478. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9479. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9480. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9481. */
  9482. getShadowDirection(faceIndex?: number): Vector3;
  9483. /**
  9484. * Returns the ShadowLight absolute position in the World.
  9485. * @returns the position vector in world space
  9486. */
  9487. getAbsolutePosition(): Vector3;
  9488. /**
  9489. * Sets the ShadowLight direction toward the passed target.
  9490. * @param target The point to target in local space
  9491. * @returns the updated ShadowLight direction
  9492. */
  9493. setDirectionToTarget(target: Vector3): Vector3;
  9494. /**
  9495. * Returns the light rotation in euler definition.
  9496. * @returns the x y z rotation in local space.
  9497. */
  9498. getRotation(): Vector3;
  9499. /**
  9500. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9501. * @returns true if a cube texture needs to be use
  9502. */
  9503. needCube(): boolean;
  9504. /**
  9505. * Detects if the projection matrix requires to be recomputed this frame.
  9506. * @returns true if it requires to be recomputed otherwise, false.
  9507. */
  9508. needProjectionMatrixCompute(): boolean;
  9509. /**
  9510. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9511. */
  9512. forceProjectionMatrixCompute(): void;
  9513. /** @hidden */
  9514. _initCache(): void;
  9515. /** @hidden */
  9516. _isSynchronized(): boolean;
  9517. /**
  9518. * Computes the world matrix of the node
  9519. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9520. * @returns the world matrix
  9521. */
  9522. computeWorldMatrix(force?: boolean): Matrix;
  9523. /**
  9524. * Gets the minZ used for shadow according to both the scene and the light.
  9525. * @param activeCamera The camera we are returning the min for
  9526. * @returns the depth min z
  9527. */
  9528. getDepthMinZ(activeCamera: Camera): number;
  9529. /**
  9530. * Gets the maxZ used for shadow according to both the scene and the light.
  9531. * @param activeCamera The camera we are returning the max for
  9532. * @returns the depth max z
  9533. */
  9534. getDepthMaxZ(activeCamera: Camera): number;
  9535. /**
  9536. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9537. * @param matrix The matrix to updated with the projection information
  9538. * @param viewMatrix The transform matrix of the light
  9539. * @param renderList The list of mesh to render in the map
  9540. * @returns The current light
  9541. */
  9542. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9543. }
  9544. }
  9545. declare module BABYLON {
  9546. /**
  9547. * Configuration needed for prepass-capable materials
  9548. */
  9549. export class PrePassConfiguration {
  9550. /**
  9551. * Previous world matrices of meshes carrying this material
  9552. * Used for computing velocity
  9553. */
  9554. previousWorldMatrices: {
  9555. [index: number]: Matrix;
  9556. };
  9557. /**
  9558. * Previous view project matrix
  9559. * Used for computing velocity
  9560. */
  9561. previousViewProjection: Matrix;
  9562. /**
  9563. * Previous bones of meshes carrying this material
  9564. * Used for computing velocity
  9565. */
  9566. previousBones: {
  9567. [index: number]: Float32Array;
  9568. };
  9569. /**
  9570. * Add the required uniforms to the current list.
  9571. * @param uniforms defines the current uniform list.
  9572. */
  9573. static AddUniforms(uniforms: string[]): void;
  9574. /**
  9575. * Add the required samplers to the current list.
  9576. * @param samplers defines the current sampler list.
  9577. */
  9578. static AddSamplers(samplers: string[]): void;
  9579. /**
  9580. * Binds the material data.
  9581. * @param effect defines the effect to update
  9582. * @param scene defines the scene the material belongs to.
  9583. * @param mesh The mesh
  9584. * @param world World matrix of this mesh
  9585. * @param isFrozen Is the material frozen
  9586. */
  9587. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9588. }
  9589. }
  9590. declare module BABYLON {
  9591. /**
  9592. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9593. * This is the base of the follow, arc rotate cameras and Free camera
  9594. * @see https://doc.babylonjs.com/features/cameras
  9595. */
  9596. export class TargetCamera extends Camera {
  9597. private static _RigCamTransformMatrix;
  9598. private static _TargetTransformMatrix;
  9599. private static _TargetFocalPoint;
  9600. private _tmpUpVector;
  9601. private _tmpTargetVector;
  9602. /**
  9603. * Define the current direction the camera is moving to
  9604. */
  9605. cameraDirection: Vector3;
  9606. /**
  9607. * Define the current rotation the camera is rotating to
  9608. */
  9609. cameraRotation: Vector2;
  9610. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9611. ignoreParentScaling: boolean;
  9612. /**
  9613. * When set, the up vector of the camera will be updated by the rotation of the camera
  9614. */
  9615. updateUpVectorFromRotation: boolean;
  9616. private _tmpQuaternion;
  9617. /**
  9618. * Define the current rotation of the camera
  9619. */
  9620. rotation: Vector3;
  9621. /**
  9622. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9623. */
  9624. rotationQuaternion: Quaternion;
  9625. /**
  9626. * Define the current speed of the camera
  9627. */
  9628. speed: number;
  9629. /**
  9630. * Add constraint to the camera to prevent it to move freely in all directions and
  9631. * around all axis.
  9632. */
  9633. noRotationConstraint: boolean;
  9634. /**
  9635. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9636. * panning
  9637. */
  9638. invertRotation: boolean;
  9639. /**
  9640. * Speed multiplier for inverse camera panning
  9641. */
  9642. inverseRotationSpeed: number;
  9643. /**
  9644. * Define the current target of the camera as an object or a position.
  9645. */
  9646. lockedTarget: any;
  9647. /** @hidden */
  9648. _currentTarget: Vector3;
  9649. /** @hidden */
  9650. _initialFocalDistance: number;
  9651. /** @hidden */
  9652. _viewMatrix: Matrix;
  9653. /** @hidden */
  9654. _camMatrix: Matrix;
  9655. /** @hidden */
  9656. _cameraTransformMatrix: Matrix;
  9657. /** @hidden */
  9658. _cameraRotationMatrix: Matrix;
  9659. /** @hidden */
  9660. _referencePoint: Vector3;
  9661. /** @hidden */
  9662. _transformedReferencePoint: Vector3;
  9663. /** @hidden */
  9664. _reset: () => void;
  9665. private _defaultUp;
  9666. /**
  9667. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9668. * This is the base of the follow, arc rotate cameras and Free camera
  9669. * @see https://doc.babylonjs.com/features/cameras
  9670. * @param name Defines the name of the camera in the scene
  9671. * @param position Defines the start position of the camera in the scene
  9672. * @param scene Defines the scene the camera belongs to
  9673. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  9674. */
  9675. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9676. /**
  9677. * Gets the position in front of the camera at a given distance.
  9678. * @param distance The distance from the camera we want the position to be
  9679. * @returns the position
  9680. */
  9681. getFrontPosition(distance: number): Vector3;
  9682. /** @hidden */
  9683. _getLockedTargetPosition(): Nullable<Vector3>;
  9684. private _storedPosition;
  9685. private _storedRotation;
  9686. private _storedRotationQuaternion;
  9687. /**
  9688. * Store current camera state of the camera (fov, position, rotation, etc..)
  9689. * @returns the camera
  9690. */
  9691. storeState(): Camera;
  9692. /**
  9693. * Restored camera state. You must call storeState() first
  9694. * @returns whether it was successful or not
  9695. * @hidden
  9696. */
  9697. _restoreStateValues(): boolean;
  9698. /** @hidden */
  9699. _initCache(): void;
  9700. /** @hidden */
  9701. _updateCache(ignoreParentClass?: boolean): void;
  9702. /** @hidden */
  9703. _isSynchronizedViewMatrix(): boolean;
  9704. /** @hidden */
  9705. _computeLocalCameraSpeed(): number;
  9706. /**
  9707. * Defines the target the camera should look at.
  9708. * @param target Defines the new target as a Vector or a mesh
  9709. */
  9710. setTarget(target: Vector3): void;
  9711. /**
  9712. * Defines the target point of the camera.
  9713. * The camera looks towards it form the radius distance.
  9714. */
  9715. get target(): Vector3;
  9716. set target(value: Vector3);
  9717. /**
  9718. * Return the current target position of the camera. This value is expressed in local space.
  9719. * @returns the target position
  9720. */
  9721. getTarget(): Vector3;
  9722. /** @hidden */
  9723. _decideIfNeedsToMove(): boolean;
  9724. /** @hidden */
  9725. _updatePosition(): void;
  9726. /** @hidden */
  9727. _checkInputs(): void;
  9728. protected _updateCameraRotationMatrix(): void;
  9729. /**
  9730. * 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)
  9731. * @returns the current camera
  9732. */
  9733. private _rotateUpVectorWithCameraRotationMatrix;
  9734. private _cachedRotationZ;
  9735. private _cachedQuaternionRotationZ;
  9736. /** @hidden */
  9737. _getViewMatrix(): Matrix;
  9738. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9739. /**
  9740. * @hidden
  9741. */
  9742. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9743. /**
  9744. * @hidden
  9745. */
  9746. _updateRigCameras(): void;
  9747. private _getRigCamPositionAndTarget;
  9748. /**
  9749. * Gets the current object class name.
  9750. * @return the class name
  9751. */
  9752. getClassName(): string;
  9753. }
  9754. }
  9755. declare module BABYLON {
  9756. /**
  9757. * @ignore
  9758. * This is a list of all the different input types that are available in the application.
  9759. * Fo instance: ArcRotateCameraGamepadInput...
  9760. */
  9761. export var CameraInputTypes: {};
  9762. /**
  9763. * This is the contract to implement in order to create a new input class.
  9764. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9765. */
  9766. export interface ICameraInput<TCamera extends Camera> {
  9767. /**
  9768. * Defines the camera the input is attached to.
  9769. */
  9770. camera: Nullable<TCamera>;
  9771. /**
  9772. * Gets the class name of the current input.
  9773. * @returns the class name
  9774. */
  9775. getClassName(): string;
  9776. /**
  9777. * Get the friendly name associated with the input class.
  9778. * @returns the input friendly name
  9779. */
  9780. getSimpleName(): string;
  9781. /**
  9782. * Attach the input controls to a specific dom element to get the input from.
  9783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9784. */
  9785. attachControl(noPreventDefault?: boolean): void;
  9786. /**
  9787. * Detach the current controls from the specified dom element.
  9788. */
  9789. detachControl(): void;
  9790. /**
  9791. * Update the current camera state depending on the inputs that have been used this frame.
  9792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9793. */
  9794. checkInputs?: () => void;
  9795. }
  9796. /**
  9797. * Represents a map of input types to input instance or input index to input instance.
  9798. */
  9799. export interface CameraInputsMap<TCamera extends Camera> {
  9800. /**
  9801. * Accessor to the input by input type.
  9802. */
  9803. [name: string]: ICameraInput<TCamera>;
  9804. /**
  9805. * Accessor to the input by input index.
  9806. */
  9807. [idx: number]: ICameraInput<TCamera>;
  9808. }
  9809. /**
  9810. * This represents the input manager used within a camera.
  9811. * It helps dealing with all the different kind of input attached to a camera.
  9812. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9813. */
  9814. export class CameraInputsManager<TCamera extends Camera> {
  9815. /**
  9816. * Defines the list of inputs attached to the camera.
  9817. */
  9818. attached: CameraInputsMap<TCamera>;
  9819. /**
  9820. * Defines the dom element the camera is collecting inputs from.
  9821. * This is null if the controls have not been attached.
  9822. */
  9823. attachedToElement: boolean;
  9824. /**
  9825. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9826. */
  9827. noPreventDefault: boolean;
  9828. /**
  9829. * Defined the camera the input manager belongs to.
  9830. */
  9831. camera: TCamera;
  9832. /**
  9833. * Update the current camera state depending on the inputs that have been used this frame.
  9834. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9835. */
  9836. checkInputs: () => void;
  9837. /**
  9838. * Instantiate a new Camera Input Manager.
  9839. * @param camera Defines the camera the input manager belongs to
  9840. */
  9841. constructor(camera: TCamera);
  9842. /**
  9843. * Add an input method to a camera
  9844. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9845. * @param input camera input method
  9846. */
  9847. add(input: ICameraInput<TCamera>): void;
  9848. /**
  9849. * Remove a specific input method from a camera
  9850. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9851. * @param inputToRemove camera input method
  9852. */
  9853. remove(inputToRemove: ICameraInput<TCamera>): void;
  9854. /**
  9855. * Remove a specific input type from a camera
  9856. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9857. * @param inputType the type of the input to remove
  9858. */
  9859. removeByType(inputType: string): void;
  9860. private _addCheckInputs;
  9861. /**
  9862. * Attach the input controls to the currently attached dom element to listen the events from.
  9863. * @param input Defines the input to attach
  9864. */
  9865. attachInput(input: ICameraInput<TCamera>): void;
  9866. /**
  9867. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9868. * @param element Defines the dom element to collect the events from
  9869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9870. */
  9871. attachElement(noPreventDefault?: boolean): void;
  9872. /**
  9873. * Detach the current manager inputs controls from a specific dom element.
  9874. * @param element Defines the dom element to collect the events from
  9875. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9876. */
  9877. detachElement(disconnect?: boolean): void;
  9878. /**
  9879. * Rebuild the dynamic inputCheck function from the current list of
  9880. * defined inputs in the manager.
  9881. */
  9882. rebuildInputCheck(): void;
  9883. /**
  9884. * Remove all attached input methods from a camera
  9885. */
  9886. clear(): void;
  9887. /**
  9888. * Serialize the current input manager attached to a camera.
  9889. * This ensures than once parsed,
  9890. * the input associated to the camera will be identical to the current ones
  9891. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9892. */
  9893. serialize(serializedCamera: any): void;
  9894. /**
  9895. * Parses an input manager serialized JSON to restore the previous list of inputs
  9896. * and states associated to a camera.
  9897. * @param parsedCamera Defines the JSON to parse
  9898. */
  9899. parse(parsedCamera: any): void;
  9900. }
  9901. }
  9902. declare module BABYLON {
  9903. /**
  9904. * Gather the list of keyboard event types as constants.
  9905. */
  9906. export class KeyboardEventTypes {
  9907. /**
  9908. * The keydown event is fired when a key becomes active (pressed).
  9909. */
  9910. static readonly KEYDOWN: number;
  9911. /**
  9912. * The keyup event is fired when a key has been released.
  9913. */
  9914. static readonly KEYUP: number;
  9915. }
  9916. /**
  9917. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9918. */
  9919. export class KeyboardInfo {
  9920. /**
  9921. * Defines the type of event (KeyboardEventTypes)
  9922. */
  9923. type: number;
  9924. /**
  9925. * Defines the related dom event
  9926. */
  9927. event: KeyboardEvent;
  9928. /**
  9929. * Instantiates a new keyboard info.
  9930. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9931. * @param type Defines the type of event (KeyboardEventTypes)
  9932. * @param event Defines the related dom event
  9933. */
  9934. constructor(
  9935. /**
  9936. * Defines the type of event (KeyboardEventTypes)
  9937. */
  9938. type: number,
  9939. /**
  9940. * Defines the related dom event
  9941. */
  9942. event: KeyboardEvent);
  9943. }
  9944. /**
  9945. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9946. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9947. */
  9948. export class KeyboardInfoPre extends KeyboardInfo {
  9949. /**
  9950. * Defines the type of event (KeyboardEventTypes)
  9951. */
  9952. type: number;
  9953. /**
  9954. * Defines the related dom event
  9955. */
  9956. event: KeyboardEvent;
  9957. /**
  9958. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9959. */
  9960. skipOnPointerObservable: boolean;
  9961. /**
  9962. * Instantiates a new keyboard pre info.
  9963. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9964. * @param type Defines the type of event (KeyboardEventTypes)
  9965. * @param event Defines the related dom event
  9966. */
  9967. constructor(
  9968. /**
  9969. * Defines the type of event (KeyboardEventTypes)
  9970. */
  9971. type: number,
  9972. /**
  9973. * Defines the related dom event
  9974. */
  9975. event: KeyboardEvent);
  9976. }
  9977. }
  9978. declare module BABYLON {
  9979. /**
  9980. * Manage the keyboard inputs to control the movement of a free camera.
  9981. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9982. */
  9983. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9984. /**
  9985. * Defines the camera the input is attached to.
  9986. */
  9987. camera: FreeCamera;
  9988. /**
  9989. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9990. */
  9991. keysUp: number[];
  9992. /**
  9993. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9994. */
  9995. keysUpward: number[];
  9996. /**
  9997. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9998. */
  9999. keysDown: number[];
  10000. /**
  10001. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  10002. */
  10003. keysDownward: number[];
  10004. /**
  10005. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  10006. */
  10007. keysLeft: number[];
  10008. /**
  10009. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  10010. */
  10011. keysRight: number[];
  10012. private _keys;
  10013. private _onCanvasBlurObserver;
  10014. private _onKeyboardObserver;
  10015. private _engine;
  10016. private _scene;
  10017. /**
  10018. * Attach the input controls to a specific dom element to get the input from.
  10019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10020. */
  10021. attachControl(noPreventDefault?: boolean): void;
  10022. /**
  10023. * Detach the current controls from the specified dom element.
  10024. */
  10025. detachControl(): void;
  10026. /**
  10027. * Update the current camera state depending on the inputs that have been used this frame.
  10028. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10029. */
  10030. checkInputs(): void;
  10031. /**
  10032. * Gets the class name of the current input.
  10033. * @returns the class name
  10034. */
  10035. getClassName(): string;
  10036. /** @hidden */
  10037. _onLostFocus(): void;
  10038. /**
  10039. * Get the friendly name associated with the input class.
  10040. * @returns the input friendly name
  10041. */
  10042. getSimpleName(): string;
  10043. }
  10044. }
  10045. declare module BABYLON {
  10046. /**
  10047. * Interface used to define Action
  10048. */
  10049. export interface IAction {
  10050. /**
  10051. * Trigger for the action
  10052. */
  10053. trigger: number;
  10054. /** Options of the trigger */
  10055. triggerOptions: any;
  10056. /**
  10057. * Gets the trigger parameters
  10058. * @returns the trigger parameters
  10059. */
  10060. getTriggerParameter(): any;
  10061. /**
  10062. * Internal only - executes current action event
  10063. * @hidden
  10064. */
  10065. _executeCurrent(evt?: ActionEvent): void;
  10066. /**
  10067. * Serialize placeholder for child classes
  10068. * @param parent of child
  10069. * @returns the serialized object
  10070. */
  10071. serialize(parent: any): any;
  10072. /**
  10073. * Internal only
  10074. * @hidden
  10075. */
  10076. _prepare(): void;
  10077. /**
  10078. * Internal only - manager for action
  10079. * @hidden
  10080. */
  10081. _actionManager: Nullable<AbstractActionManager>;
  10082. /**
  10083. * Adds action to chain of actions, may be a DoNothingAction
  10084. * @param action defines the next action to execute
  10085. * @returns The action passed in
  10086. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10087. */
  10088. then(action: IAction): IAction;
  10089. }
  10090. /**
  10091. * The action to be carried out following a trigger
  10092. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10093. */
  10094. export class Action implements IAction {
  10095. /** the trigger, with or without parameters, for the action */
  10096. triggerOptions: any;
  10097. /**
  10098. * Trigger for the action
  10099. */
  10100. trigger: number;
  10101. /**
  10102. * Internal only - manager for action
  10103. * @hidden
  10104. */
  10105. _actionManager: ActionManager;
  10106. private _nextActiveAction;
  10107. private _child;
  10108. private _condition?;
  10109. private _triggerParameter;
  10110. /**
  10111. * An event triggered prior to action being executed.
  10112. */
  10113. onBeforeExecuteObservable: Observable<Action>;
  10114. /**
  10115. * Creates a new Action
  10116. * @param triggerOptions the trigger, with or without parameters, for the action
  10117. * @param condition an optional determinant of action
  10118. */
  10119. constructor(
  10120. /** the trigger, with or without parameters, for the action */
  10121. triggerOptions: any, condition?: Condition);
  10122. /**
  10123. * Internal only
  10124. * @hidden
  10125. */
  10126. _prepare(): void;
  10127. /**
  10128. * Gets the trigger parameter
  10129. * @returns the trigger parameter
  10130. */
  10131. getTriggerParameter(): any;
  10132. /**
  10133. * Sets the trigger parameter
  10134. * @param value defines the new trigger parameter
  10135. */
  10136. setTriggerParameter(value: any): void;
  10137. /**
  10138. * Internal only - executes current action event
  10139. * @hidden
  10140. */
  10141. _executeCurrent(evt?: ActionEvent): void;
  10142. /**
  10143. * Execute placeholder for child classes
  10144. * @param evt optional action event
  10145. */
  10146. execute(evt?: ActionEvent): void;
  10147. /**
  10148. * Skips to next active action
  10149. */
  10150. skipToNextActiveAction(): void;
  10151. /**
  10152. * Adds action to chain of actions, may be a DoNothingAction
  10153. * @param action defines the next action to execute
  10154. * @returns The action passed in
  10155. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10156. */
  10157. then(action: Action): Action;
  10158. /**
  10159. * Internal only
  10160. * @hidden
  10161. */
  10162. _getProperty(propertyPath: string): string;
  10163. /**
  10164. * Internal only
  10165. * @hidden
  10166. */
  10167. _getEffectiveTarget(target: any, propertyPath: string): any;
  10168. /**
  10169. * Serialize placeholder for child classes
  10170. * @param parent of child
  10171. * @returns the serialized object
  10172. */
  10173. serialize(parent: any): any;
  10174. /**
  10175. * Internal only called by serialize
  10176. * @hidden
  10177. */
  10178. protected _serialize(serializedAction: any, parent?: any): any;
  10179. /**
  10180. * Internal only
  10181. * @hidden
  10182. */
  10183. static _SerializeValueAsString: (value: any) => string;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. static _GetTargetProperty: (target: Scene | Node) => {
  10189. name: string;
  10190. targetType: string;
  10191. value: string;
  10192. };
  10193. }
  10194. }
  10195. declare module BABYLON {
  10196. /**
  10197. * A Condition applied to an Action
  10198. */
  10199. export class Condition {
  10200. /**
  10201. * Internal only - manager for action
  10202. * @hidden
  10203. */
  10204. _actionManager: ActionManager;
  10205. /**
  10206. * Internal only
  10207. * @hidden
  10208. */
  10209. _evaluationId: number;
  10210. /**
  10211. * Internal only
  10212. * @hidden
  10213. */
  10214. _currentResult: boolean;
  10215. /**
  10216. * Creates a new Condition
  10217. * @param actionManager the manager of the action the condition is applied to
  10218. */
  10219. constructor(actionManager: ActionManager);
  10220. /**
  10221. * Check if the current condition is valid
  10222. * @returns a boolean
  10223. */
  10224. isValid(): boolean;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. _getProperty(propertyPath: string): string;
  10230. /**
  10231. * Internal only
  10232. * @hidden
  10233. */
  10234. _getEffectiveTarget(target: any, propertyPath: string): any;
  10235. /**
  10236. * Serialize placeholder for child classes
  10237. * @returns the serialized object
  10238. */
  10239. serialize(): any;
  10240. /**
  10241. * Internal only
  10242. * @hidden
  10243. */
  10244. protected _serialize(serializedCondition: any): any;
  10245. }
  10246. /**
  10247. * Defines specific conditional operators as extensions of Condition
  10248. */
  10249. export class ValueCondition extends Condition {
  10250. /** path to specify the property of the target the conditional operator uses */
  10251. propertyPath: string;
  10252. /** the value compared by the conditional operator against the current value of the property */
  10253. value: any;
  10254. /** the conditional operator, default ValueCondition.IsEqual */
  10255. operator: number;
  10256. /**
  10257. * Internal only
  10258. * @hidden
  10259. */
  10260. private static _IsEqual;
  10261. /**
  10262. * Internal only
  10263. * @hidden
  10264. */
  10265. private static _IsDifferent;
  10266. /**
  10267. * Internal only
  10268. * @hidden
  10269. */
  10270. private static _IsGreater;
  10271. /**
  10272. * Internal only
  10273. * @hidden
  10274. */
  10275. private static _IsLesser;
  10276. /**
  10277. * returns the number for IsEqual
  10278. */
  10279. static get IsEqual(): number;
  10280. /**
  10281. * Returns the number for IsDifferent
  10282. */
  10283. static get IsDifferent(): number;
  10284. /**
  10285. * Returns the number for IsGreater
  10286. */
  10287. static get IsGreater(): number;
  10288. /**
  10289. * Returns the number for IsLesser
  10290. */
  10291. static get IsLesser(): number;
  10292. /**
  10293. * Internal only The action manager for the condition
  10294. * @hidden
  10295. */
  10296. _actionManager: ActionManager;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. private _target;
  10302. /**
  10303. * Internal only
  10304. * @hidden
  10305. */
  10306. private _effectiveTarget;
  10307. /**
  10308. * Internal only
  10309. * @hidden
  10310. */
  10311. private _property;
  10312. /**
  10313. * Creates a new ValueCondition
  10314. * @param actionManager manager for the action the condition applies to
  10315. * @param target for the action
  10316. * @param propertyPath path to specify the property of the target the conditional operator uses
  10317. * @param value the value compared by the conditional operator against the current value of the property
  10318. * @param operator the conditional operator, default ValueCondition.IsEqual
  10319. */
  10320. constructor(actionManager: ActionManager, target: any,
  10321. /** path to specify the property of the target the conditional operator uses */
  10322. propertyPath: string,
  10323. /** the value compared by the conditional operator against the current value of the property */
  10324. value: any,
  10325. /** the conditional operator, default ValueCondition.IsEqual */
  10326. operator?: number);
  10327. /**
  10328. * Compares the given value with the property value for the specified conditional operator
  10329. * @returns the result of the comparison
  10330. */
  10331. isValid(): boolean;
  10332. /**
  10333. * Serialize the ValueCondition into a JSON compatible object
  10334. * @returns serialization object
  10335. */
  10336. serialize(): any;
  10337. /**
  10338. * Gets the name of the conditional operator for the ValueCondition
  10339. * @param operator the conditional operator
  10340. * @returns the name
  10341. */
  10342. static GetOperatorName(operator: number): string;
  10343. }
  10344. /**
  10345. * Defines a predicate condition as an extension of Condition
  10346. */
  10347. export class PredicateCondition extends Condition {
  10348. /** defines the predicate function used to validate the condition */
  10349. predicate: () => boolean;
  10350. /**
  10351. * Internal only - manager for action
  10352. * @hidden
  10353. */
  10354. _actionManager: ActionManager;
  10355. /**
  10356. * Creates a new PredicateCondition
  10357. * @param actionManager manager for the action the condition applies to
  10358. * @param predicate defines the predicate function used to validate the condition
  10359. */
  10360. constructor(actionManager: ActionManager,
  10361. /** defines the predicate function used to validate the condition */
  10362. predicate: () => boolean);
  10363. /**
  10364. * @returns the validity of the predicate condition
  10365. */
  10366. isValid(): boolean;
  10367. }
  10368. /**
  10369. * Defines a state condition as an extension of Condition
  10370. */
  10371. export class StateCondition extends Condition {
  10372. /** Value to compare with target state */
  10373. value: string;
  10374. /**
  10375. * Internal only - manager for action
  10376. * @hidden
  10377. */
  10378. _actionManager: ActionManager;
  10379. /**
  10380. * Internal only
  10381. * @hidden
  10382. */
  10383. private _target;
  10384. /**
  10385. * Creates a new StateCondition
  10386. * @param actionManager manager for the action the condition applies to
  10387. * @param target of the condition
  10388. * @param value to compare with target state
  10389. */
  10390. constructor(actionManager: ActionManager, target: any,
  10391. /** Value to compare with target state */
  10392. value: string);
  10393. /**
  10394. * Gets a boolean indicating if the current condition is met
  10395. * @returns the validity of the state
  10396. */
  10397. isValid(): boolean;
  10398. /**
  10399. * Serialize the StateCondition into a JSON compatible object
  10400. * @returns serialization object
  10401. */
  10402. serialize(): any;
  10403. }
  10404. }
  10405. declare module BABYLON {
  10406. /**
  10407. * This defines an action responsible to toggle a boolean once triggered.
  10408. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10409. */
  10410. export class SwitchBooleanAction extends Action {
  10411. /**
  10412. * The path to the boolean property in the target object
  10413. */
  10414. propertyPath: string;
  10415. private _target;
  10416. private _effectiveTarget;
  10417. private _property;
  10418. /**
  10419. * Instantiate the action
  10420. * @param triggerOptions defines the trigger options
  10421. * @param target defines the object containing the boolean
  10422. * @param propertyPath defines the path to the boolean property in the target object
  10423. * @param condition defines the trigger related conditions
  10424. */
  10425. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10426. /** @hidden */
  10427. _prepare(): void;
  10428. /**
  10429. * Execute the action toggle the boolean value.
  10430. */
  10431. execute(): void;
  10432. /**
  10433. * Serializes the actions and its related information.
  10434. * @param parent defines the object to serialize in
  10435. * @returns the serialized object
  10436. */
  10437. serialize(parent: any): any;
  10438. }
  10439. /**
  10440. * This defines an action responsible to set a the state field of the target
  10441. * to a desired value once triggered.
  10442. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10443. */
  10444. export class SetStateAction extends Action {
  10445. /**
  10446. * The value to store in the state field.
  10447. */
  10448. value: string;
  10449. private _target;
  10450. /**
  10451. * Instantiate the action
  10452. * @param triggerOptions defines the trigger options
  10453. * @param target defines the object containing the state property
  10454. * @param value defines the value to store in the state field
  10455. * @param condition defines the trigger related conditions
  10456. */
  10457. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10458. /**
  10459. * Execute the action and store the value on the target state property.
  10460. */
  10461. execute(): void;
  10462. /**
  10463. * Serializes the actions and its related information.
  10464. * @param parent defines the object to serialize in
  10465. * @returns the serialized object
  10466. */
  10467. serialize(parent: any): any;
  10468. }
  10469. /**
  10470. * This defines an action responsible to set a property of the target
  10471. * to a desired value once triggered.
  10472. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10473. */
  10474. export class SetValueAction extends Action {
  10475. /**
  10476. * The path of the property to set in the target.
  10477. */
  10478. propertyPath: string;
  10479. /**
  10480. * The value to set in the property
  10481. */
  10482. value: any;
  10483. private _target;
  10484. private _effectiveTarget;
  10485. private _property;
  10486. /**
  10487. * Instantiate the action
  10488. * @param triggerOptions defines the trigger options
  10489. * @param target defines the object containing the property
  10490. * @param propertyPath defines the path of the property to set in the target
  10491. * @param value defines the value to set in the property
  10492. * @param condition defines the trigger related conditions
  10493. */
  10494. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10495. /** @hidden */
  10496. _prepare(): void;
  10497. /**
  10498. * Execute the action and set the targeted property to the desired value.
  10499. */
  10500. execute(): void;
  10501. /**
  10502. * Serializes the actions and its related information.
  10503. * @param parent defines the object to serialize in
  10504. * @returns the serialized object
  10505. */
  10506. serialize(parent: any): any;
  10507. }
  10508. /**
  10509. * This defines an action responsible to increment the target value
  10510. * to a desired value once triggered.
  10511. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10512. */
  10513. export class IncrementValueAction extends Action {
  10514. /**
  10515. * The path of the property to increment in the target.
  10516. */
  10517. propertyPath: string;
  10518. /**
  10519. * The value we should increment the property by.
  10520. */
  10521. value: any;
  10522. private _target;
  10523. private _effectiveTarget;
  10524. private _property;
  10525. /**
  10526. * Instantiate the action
  10527. * @param triggerOptions defines the trigger options
  10528. * @param target defines the object containing the property
  10529. * @param propertyPath defines the path of the property to increment in the target
  10530. * @param value defines the value value we should increment the property by
  10531. * @param condition defines the trigger related conditions
  10532. */
  10533. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10534. /** @hidden */
  10535. _prepare(): void;
  10536. /**
  10537. * Execute the action and increment the target of the value amount.
  10538. */
  10539. execute(): void;
  10540. /**
  10541. * Serializes the actions and its related information.
  10542. * @param parent defines the object to serialize in
  10543. * @returns the serialized object
  10544. */
  10545. serialize(parent: any): any;
  10546. }
  10547. /**
  10548. * This defines an action responsible to start an animation once triggered.
  10549. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10550. */
  10551. export class PlayAnimationAction extends Action {
  10552. /**
  10553. * Where the animation should start (animation frame)
  10554. */
  10555. from: number;
  10556. /**
  10557. * Where the animation should stop (animation frame)
  10558. */
  10559. to: number;
  10560. /**
  10561. * Define if the animation should loop or stop after the first play.
  10562. */
  10563. loop?: boolean;
  10564. private _target;
  10565. /**
  10566. * Instantiate the action
  10567. * @param triggerOptions defines the trigger options
  10568. * @param target defines the target animation or animation name
  10569. * @param from defines from where the animation should start (animation frame)
  10570. * @param to defines where the animation should stop (animation frame)
  10571. * @param loop defines if the animation should loop or stop after the first play
  10572. * @param condition defines the trigger related conditions
  10573. */
  10574. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10575. /** @hidden */
  10576. _prepare(): void;
  10577. /**
  10578. * Execute the action and play the animation.
  10579. */
  10580. execute(): void;
  10581. /**
  10582. * Serializes the actions and its related information.
  10583. * @param parent defines the object to serialize in
  10584. * @returns the serialized object
  10585. */
  10586. serialize(parent: any): any;
  10587. }
  10588. /**
  10589. * This defines an action responsible to stop an animation once triggered.
  10590. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10591. */
  10592. export class StopAnimationAction extends Action {
  10593. private _target;
  10594. /**
  10595. * Instantiate the action
  10596. * @param triggerOptions defines the trigger options
  10597. * @param target defines the target animation or animation name
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and stop the animation.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible that does nothing once triggered.
  10616. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class DoNothingAction extends Action {
  10619. /**
  10620. * Instantiate the action
  10621. * @param triggerOptions defines the trigger options
  10622. * @param condition defines the trigger related conditions
  10623. */
  10624. constructor(triggerOptions?: any, condition?: Condition);
  10625. /**
  10626. * Execute the action and do nothing.
  10627. */
  10628. execute(): void;
  10629. /**
  10630. * Serializes the actions and its related information.
  10631. * @param parent defines the object to serialize in
  10632. * @returns the serialized object
  10633. */
  10634. serialize(parent: any): any;
  10635. }
  10636. /**
  10637. * This defines an action responsible to trigger several actions once triggered.
  10638. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10639. */
  10640. export class CombineAction extends Action {
  10641. /**
  10642. * The list of aggregated animations to run.
  10643. */
  10644. children: Action[];
  10645. /**
  10646. * Instantiate the action
  10647. * @param triggerOptions defines the trigger options
  10648. * @param children defines the list of aggregated animations to run
  10649. * @param condition defines the trigger related conditions
  10650. */
  10651. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10652. /** @hidden */
  10653. _prepare(): void;
  10654. /**
  10655. * Execute the action and executes all the aggregated actions.
  10656. */
  10657. execute(evt: ActionEvent): void;
  10658. /**
  10659. * Serializes the actions and its related information.
  10660. * @param parent defines the object to serialize in
  10661. * @returns the serialized object
  10662. */
  10663. serialize(parent: any): any;
  10664. }
  10665. /**
  10666. * This defines an action responsible to run code (external event) once triggered.
  10667. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10668. */
  10669. export class ExecuteCodeAction extends Action {
  10670. /**
  10671. * The callback function to run.
  10672. */
  10673. func: (evt: ActionEvent) => void;
  10674. /**
  10675. * Instantiate the action
  10676. * @param triggerOptions defines the trigger options
  10677. * @param func defines the callback function to run
  10678. * @param condition defines the trigger related conditions
  10679. */
  10680. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10681. /**
  10682. * Execute the action and run the attached code.
  10683. */
  10684. execute(evt: ActionEvent): void;
  10685. }
  10686. /**
  10687. * This defines an action responsible to set the parent property of the target once triggered.
  10688. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10689. */
  10690. export class SetParentAction extends Action {
  10691. private _parent;
  10692. private _target;
  10693. /**
  10694. * Instantiate the action
  10695. * @param triggerOptions defines the trigger options
  10696. * @param target defines the target containing the parent property
  10697. * @param parent defines from where the animation should start (animation frame)
  10698. * @param condition defines the trigger related conditions
  10699. */
  10700. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10701. /** @hidden */
  10702. _prepare(): void;
  10703. /**
  10704. * Execute the action and set the parent property.
  10705. */
  10706. execute(): void;
  10707. /**
  10708. * Serializes the actions and its related information.
  10709. * @param parent defines the object to serialize in
  10710. * @returns the serialized object
  10711. */
  10712. serialize(parent: any): any;
  10713. }
  10714. }
  10715. declare module BABYLON {
  10716. /**
  10717. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10718. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10719. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10720. */
  10721. export class ActionManager extends AbstractActionManager {
  10722. /**
  10723. * Nothing
  10724. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10725. */
  10726. static readonly NothingTrigger: number;
  10727. /**
  10728. * On pick
  10729. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10730. */
  10731. static readonly OnPickTrigger: number;
  10732. /**
  10733. * On left pick
  10734. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10735. */
  10736. static readonly OnLeftPickTrigger: number;
  10737. /**
  10738. * On right pick
  10739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10740. */
  10741. static readonly OnRightPickTrigger: number;
  10742. /**
  10743. * On center pick
  10744. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10745. */
  10746. static readonly OnCenterPickTrigger: number;
  10747. /**
  10748. * On pick down
  10749. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10750. */
  10751. static readonly OnPickDownTrigger: number;
  10752. /**
  10753. * On double pick
  10754. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10755. */
  10756. static readonly OnDoublePickTrigger: number;
  10757. /**
  10758. * On pick up
  10759. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10760. */
  10761. static readonly OnPickUpTrigger: number;
  10762. /**
  10763. * On pick out.
  10764. * This trigger will only be raised if you also declared a OnPickDown
  10765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10766. */
  10767. static readonly OnPickOutTrigger: number;
  10768. /**
  10769. * On long press
  10770. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10771. */
  10772. static readonly OnLongPressTrigger: number;
  10773. /**
  10774. * On pointer over
  10775. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10776. */
  10777. static readonly OnPointerOverTrigger: number;
  10778. /**
  10779. * On pointer out
  10780. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10781. */
  10782. static readonly OnPointerOutTrigger: number;
  10783. /**
  10784. * On every frame
  10785. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10786. */
  10787. static readonly OnEveryFrameTrigger: number;
  10788. /**
  10789. * On intersection enter
  10790. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10791. */
  10792. static readonly OnIntersectionEnterTrigger: number;
  10793. /**
  10794. * On intersection exit
  10795. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10796. */
  10797. static readonly OnIntersectionExitTrigger: number;
  10798. /**
  10799. * On key down
  10800. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10801. */
  10802. static readonly OnKeyDownTrigger: number;
  10803. /**
  10804. * On key up
  10805. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10806. */
  10807. static readonly OnKeyUpTrigger: number;
  10808. private _scene;
  10809. /**
  10810. * Creates a new action manager
  10811. * @param scene defines the hosting scene
  10812. */
  10813. constructor(scene: Scene);
  10814. /**
  10815. * Releases all associated resources
  10816. */
  10817. dispose(): void;
  10818. /**
  10819. * Gets hosting scene
  10820. * @returns the hosting scene
  10821. */
  10822. getScene(): Scene;
  10823. /**
  10824. * Does this action manager handles actions of any of the given triggers
  10825. * @param triggers defines the triggers to be tested
  10826. * @return a boolean indicating whether one (or more) of the triggers is handled
  10827. */
  10828. hasSpecificTriggers(triggers: number[]): boolean;
  10829. /**
  10830. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10831. * speed.
  10832. * @param triggerA defines the trigger to be tested
  10833. * @param triggerB defines the trigger to be tested
  10834. * @return a boolean indicating whether one (or more) of the triggers is handled
  10835. */
  10836. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10837. /**
  10838. * Does this action manager handles actions of a given trigger
  10839. * @param trigger defines the trigger to be tested
  10840. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10841. * @return whether the trigger is handled
  10842. */
  10843. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10844. /**
  10845. * Does this action manager has pointer triggers
  10846. */
  10847. get hasPointerTriggers(): boolean;
  10848. /**
  10849. * Does this action manager has pick triggers
  10850. */
  10851. get hasPickTriggers(): boolean;
  10852. /**
  10853. * Registers an action to this action manager
  10854. * @param action defines the action to be registered
  10855. * @return the action amended (prepared) after registration
  10856. */
  10857. registerAction(action: IAction): Nullable<IAction>;
  10858. /**
  10859. * Unregisters an action to this action manager
  10860. * @param action defines the action to be unregistered
  10861. * @return a boolean indicating whether the action has been unregistered
  10862. */
  10863. unregisterAction(action: IAction): Boolean;
  10864. /**
  10865. * Process a specific trigger
  10866. * @param trigger defines the trigger to process
  10867. * @param evt defines the event details to be processed
  10868. */
  10869. processTrigger(trigger: number, evt?: IActionEvent): void;
  10870. /** @hidden */
  10871. _getEffectiveTarget(target: any, propertyPath: string): any;
  10872. /** @hidden */
  10873. _getProperty(propertyPath: string): string;
  10874. /**
  10875. * Serialize this manager to a JSON object
  10876. * @param name defines the property name to store this manager
  10877. * @returns a JSON representation of this manager
  10878. */
  10879. serialize(name: string): any;
  10880. /**
  10881. * Creates a new ActionManager from a JSON data
  10882. * @param parsedActions defines the JSON data to read from
  10883. * @param object defines the hosting mesh
  10884. * @param scene defines the hosting scene
  10885. */
  10886. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10887. /**
  10888. * Get a trigger name by index
  10889. * @param trigger defines the trigger index
  10890. * @returns a trigger name
  10891. */
  10892. static GetTriggerName(trigger: number): string;
  10893. }
  10894. }
  10895. declare module BABYLON {
  10896. /**
  10897. * Class representing a ray with position and direction
  10898. */
  10899. export class Ray {
  10900. /** origin point */
  10901. origin: Vector3;
  10902. /** direction */
  10903. direction: Vector3;
  10904. /** length of the ray */
  10905. length: number;
  10906. private static readonly _TmpVector3;
  10907. private _tmpRay;
  10908. /**
  10909. * Creates a new ray
  10910. * @param origin origin point
  10911. * @param direction direction
  10912. * @param length length of the ray
  10913. */
  10914. constructor(
  10915. /** origin point */
  10916. origin: Vector3,
  10917. /** direction */
  10918. direction: Vector3,
  10919. /** length of the ray */
  10920. length?: number);
  10921. /**
  10922. * Checks if the ray intersects a box
  10923. * This does not account for the ray length by design to improve perfs.
  10924. * @param minimum bound of the box
  10925. * @param maximum bound of the box
  10926. * @param intersectionTreshold extra extend to be added to the box in all direction
  10927. * @returns if the box was hit
  10928. */
  10929. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10930. /**
  10931. * Checks if the ray intersects a box
  10932. * This does not account for the ray lenght by design to improve perfs.
  10933. * @param box the bounding box to check
  10934. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10935. * @returns if the box was hit
  10936. */
  10937. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10938. /**
  10939. * If the ray hits a sphere
  10940. * @param sphere the bounding sphere to check
  10941. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10942. * @returns true if it hits the sphere
  10943. */
  10944. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10945. /**
  10946. * If the ray hits a triange
  10947. * @param vertex0 triangle vertex
  10948. * @param vertex1 triangle vertex
  10949. * @param vertex2 triangle vertex
  10950. * @returns intersection information if hit
  10951. */
  10952. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10953. /**
  10954. * Checks if ray intersects a plane
  10955. * @param plane the plane to check
  10956. * @returns the distance away it was hit
  10957. */
  10958. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10959. /**
  10960. * Calculate the intercept of a ray on a given axis
  10961. * @param axis to check 'x' | 'y' | 'z'
  10962. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10963. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10964. */
  10965. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10966. /**
  10967. * Checks if ray intersects a mesh
  10968. * @param mesh the mesh to check
  10969. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10970. * @returns picking info of the intersection
  10971. */
  10972. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10973. /**
  10974. * Checks if ray intersects a mesh
  10975. * @param meshes the meshes to check
  10976. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10977. * @param results array to store result in
  10978. * @returns Array of picking infos
  10979. */
  10980. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10981. private _comparePickingInfo;
  10982. private static smallnum;
  10983. private static rayl;
  10984. /**
  10985. * Intersection test between the ray and a given segment within a given tolerance (threshold)
  10986. * @param sega the first point of the segment to test the intersection against
  10987. * @param segb the second point of the segment to test the intersection against
  10988. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10989. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10990. */
  10991. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10992. /**
  10993. * Update the ray from viewport position
  10994. * @param x position
  10995. * @param y y position
  10996. * @param viewportWidth viewport width
  10997. * @param viewportHeight viewport height
  10998. * @param world world matrix
  10999. * @param view view matrix
  11000. * @param projection projection matrix
  11001. * @returns this ray updated
  11002. */
  11003. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11004. /**
  11005. * Creates a ray with origin and direction of 0,0,0
  11006. * @returns the new ray
  11007. */
  11008. static Zero(): Ray;
  11009. /**
  11010. * Creates a new ray from screen space and viewport
  11011. * @param x position
  11012. * @param y y position
  11013. * @param viewportWidth viewport width
  11014. * @param viewportHeight viewport height
  11015. * @param world world matrix
  11016. * @param view view matrix
  11017. * @param projection projection matrix
  11018. * @returns new ray
  11019. */
  11020. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11021. /**
  11022. * 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
  11023. * transformed to the given world matrix.
  11024. * @param origin The origin point
  11025. * @param end The end point
  11026. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11027. * @returns the new ray
  11028. */
  11029. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  11030. /**
  11031. * Transforms a ray by a matrix
  11032. * @param ray ray to transform
  11033. * @param matrix matrix to apply
  11034. * @returns the resulting new ray
  11035. */
  11036. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11037. /**
  11038. * Transforms a ray by a matrix
  11039. * @param ray ray to transform
  11040. * @param matrix matrix to apply
  11041. * @param result ray to store result in
  11042. */
  11043. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11044. /**
  11045. * Unproject a ray from screen space to object space
  11046. * @param sourceX defines the screen space x coordinate to use
  11047. * @param sourceY defines the screen space y coordinate to use
  11048. * @param viewportWidth defines the current width of the viewport
  11049. * @param viewportHeight defines the current height of the viewport
  11050. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11051. * @param view defines the view matrix to use
  11052. * @param projection defines the projection matrix to use
  11053. */
  11054. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11055. }
  11056. /**
  11057. * Type used to define predicate used to select faces when a mesh intersection is detected
  11058. */
  11059. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11060. interface Scene {
  11061. /** @hidden */
  11062. _tempPickingRay: Nullable<Ray>;
  11063. /** @hidden */
  11064. _cachedRayForTransform: Ray;
  11065. /** @hidden */
  11066. _pickWithRayInverseMatrix: Matrix;
  11067. /** @hidden */
  11068. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11069. /** @hidden */
  11070. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11071. /** @hidden */
  11072. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11073. }
  11074. }
  11075. declare module BABYLON {
  11076. /**
  11077. * Groups all the scene component constants in one place to ease maintenance.
  11078. * @hidden
  11079. */
  11080. export class SceneComponentConstants {
  11081. static readonly NAME_EFFECTLAYER: string;
  11082. static readonly NAME_LAYER: string;
  11083. static readonly NAME_LENSFLARESYSTEM: string;
  11084. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11085. static readonly NAME_PARTICLESYSTEM: string;
  11086. static readonly NAME_GAMEPAD: string;
  11087. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11088. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11089. static readonly NAME_PREPASSRENDERER: string;
  11090. static readonly NAME_DEPTHRENDERER: string;
  11091. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11092. static readonly NAME_SPRITE: string;
  11093. static readonly NAME_SUBSURFACE: string;
  11094. static readonly NAME_OUTLINERENDERER: string;
  11095. static readonly NAME_PROCEDURALTEXTURE: string;
  11096. static readonly NAME_SHADOWGENERATOR: string;
  11097. static readonly NAME_OCTREE: string;
  11098. static readonly NAME_PHYSICSENGINE: string;
  11099. static readonly NAME_AUDIO: string;
  11100. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11101. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11102. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11103. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11104. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11105. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11106. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11107. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11108. static readonly STEP_BEFORERENDERTARGETDRAW_PREPASS: number;
  11109. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11110. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11111. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11112. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11113. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11114. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11115. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11116. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11117. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11118. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11119. static readonly STEP_AFTERRENDERTARGETDRAW_PREPASS: number;
  11120. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11121. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11122. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11123. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11124. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11125. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11126. static readonly STEP_AFTERRENDER_AUDIO: number;
  11127. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11128. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11129. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11130. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11131. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11132. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11133. static readonly STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS: number;
  11134. static readonly STEP_POINTERMOVE_SPRITE: number;
  11135. static readonly STEP_POINTERDOWN_SPRITE: number;
  11136. static readonly STEP_POINTERUP_SPRITE: number;
  11137. }
  11138. /**
  11139. * This represents a scene component.
  11140. *
  11141. * This is used to decouple the dependency the scene is having on the different workloads like
  11142. * layers, post processes...
  11143. */
  11144. export interface ISceneComponent {
  11145. /**
  11146. * The name of the component. Each component must have a unique name.
  11147. */
  11148. name: string;
  11149. /**
  11150. * The scene the component belongs to.
  11151. */
  11152. scene: Scene;
  11153. /**
  11154. * Register the component to one instance of a scene.
  11155. */
  11156. register(): void;
  11157. /**
  11158. * Rebuilds the elements related to this component in case of
  11159. * context lost for instance.
  11160. */
  11161. rebuild(): void;
  11162. /**
  11163. * Disposes the component and the associated ressources.
  11164. */
  11165. dispose(): void;
  11166. }
  11167. /**
  11168. * This represents a SERIALIZABLE scene component.
  11169. *
  11170. * This extends Scene Component to add Serialization methods on top.
  11171. */
  11172. export interface ISceneSerializableComponent extends ISceneComponent {
  11173. /**
  11174. * Adds all the elements from the container to the scene
  11175. * @param container the container holding the elements
  11176. */
  11177. addFromContainer(container: AbstractScene): void;
  11178. /**
  11179. * Removes all the elements in the container from the scene
  11180. * @param container contains the elements to remove
  11181. * @param dispose if the removed element should be disposed (default: false)
  11182. */
  11183. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11184. /**
  11185. * Serializes the component data to the specified json object
  11186. * @param serializationObject The object to serialize to
  11187. */
  11188. serialize(serializationObject: any): void;
  11189. }
  11190. /**
  11191. * Strong typing of a Mesh related stage step action
  11192. */
  11193. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11194. /**
  11195. * Strong typing of a Evaluate Sub Mesh related stage step action
  11196. */
  11197. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11198. /**
  11199. * Strong typing of a pre active Mesh related stage step action
  11200. */
  11201. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11202. /**
  11203. * Strong typing of a Camera related stage step action
  11204. */
  11205. export type CameraStageAction = (camera: Camera) => void;
  11206. /**
  11207. * Strong typing of a Camera Frame buffer related stage step action
  11208. */
  11209. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11210. /**
  11211. * Strong typing of a Render Target related stage step action
  11212. */
  11213. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture, faceIndex?: number, layer?: number) => void;
  11214. /**
  11215. * Strong typing of a RenderingGroup related stage step action
  11216. */
  11217. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11218. /**
  11219. * Strong typing of a Mesh Render related stage step action
  11220. */
  11221. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11222. /**
  11223. * Strong typing of a simple stage step action
  11224. */
  11225. export type SimpleStageAction = () => void;
  11226. /**
  11227. * Strong typing of a render target action.
  11228. */
  11229. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11230. /**
  11231. * Strong typing of a pointer move action.
  11232. */
  11233. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11234. /**
  11235. * Strong typing of a pointer up/down action.
  11236. */
  11237. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11238. /**
  11239. * Representation of a stage in the scene (Basically a list of ordered steps)
  11240. * @hidden
  11241. */
  11242. export class Stage<T extends Function> extends Array<{
  11243. index: number;
  11244. component: ISceneComponent;
  11245. action: T;
  11246. }> {
  11247. /**
  11248. * Hide ctor from the rest of the world.
  11249. * @param items The items to add.
  11250. */
  11251. private constructor();
  11252. /**
  11253. * Creates a new Stage.
  11254. * @returns A new instance of a Stage
  11255. */
  11256. static Create<T extends Function>(): Stage<T>;
  11257. /**
  11258. * Registers a step in an ordered way in the targeted stage.
  11259. * @param index Defines the position to register the step in
  11260. * @param component Defines the component attached to the step
  11261. * @param action Defines the action to launch during the step
  11262. */
  11263. registerStep(index: number, component: ISceneComponent, action: T): void;
  11264. /**
  11265. * Clears all the steps from the stage.
  11266. */
  11267. clear(): void;
  11268. }
  11269. }
  11270. declare module BABYLON {
  11271. interface Scene {
  11272. /** @hidden */
  11273. _pointerOverSprite: Nullable<Sprite>;
  11274. /** @hidden */
  11275. _pickedDownSprite: Nullable<Sprite>;
  11276. /** @hidden */
  11277. _tempSpritePickingRay: Nullable<Ray>;
  11278. /**
  11279. * All of the sprite managers added to this scene
  11280. * @see https://doc.babylonjs.com/babylon101/sprites
  11281. */
  11282. spriteManagers: Array<ISpriteManager>;
  11283. /**
  11284. * An event triggered when sprites rendering is about to start
  11285. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11286. */
  11287. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11288. /**
  11289. * An event triggered when sprites rendering is done
  11290. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11291. */
  11292. onAfterSpritesRenderingObservable: Observable<Scene>;
  11293. /** @hidden */
  11294. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11295. /** Launch a ray to try to pick a sprite in the scene
  11296. * @param x position on screen
  11297. * @param y position on screen
  11298. * @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
  11299. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11300. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11301. * @returns a PickingInfo
  11302. */
  11303. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11304. /** Use the given ray to pick a sprite in the scene
  11305. * @param ray The ray (in world space) to use to pick meshes
  11306. * @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
  11307. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11308. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11309. * @returns a PickingInfo
  11310. */
  11311. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11312. /** @hidden */
  11313. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11314. /** Launch a ray to try to pick sprites in the scene
  11315. * @param x position on screen
  11316. * @param y position on screen
  11317. * @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
  11318. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11319. * @returns a PickingInfo array
  11320. */
  11321. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11322. /** Use the given ray to pick sprites in the scene
  11323. * @param ray The ray (in world space) to use to pick meshes
  11324. * @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
  11325. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11326. * @returns a PickingInfo array
  11327. */
  11328. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11329. /**
  11330. * Force the sprite under the pointer
  11331. * @param sprite defines the sprite to use
  11332. */
  11333. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11334. /**
  11335. * Gets the sprite under the pointer
  11336. * @returns a Sprite or null if no sprite is under the pointer
  11337. */
  11338. getPointerOverSprite(): Nullable<Sprite>;
  11339. }
  11340. /**
  11341. * Defines the sprite scene component responsible to manage sprites
  11342. * in a given scene.
  11343. */
  11344. export class SpriteSceneComponent implements ISceneComponent {
  11345. /**
  11346. * The component name helpfull to identify the component in the list of scene components.
  11347. */
  11348. readonly name: string;
  11349. /**
  11350. * The scene the component belongs to.
  11351. */
  11352. scene: Scene;
  11353. /** @hidden */
  11354. private _spritePredicate;
  11355. /**
  11356. * Creates a new instance of the component for the given scene
  11357. * @param scene Defines the scene to register the component in
  11358. */
  11359. constructor(scene: Scene);
  11360. /**
  11361. * Registers the component in a given scene
  11362. */
  11363. register(): void;
  11364. /**
  11365. * Rebuilds the elements related to this component in case of
  11366. * context lost for instance.
  11367. */
  11368. rebuild(): void;
  11369. /**
  11370. * Disposes the component and the associated resources.
  11371. */
  11372. dispose(): void;
  11373. private _pickSpriteButKeepRay;
  11374. private _pointerMove;
  11375. private _pointerDown;
  11376. private _pointerUp;
  11377. }
  11378. }
  11379. declare module BABYLON {
  11380. /**
  11381. * Class used to provide helper for timing
  11382. */
  11383. export class TimingTools {
  11384. /**
  11385. * Polyfill for setImmediate
  11386. * @param action defines the action to execute after the current execution block
  11387. */
  11388. static SetImmediate(action: () => void): void;
  11389. }
  11390. }
  11391. declare module BABYLON {
  11392. /**
  11393. * Class used to enable instantiation of objects by class name
  11394. */
  11395. export class InstantiationTools {
  11396. /**
  11397. * Use this object to register external classes like custom textures or material
  11398. * to allow the loaders to instantiate them
  11399. */
  11400. static RegisteredExternalClasses: {
  11401. [key: string]: Object;
  11402. };
  11403. /**
  11404. * Tries to instantiate a new object from a given class name
  11405. * @param className defines the class name to instantiate
  11406. * @returns the new object or null if the system was not able to do the instantiation
  11407. */
  11408. static Instantiate(className: string): any;
  11409. }
  11410. }
  11411. declare module BABYLON {
  11412. /**
  11413. * Class used to host copy specific utilities
  11414. */
  11415. export class CopyTools {
  11416. /**
  11417. * Transform some pixel data to a base64 string
  11418. * @param pixels defines the pixel data to transform to base64
  11419. * @param size defines the width and height of the (texture) data
  11420. * @param invertY true if the data must be inverted for the Y coordinate during the conversion
  11421. * @returns The base64 encoded string or null
  11422. */
  11423. static GenerateBase64StringFromPixelData(pixels: ArrayBufferView, size: ISize, invertY?: boolean): Nullable<string>;
  11424. /**
  11425. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11426. * @param texture defines the texture to read pixels from
  11427. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11428. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11429. * @returns The base64 encoded string or null
  11430. */
  11431. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  11432. /**
  11433. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11434. * @param texture defines the texture to read pixels from
  11435. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11436. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11437. * @returns The base64 encoded string or null wrapped in a promise
  11438. */
  11439. static GenerateBase64StringFromTextureAsync(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11440. }
  11441. }
  11442. declare module BABYLON {
  11443. /**
  11444. * Define options used to create a depth texture
  11445. */
  11446. export class DepthTextureCreationOptions {
  11447. /** Specifies whether or not a stencil should be allocated in the texture */
  11448. generateStencil?: boolean;
  11449. /** Specifies whether or not bilinear filtering is enable on the texture */
  11450. bilinearFiltering?: boolean;
  11451. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11452. comparisonFunction?: number;
  11453. /** Specifies if the created texture is a cube texture */
  11454. isCube?: boolean;
  11455. /** Specifies the sample count of the depth/stencil texture texture */
  11456. samples?: number;
  11457. }
  11458. }
  11459. declare module BABYLON {
  11460. interface ThinEngine {
  11461. /**
  11462. * Creates a depth stencil cube texture.
  11463. * This is only available in WebGL 2.
  11464. * @param size The size of face edge in the cube texture.
  11465. * @param options The options defining the cube texture.
  11466. * @returns The cube texture
  11467. */
  11468. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11469. /**
  11470. * Creates a cube texture
  11471. * @param rootUrl defines the url where the files to load is located
  11472. * @param scene defines the current scene
  11473. * @param files defines the list of files to load (1 per face)
  11474. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11475. * @param onLoad defines an optional callback raised when the texture is loaded
  11476. * @param onError defines an optional callback raised if there is an issue to load the texture
  11477. * @param format defines the format of the data
  11478. * @param forcedExtension defines the extension to use to pick the right loader
  11479. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11480. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11481. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11482. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11483. * @param loaderOptions options to be passed to the loader
  11484. * @returns the cube texture as an InternalTexture
  11485. */
  11486. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  11487. /**
  11488. * Creates a cube texture
  11489. * @param rootUrl defines the url where the files to load is located
  11490. * @param scene defines the current scene
  11491. * @param files defines the list of files to load (1 per face)
  11492. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11493. * @param onLoad defines an optional callback raised when the texture is loaded
  11494. * @param onError defines an optional callback raised if there is an issue to load the texture
  11495. * @param format defines the format of the data
  11496. * @param forcedExtension defines the extension to use to pick the right loader
  11497. * @returns the cube texture as an InternalTexture
  11498. */
  11499. 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 | undefined, forcedExtension: any): InternalTexture;
  11500. /**
  11501. * Creates a cube texture
  11502. * @param rootUrl defines the url where the files to load is located
  11503. * @param scene defines the current scene
  11504. * @param files defines the list of files to load (1 per face)
  11505. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11506. * @param onLoad defines an optional callback raised when the texture is loaded
  11507. * @param onError defines an optional callback raised if there is an issue to load the texture
  11508. * @param format defines the format of the data
  11509. * @param forcedExtension defines the extension to use to pick the right loader
  11510. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11511. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11512. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11513. * @returns the cube texture as an InternalTexture
  11514. */
  11515. 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 | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  11516. /** @hidden */
  11517. createCubeTextureBase(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void>, imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void>): InternalTexture;
  11518. /** @hidden */
  11519. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11520. /** @hidden */
  11521. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11522. /** @hidden */
  11523. _cascadeLoadImgs(scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11524. /** @hidden */
  11525. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11526. /**
  11527. * @hidden
  11528. */
  11529. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11530. }
  11531. }
  11532. declare module BABYLON {
  11533. /**
  11534. * Class for creating a cube texture
  11535. */
  11536. export class CubeTexture extends BaseTexture {
  11537. private _delayedOnLoad;
  11538. /**
  11539. * Observable triggered once the texture has been loaded.
  11540. */
  11541. onLoadObservable: Observable<CubeTexture>;
  11542. /**
  11543. * The url of the texture
  11544. */
  11545. url: string;
  11546. /**
  11547. * Gets or sets the center of the bounding box associated with the cube texture.
  11548. * It must define where the camera used to render the texture was set
  11549. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11550. */
  11551. boundingBoxPosition: Vector3;
  11552. private _boundingBoxSize;
  11553. /**
  11554. * Gets or sets the size of the bounding box associated with the cube texture
  11555. * When defined, the cubemap will switch to local mode
  11556. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11557. * @example https://www.babylonjs-playground.com/#RNASML
  11558. */
  11559. set boundingBoxSize(value: Vector3);
  11560. /**
  11561. * Returns the bounding box size
  11562. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11563. */
  11564. get boundingBoxSize(): Vector3;
  11565. protected _rotationY: number;
  11566. /**
  11567. * Sets texture matrix rotation angle around Y axis in radians.
  11568. */
  11569. set rotationY(value: number);
  11570. /**
  11571. * Gets texture matrix rotation angle around Y axis radians.
  11572. */
  11573. get rotationY(): number;
  11574. /**
  11575. * Are mip maps generated for this texture or not.
  11576. */
  11577. get noMipmap(): boolean;
  11578. private _noMipmap;
  11579. private _files;
  11580. protected _forcedExtension: Nullable<string>;
  11581. private _extensions;
  11582. private _textureMatrix;
  11583. private _format;
  11584. private _createPolynomials;
  11585. private _loaderOptions;
  11586. /**
  11587. * Creates a cube texture from an array of image urls
  11588. * @param files defines an array of image urls
  11589. * @param scene defines the hosting scene
  11590. * @param noMipmap specifies if mip maps are not used
  11591. * @returns a cube texture
  11592. */
  11593. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11594. /**
  11595. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11596. * @param url defines the url of the prefiltered texture
  11597. * @param scene defines the scene the texture is attached to
  11598. * @param forcedExtension defines the extension of the file if different from the url
  11599. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11600. * @return the prefiltered texture
  11601. */
  11602. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11603. /**
  11604. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11605. * as prefiltered data.
  11606. * @param rootUrl defines the url of the texture or the root name of the six images
  11607. * @param null defines the scene or engine the texture is attached to
  11608. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11609. * @param noMipmap defines if mipmaps should be created or not
  11610. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11611. * @param onLoad defines a callback triggered at the end of the file load if no errors occurred
  11612. * @param onError defines a callback triggered in case of error during load
  11613. * @param format defines the internal format to use for the texture once loaded
  11614. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11615. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11616. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11617. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11618. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11619. * @param loaderOptions options to be passed to the loader
  11620. * @return the cube texture
  11621. */
  11622. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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, loaderOptions?: any);
  11623. /**
  11624. * Get the current class name of the texture useful for serialization or dynamic coding.
  11625. * @returns "CubeTexture"
  11626. */
  11627. getClassName(): string;
  11628. /**
  11629. * Update the url (and optional buffer) of this texture if url was null during construction.
  11630. * @param url the url of the texture
  11631. * @param forcedExtension defines the extension to use
  11632. * @param onLoad callback called when the texture is loaded (defaults to null)
  11633. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11634. */
  11635. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11636. /**
  11637. * Delays loading of the cube texture
  11638. * @param forcedExtension defines the extension to use
  11639. */
  11640. delayLoad(forcedExtension?: string): void;
  11641. /**
  11642. * Returns the reflection texture matrix
  11643. * @returns the reflection texture matrix
  11644. */
  11645. getReflectionTextureMatrix(): Matrix;
  11646. /**
  11647. * Sets the reflection texture matrix
  11648. * @param value Reflection texture matrix
  11649. */
  11650. setReflectionTextureMatrix(value: Matrix): void;
  11651. /**
  11652. * Parses text to create a cube texture
  11653. * @param parsedTexture define the serialized text to read from
  11654. * @param scene defines the hosting scene
  11655. * @param rootUrl defines the root url of the cube texture
  11656. * @returns a cube texture
  11657. */
  11658. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11659. /**
  11660. * Makes a clone, or deep copy, of the cube texture
  11661. * @returns a new cube texture
  11662. */
  11663. clone(): CubeTexture;
  11664. }
  11665. }
  11666. declare module BABYLON {
  11667. /**
  11668. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  11669. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11670. * 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;
  11671. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11672. */
  11673. export class ColorCurves {
  11674. private _dirty;
  11675. private _tempColor;
  11676. private _globalCurve;
  11677. private _highlightsCurve;
  11678. private _midtonesCurve;
  11679. private _shadowsCurve;
  11680. private _positiveCurve;
  11681. private _negativeCurve;
  11682. private _globalHue;
  11683. private _globalDensity;
  11684. private _globalSaturation;
  11685. private _globalExposure;
  11686. /**
  11687. * Gets the global Hue value.
  11688. * 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).
  11689. */
  11690. get globalHue(): number;
  11691. /**
  11692. * Sets the global Hue value.
  11693. * 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).
  11694. */
  11695. set globalHue(value: number);
  11696. /**
  11697. * Gets the global Density value.
  11698. * 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.
  11699. * Values less than zero provide a filter of opposite hue.
  11700. */
  11701. get globalDensity(): number;
  11702. /**
  11703. * Sets the global Density value.
  11704. * 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.
  11705. * Values less than zero provide a filter of opposite hue.
  11706. */
  11707. set globalDensity(value: number);
  11708. /**
  11709. * Gets the global Saturation value.
  11710. * 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.
  11711. */
  11712. get globalSaturation(): number;
  11713. /**
  11714. * Sets the global Saturation value.
  11715. * 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.
  11716. */
  11717. set globalSaturation(value: number);
  11718. /**
  11719. * Gets the global Exposure value.
  11720. * 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.
  11721. */
  11722. get globalExposure(): number;
  11723. /**
  11724. * Sets the global Exposure value.
  11725. * 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.
  11726. */
  11727. set globalExposure(value: number);
  11728. private _highlightsHue;
  11729. private _highlightsDensity;
  11730. private _highlightsSaturation;
  11731. private _highlightsExposure;
  11732. /**
  11733. * Gets the highlights Hue value.
  11734. * 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).
  11735. */
  11736. get highlightsHue(): number;
  11737. /**
  11738. * Sets the highlights Hue value.
  11739. * 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).
  11740. */
  11741. set highlightsHue(value: number);
  11742. /**
  11743. * Gets the highlights Density value.
  11744. * 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.
  11745. * Values less than zero provide a filter of opposite hue.
  11746. */
  11747. get highlightsDensity(): number;
  11748. /**
  11749. * Sets the highlights Density value.
  11750. * 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.
  11751. * Values less than zero provide a filter of opposite hue.
  11752. */
  11753. set highlightsDensity(value: number);
  11754. /**
  11755. * Gets the highlights Saturation value.
  11756. * 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.
  11757. */
  11758. get highlightsSaturation(): number;
  11759. /**
  11760. * Sets the highlights Saturation value.
  11761. * 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.
  11762. */
  11763. set highlightsSaturation(value: number);
  11764. /**
  11765. * Gets the highlights Exposure value.
  11766. * 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.
  11767. */
  11768. get highlightsExposure(): number;
  11769. /**
  11770. * Sets the highlights Exposure value.
  11771. * 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.
  11772. */
  11773. set highlightsExposure(value: number);
  11774. private _midtonesHue;
  11775. private _midtonesDensity;
  11776. private _midtonesSaturation;
  11777. private _midtonesExposure;
  11778. /**
  11779. * Gets the midtones Hue value.
  11780. * 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).
  11781. */
  11782. get midtonesHue(): number;
  11783. /**
  11784. * Sets the midtones Hue value.
  11785. * 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).
  11786. */
  11787. set midtonesHue(value: number);
  11788. /**
  11789. * Gets the midtones Density value.
  11790. * 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.
  11791. * Values less than zero provide a filter of opposite hue.
  11792. */
  11793. get midtonesDensity(): number;
  11794. /**
  11795. * Sets the midtones Density value.
  11796. * 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.
  11797. * Values less than zero provide a filter of opposite hue.
  11798. */
  11799. set midtonesDensity(value: number);
  11800. /**
  11801. * Gets the midtones Saturation value.
  11802. * 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.
  11803. */
  11804. get midtonesSaturation(): number;
  11805. /**
  11806. * Sets the midtones Saturation value.
  11807. * 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.
  11808. */
  11809. set midtonesSaturation(value: number);
  11810. /**
  11811. * Gets the midtones Exposure value.
  11812. * 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.
  11813. */
  11814. get midtonesExposure(): number;
  11815. /**
  11816. * Sets the midtones Exposure value.
  11817. * 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.
  11818. */
  11819. set midtonesExposure(value: number);
  11820. private _shadowsHue;
  11821. private _shadowsDensity;
  11822. private _shadowsSaturation;
  11823. private _shadowsExposure;
  11824. /**
  11825. * Gets the shadows Hue value.
  11826. * 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).
  11827. */
  11828. get shadowsHue(): number;
  11829. /**
  11830. * Sets the shadows Hue value.
  11831. * 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).
  11832. */
  11833. set shadowsHue(value: number);
  11834. /**
  11835. * Gets the shadows Density value.
  11836. * 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.
  11837. * Values less than zero provide a filter of opposite hue.
  11838. */
  11839. get shadowsDensity(): number;
  11840. /**
  11841. * Sets the shadows Density value.
  11842. * 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.
  11843. * Values less than zero provide a filter of opposite hue.
  11844. */
  11845. set shadowsDensity(value: number);
  11846. /**
  11847. * Gets the shadows Saturation value.
  11848. * 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.
  11849. */
  11850. get shadowsSaturation(): number;
  11851. /**
  11852. * Sets the shadows Saturation value.
  11853. * 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.
  11854. */
  11855. set shadowsSaturation(value: number);
  11856. /**
  11857. * Gets the shadows Exposure value.
  11858. * 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.
  11859. */
  11860. get shadowsExposure(): number;
  11861. /**
  11862. * Sets the shadows Exposure value.
  11863. * 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.
  11864. */
  11865. set shadowsExposure(value: number);
  11866. /**
  11867. * Returns the class name
  11868. * @returns The class name
  11869. */
  11870. getClassName(): string;
  11871. /**
  11872. * Binds the color curves to the shader.
  11873. * @param colorCurves The color curve to bind
  11874. * @param effect The effect to bind to
  11875. * @param positiveUniform The positive uniform shader parameter
  11876. * @param neutralUniform The neutral uniform shader parameter
  11877. * @param negativeUniform The negative uniform shader parameter
  11878. */
  11879. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11880. /**
  11881. * Prepare the list of uniforms associated with the ColorCurves effects.
  11882. * @param uniformsList The list of uniforms used in the effect
  11883. */
  11884. static PrepareUniforms(uniformsList: string[]): void;
  11885. /**
  11886. * Returns color grading data based on a hue, density, saturation and exposure value.
  11887. * @param filterHue The hue of the color filter.
  11888. * @param filterDensity The density of the color filter.
  11889. * @param saturation The saturation.
  11890. * @param exposure The exposure.
  11891. * @param result The result data container.
  11892. */
  11893. private getColorGradingDataToRef;
  11894. /**
  11895. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11896. * @param value The input slider value in range [-100,100].
  11897. * @returns Adjusted value.
  11898. */
  11899. private static applyColorGradingSliderNonlinear;
  11900. /**
  11901. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11902. * @param hue The hue (H) input.
  11903. * @param saturation The saturation (S) input.
  11904. * @param brightness The brightness (B) input.
  11905. * @result An RGBA color represented as Vector4.
  11906. */
  11907. private static fromHSBToRef;
  11908. /**
  11909. * Returns a value clamped between min and max
  11910. * @param value The value to clamp
  11911. * @param min The minimum of value
  11912. * @param max The maximum of value
  11913. * @returns The clamped value.
  11914. */
  11915. private static clamp;
  11916. /**
  11917. * Clones the current color curve instance.
  11918. * @return The cloned curves
  11919. */
  11920. clone(): ColorCurves;
  11921. /**
  11922. * Serializes the current color curve instance to a json representation.
  11923. * @return a JSON representation
  11924. */
  11925. serialize(): any;
  11926. /**
  11927. * Parses the color curve from a json representation.
  11928. * @param source the JSON source to parse
  11929. * @return The parsed curves
  11930. */
  11931. static Parse(source: any): ColorCurves;
  11932. }
  11933. }
  11934. declare module BABYLON {
  11935. /**
  11936. * Interface to follow in your material defines to integrate easily the
  11937. * Image processing functions.
  11938. * @hidden
  11939. */
  11940. export interface IImageProcessingConfigurationDefines {
  11941. IMAGEPROCESSING: boolean;
  11942. VIGNETTE: boolean;
  11943. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11944. VIGNETTEBLENDMODEOPAQUE: boolean;
  11945. TONEMAPPING: boolean;
  11946. TONEMAPPING_ACES: boolean;
  11947. CONTRAST: boolean;
  11948. EXPOSURE: boolean;
  11949. COLORCURVES: boolean;
  11950. COLORGRADING: boolean;
  11951. COLORGRADING3D: boolean;
  11952. SAMPLER3DGREENDEPTH: boolean;
  11953. SAMPLER3DBGRMAP: boolean;
  11954. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11955. }
  11956. /**
  11957. * @hidden
  11958. */
  11959. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11960. IMAGEPROCESSING: boolean;
  11961. VIGNETTE: boolean;
  11962. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11963. VIGNETTEBLENDMODEOPAQUE: boolean;
  11964. TONEMAPPING: boolean;
  11965. TONEMAPPING_ACES: boolean;
  11966. CONTRAST: boolean;
  11967. COLORCURVES: boolean;
  11968. COLORGRADING: boolean;
  11969. COLORGRADING3D: boolean;
  11970. SAMPLER3DGREENDEPTH: boolean;
  11971. SAMPLER3DBGRMAP: boolean;
  11972. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11973. EXPOSURE: boolean;
  11974. constructor();
  11975. }
  11976. /**
  11977. * This groups together the common properties used for image processing either in direct forward pass
  11978. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11979. * or not.
  11980. */
  11981. export class ImageProcessingConfiguration {
  11982. /**
  11983. * Default tone mapping applied in BabylonJS.
  11984. */
  11985. static readonly TONEMAPPING_STANDARD: number;
  11986. /**
  11987. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11988. * to other engines rendering to increase portability.
  11989. */
  11990. static readonly TONEMAPPING_ACES: number;
  11991. /**
  11992. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11993. */
  11994. colorCurves: Nullable<ColorCurves>;
  11995. private _colorCurvesEnabled;
  11996. /**
  11997. * Gets whether the color curves effect is enabled.
  11998. */
  11999. get colorCurvesEnabled(): boolean;
  12000. /**
  12001. * Sets whether the color curves effect is enabled.
  12002. */
  12003. set colorCurvesEnabled(value: boolean);
  12004. private _colorGradingTexture;
  12005. /**
  12006. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12007. */
  12008. get colorGradingTexture(): Nullable<BaseTexture>;
  12009. /**
  12010. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12011. */
  12012. set colorGradingTexture(value: Nullable<BaseTexture>);
  12013. private _colorGradingEnabled;
  12014. /**
  12015. * Gets whether the color grading effect is enabled.
  12016. */
  12017. get colorGradingEnabled(): boolean;
  12018. /**
  12019. * Sets whether the color grading effect is enabled.
  12020. */
  12021. set colorGradingEnabled(value: boolean);
  12022. private _colorGradingWithGreenDepth;
  12023. /**
  12024. * Gets whether the color grading effect is using a green depth for the 3d Texture.
  12025. */
  12026. get colorGradingWithGreenDepth(): boolean;
  12027. /**
  12028. * Sets whether the color grading effect is using a green depth for the 3d Texture.
  12029. */
  12030. set colorGradingWithGreenDepth(value: boolean);
  12031. private _colorGradingBGR;
  12032. /**
  12033. * Gets whether the color grading texture contains BGR values.
  12034. */
  12035. get colorGradingBGR(): boolean;
  12036. /**
  12037. * Sets whether the color grading texture contains BGR values.
  12038. */
  12039. set colorGradingBGR(value: boolean);
  12040. /** @hidden */
  12041. _exposure: number;
  12042. /**
  12043. * Gets the Exposure used in the effect.
  12044. */
  12045. get exposure(): number;
  12046. /**
  12047. * Sets the Exposure used in the effect.
  12048. */
  12049. set exposure(value: number);
  12050. private _toneMappingEnabled;
  12051. /**
  12052. * Gets whether the tone mapping effect is enabled.
  12053. */
  12054. get toneMappingEnabled(): boolean;
  12055. /**
  12056. * Sets whether the tone mapping effect is enabled.
  12057. */
  12058. set toneMappingEnabled(value: boolean);
  12059. private _toneMappingType;
  12060. /**
  12061. * Gets the type of tone mapping effect.
  12062. */
  12063. get toneMappingType(): number;
  12064. /**
  12065. * Sets the type of tone mapping effect used in BabylonJS.
  12066. */
  12067. set toneMappingType(value: number);
  12068. protected _contrast: number;
  12069. /**
  12070. * Gets the contrast used in the effect.
  12071. */
  12072. get contrast(): number;
  12073. /**
  12074. * Sets the contrast used in the effect.
  12075. */
  12076. set contrast(value: number);
  12077. /**
  12078. * Vignette stretch size.
  12079. */
  12080. vignetteStretch: number;
  12081. /**
  12082. * Vignette centre X Offset.
  12083. */
  12084. vignetteCentreX: number;
  12085. /**
  12086. * Vignette centre Y Offset.
  12087. */
  12088. vignetteCentreY: number;
  12089. /**
  12090. * Vignette weight or intensity of the vignette effect.
  12091. */
  12092. vignetteWeight: number;
  12093. /**
  12094. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12095. * if vignetteEnabled is set to true.
  12096. */
  12097. vignetteColor: Color4;
  12098. /**
  12099. * Camera field of view used by the Vignette effect.
  12100. */
  12101. vignetteCameraFov: number;
  12102. private _vignetteBlendMode;
  12103. /**
  12104. * Gets the vignette blend mode allowing different kind of effect.
  12105. */
  12106. get vignetteBlendMode(): number;
  12107. /**
  12108. * Sets the vignette blend mode allowing different kind of effect.
  12109. */
  12110. set vignetteBlendMode(value: number);
  12111. private _vignetteEnabled;
  12112. /**
  12113. * Gets whether the vignette effect is enabled.
  12114. */
  12115. get vignetteEnabled(): boolean;
  12116. /**
  12117. * Sets whether the vignette effect is enabled.
  12118. */
  12119. set vignetteEnabled(value: boolean);
  12120. private _applyByPostProcess;
  12121. /**
  12122. * Gets whether the image processing is applied through a post process or not.
  12123. */
  12124. get applyByPostProcess(): boolean;
  12125. /**
  12126. * Sets whether the image processing is applied through a post process or not.
  12127. */
  12128. set applyByPostProcess(value: boolean);
  12129. private _isEnabled;
  12130. /**
  12131. * Gets whether the image processing is enabled or not.
  12132. */
  12133. get isEnabled(): boolean;
  12134. /**
  12135. * Sets whether the image processing is enabled or not.
  12136. */
  12137. set isEnabled(value: boolean);
  12138. /**
  12139. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12140. */
  12141. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12142. /**
  12143. * Method called each time the image processing information changes requires to recompile the effect.
  12144. */
  12145. protected _updateParameters(): void;
  12146. /**
  12147. * Gets the current class name.
  12148. * @return "ImageProcessingConfiguration"
  12149. */
  12150. getClassName(): string;
  12151. /**
  12152. * Prepare the list of uniforms associated with the Image Processing effects.
  12153. * @param uniforms The list of uniforms used in the effect
  12154. * @param defines the list of defines currently in use
  12155. */
  12156. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12157. /**
  12158. * Prepare the list of samplers associated with the Image Processing effects.
  12159. * @param samplersList The list of uniforms used in the effect
  12160. * @param defines the list of defines currently in use
  12161. */
  12162. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12163. /**
  12164. * Prepare the list of defines associated to the shader.
  12165. * @param defines the list of defines to complete
  12166. * @param forPostProcess Define if we are currently in post process mode or not
  12167. */
  12168. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12169. /**
  12170. * Returns true if all the image processing information are ready.
  12171. * @returns True if ready, otherwise, false
  12172. */
  12173. isReady(): boolean;
  12174. /**
  12175. * Binds the image processing to the shader.
  12176. * @param effect The effect to bind to
  12177. * @param overrideAspectRatio Override the aspect ratio of the effect
  12178. */
  12179. bind(effect: Effect, overrideAspectRatio?: number): void;
  12180. /**
  12181. * Clones the current image processing instance.
  12182. * @return The cloned image processing
  12183. */
  12184. clone(): ImageProcessingConfiguration;
  12185. /**
  12186. * Serializes the current image processing instance to a json representation.
  12187. * @return a JSON representation
  12188. */
  12189. serialize(): any;
  12190. /**
  12191. * Parses the image processing from a json representation.
  12192. * @param source the JSON source to parse
  12193. * @return The parsed image processing
  12194. */
  12195. static Parse(source: any): ImageProcessingConfiguration;
  12196. private static _VIGNETTEMODE_MULTIPLY;
  12197. private static _VIGNETTEMODE_OPAQUE;
  12198. /**
  12199. * Used to apply the vignette as a mix with the pixel color.
  12200. */
  12201. static get VIGNETTEMODE_MULTIPLY(): number;
  12202. /**
  12203. * Used to apply the vignette as a replacement of the pixel color.
  12204. */
  12205. static get VIGNETTEMODE_OPAQUE(): number;
  12206. }
  12207. }
  12208. declare module BABYLON {
  12209. /** @hidden */
  12210. export var postprocessVertexShader: {
  12211. name: string;
  12212. shader: string;
  12213. };
  12214. }
  12215. declare module BABYLON {
  12216. /**
  12217. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12218. */
  12219. export type RenderTargetTextureSize = number | {
  12220. width: number;
  12221. height: number;
  12222. layers?: number;
  12223. };
  12224. interface ThinEngine {
  12225. /**
  12226. * Creates a new render target texture
  12227. * @param size defines the size of the texture
  12228. * @param options defines the options used to create the texture
  12229. * @returns a new render target texture stored in an InternalTexture
  12230. */
  12231. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12232. /**
  12233. * Creates a depth stencil texture.
  12234. * This is only available in WebGL 2 or with the depth texture extension available.
  12235. * @param size The size of face edge in the texture.
  12236. * @param options The options defining the texture.
  12237. * @returns The texture
  12238. */
  12239. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12240. /** @hidden */
  12241. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12242. }
  12243. }
  12244. declare module BABYLON {
  12245. /**
  12246. * Defines the kind of connection point for node based material
  12247. */
  12248. export enum NodeMaterialBlockConnectionPointTypes {
  12249. /** Float */
  12250. Float = 1,
  12251. /** Int */
  12252. Int = 2,
  12253. /** Vector2 */
  12254. Vector2 = 4,
  12255. /** Vector3 */
  12256. Vector3 = 8,
  12257. /** Vector4 */
  12258. Vector4 = 16,
  12259. /** Color3 */
  12260. Color3 = 32,
  12261. /** Color4 */
  12262. Color4 = 64,
  12263. /** Matrix */
  12264. Matrix = 128,
  12265. /** Custom object */
  12266. Object = 256,
  12267. /** Detect type based on connection */
  12268. AutoDetect = 1024,
  12269. /** Output type that will be defined by input type */
  12270. BasedOnInput = 2048
  12271. }
  12272. }
  12273. declare module BABYLON {
  12274. /**
  12275. * Enum used to define the target of a block
  12276. */
  12277. export enum NodeMaterialBlockTargets {
  12278. /** Vertex shader */
  12279. Vertex = 1,
  12280. /** Fragment shader */
  12281. Fragment = 2,
  12282. /** Neutral */
  12283. Neutral = 4,
  12284. /** Vertex and Fragment */
  12285. VertexAndFragment = 3
  12286. }
  12287. }
  12288. declare module BABYLON {
  12289. /**
  12290. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12291. */
  12292. export enum NodeMaterialBlockConnectionPointMode {
  12293. /** Value is an uniform */
  12294. Uniform = 0,
  12295. /** Value is a mesh attribute */
  12296. Attribute = 1,
  12297. /** Value is a varying between vertex and fragment shaders */
  12298. Varying = 2,
  12299. /** Mode is undefined */
  12300. Undefined = 3
  12301. }
  12302. }
  12303. declare module BABYLON {
  12304. /**
  12305. * Enum used to define system values e.g. values automatically provided by the system
  12306. */
  12307. export enum NodeMaterialSystemValues {
  12308. /** World */
  12309. World = 1,
  12310. /** View */
  12311. View = 2,
  12312. /** Projection */
  12313. Projection = 3,
  12314. /** ViewProjection */
  12315. ViewProjection = 4,
  12316. /** WorldView */
  12317. WorldView = 5,
  12318. /** WorldViewProjection */
  12319. WorldViewProjection = 6,
  12320. /** CameraPosition */
  12321. CameraPosition = 7,
  12322. /** Fog Color */
  12323. FogColor = 8,
  12324. /** Delta time */
  12325. DeltaTime = 9
  12326. }
  12327. }
  12328. declare module BABYLON {
  12329. /**
  12330. * Represents a camera frustum
  12331. */
  12332. export class Frustum {
  12333. /**
  12334. * Gets the planes representing the frustum
  12335. * @param transform matrix to be applied to the returned planes
  12336. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12337. */
  12338. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12339. /**
  12340. * Gets the near frustum plane transformed by the transform matrix
  12341. * @param transform transformation matrix to be applied to the resulting frustum plane
  12342. * @param frustumPlane the resuling frustum plane
  12343. */
  12344. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12345. /**
  12346. * Gets the far frustum plane transformed by the transform matrix
  12347. * @param transform transformation matrix to be applied to the resulting frustum plane
  12348. * @param frustumPlane the resuling frustum plane
  12349. */
  12350. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12351. /**
  12352. * Gets the left frustum plane transformed by the transform matrix
  12353. * @param transform transformation matrix to be applied to the resulting frustum plane
  12354. * @param frustumPlane the resuling frustum plane
  12355. */
  12356. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12357. /**
  12358. * Gets the right frustum plane transformed by the transform matrix
  12359. * @param transform transformation matrix to be applied to the resulting frustum plane
  12360. * @param frustumPlane the resuling frustum plane
  12361. */
  12362. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12363. /**
  12364. * Gets the top frustum plane transformed by the transform matrix
  12365. * @param transform transformation matrix to be applied to the resulting frustum plane
  12366. * @param frustumPlane the resuling frustum plane
  12367. */
  12368. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12369. /**
  12370. * Gets the bottom frustum plane transformed by the transform matrix
  12371. * @param transform transformation matrix to be applied to the resulting frustum plane
  12372. * @param frustumPlane the resuling frustum plane
  12373. */
  12374. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12375. /**
  12376. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12377. * @param transform transformation matrix to be applied to the resulting frustum planes
  12378. * @param frustumPlanes the resuling frustum planes
  12379. */
  12380. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12381. }
  12382. }
  12383. declare module BABYLON {
  12384. /**
  12385. * Contains position and normal vectors for a vertex
  12386. */
  12387. export class PositionNormalVertex {
  12388. /** the position of the vertex (defaut: 0,0,0) */
  12389. position: Vector3;
  12390. /** the normal of the vertex (defaut: 0,1,0) */
  12391. normal: Vector3;
  12392. /**
  12393. * Creates a PositionNormalVertex
  12394. * @param position the position of the vertex (defaut: 0,0,0)
  12395. * @param normal the normal of the vertex (defaut: 0,1,0)
  12396. */
  12397. constructor(
  12398. /** the position of the vertex (defaut: 0,0,0) */
  12399. position?: Vector3,
  12400. /** the normal of the vertex (defaut: 0,1,0) */
  12401. normal?: Vector3);
  12402. /**
  12403. * Clones the PositionNormalVertex
  12404. * @returns the cloned PositionNormalVertex
  12405. */
  12406. clone(): PositionNormalVertex;
  12407. }
  12408. /**
  12409. * Contains position, normal and uv vectors for a vertex
  12410. */
  12411. export class PositionNormalTextureVertex {
  12412. /** the position of the vertex (defaut: 0,0,0) */
  12413. position: Vector3;
  12414. /** the normal of the vertex (defaut: 0,1,0) */
  12415. normal: Vector3;
  12416. /** the uv of the vertex (default: 0,0) */
  12417. uv: Vector2;
  12418. /**
  12419. * Creates a PositionNormalTextureVertex
  12420. * @param position the position of the vertex (defaut: 0,0,0)
  12421. * @param normal the normal of the vertex (defaut: 0,1,0)
  12422. * @param uv the uv of the vertex (default: 0,0)
  12423. */
  12424. constructor(
  12425. /** the position of the vertex (defaut: 0,0,0) */
  12426. position?: Vector3,
  12427. /** the normal of the vertex (defaut: 0,1,0) */
  12428. normal?: Vector3,
  12429. /** the uv of the vertex (default: 0,0) */
  12430. uv?: Vector2);
  12431. /**
  12432. * Clones the PositionNormalTextureVertex
  12433. * @returns the cloned PositionNormalTextureVertex
  12434. */
  12435. clone(): PositionNormalTextureVertex;
  12436. }
  12437. }
  12438. declare module BABYLON {
  12439. /**
  12440. * Enum defining the type of animations supported by InputBlock
  12441. */
  12442. export enum AnimatedInputBlockTypes {
  12443. /** No animation */
  12444. None = 0,
  12445. /** Time based animation. Will only work for floats */
  12446. Time = 1
  12447. }
  12448. }
  12449. declare module BABYLON {
  12450. /**
  12451. * Block used to expose an input value
  12452. */
  12453. export class InputBlock extends NodeMaterialBlock {
  12454. private _mode;
  12455. private _associatedVariableName;
  12456. private _storedValue;
  12457. private _valueCallback;
  12458. private _type;
  12459. private _animationType;
  12460. /** Gets or set a value used to limit the range of float values */
  12461. min: number;
  12462. /** Gets or set a value used to limit the range of float values */
  12463. max: number;
  12464. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12465. isBoolean: boolean;
  12466. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12467. matrixMode: number;
  12468. /** @hidden */
  12469. _systemValue: Nullable<NodeMaterialSystemValues>;
  12470. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12471. isConstant: boolean;
  12472. /** Gets or sets the group to use to display this block in the Inspector */
  12473. groupInInspector: string;
  12474. /** Gets an observable raised when the value is changed */
  12475. onValueChangedObservable: Observable<InputBlock>;
  12476. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12477. convertToGammaSpace: boolean;
  12478. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12479. convertToLinearSpace: boolean;
  12480. /**
  12481. * Gets or sets the connection point type (default is float)
  12482. */
  12483. get type(): NodeMaterialBlockConnectionPointTypes;
  12484. /**
  12485. * Creates a new InputBlock
  12486. * @param name defines the block name
  12487. * @param target defines the target of that block (Vertex by default)
  12488. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12489. */
  12490. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12491. /**
  12492. * Validates if a name is a reserve word.
  12493. * @param newName the new name to be given to the node.
  12494. * @returns false if the name is a reserve word, else true.
  12495. */
  12496. validateBlockName(newName: string): boolean;
  12497. /**
  12498. * Gets the output component
  12499. */
  12500. get output(): NodeMaterialConnectionPoint;
  12501. /**
  12502. * Set the source of this connection point to a vertex attribute
  12503. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12504. * @returns the current connection point
  12505. */
  12506. setAsAttribute(attributeName?: string): InputBlock;
  12507. /**
  12508. * Set the source of this connection point to a system value
  12509. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12510. * @returns the current connection point
  12511. */
  12512. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12513. /**
  12514. * Gets or sets the value of that point.
  12515. * Please note that this value will be ignored if valueCallback is defined
  12516. */
  12517. get value(): any;
  12518. set value(value: any);
  12519. /**
  12520. * Gets or sets a callback used to get the value of that point.
  12521. * Please note that setting this value will force the connection point to ignore the value property
  12522. */
  12523. get valueCallback(): () => any;
  12524. set valueCallback(value: () => any);
  12525. /**
  12526. * Gets or sets the associated variable name in the shader
  12527. */
  12528. get associatedVariableName(): string;
  12529. set associatedVariableName(value: string);
  12530. /** Gets or sets the type of animation applied to the input */
  12531. get animationType(): AnimatedInputBlockTypes;
  12532. set animationType(value: AnimatedInputBlockTypes);
  12533. /**
  12534. * Gets a boolean indicating that this connection point not defined yet
  12535. */
  12536. get isUndefined(): boolean;
  12537. /**
  12538. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12539. * In this case the connection point name must be the name of the uniform to use.
  12540. * Can only be set on inputs
  12541. */
  12542. get isUniform(): boolean;
  12543. set isUniform(value: boolean);
  12544. /**
  12545. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12546. * In this case the connection point name must be the name of the attribute to use
  12547. * Can only be set on inputs
  12548. */
  12549. get isAttribute(): boolean;
  12550. set isAttribute(value: boolean);
  12551. /**
  12552. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12553. * Can only be set on exit points
  12554. */
  12555. get isVarying(): boolean;
  12556. set isVarying(value: boolean);
  12557. /**
  12558. * Gets a boolean indicating that the current connection point is a system value
  12559. */
  12560. get isSystemValue(): boolean;
  12561. /**
  12562. * Gets or sets the current well known value or null if not defined as a system value
  12563. */
  12564. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12565. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12566. /**
  12567. * Gets the current class name
  12568. * @returns the class name
  12569. */
  12570. getClassName(): string;
  12571. /**
  12572. * Animate the input if animationType !== None
  12573. * @param scene defines the rendering scene
  12574. */
  12575. animate(scene: Scene): void;
  12576. private _emitDefine;
  12577. initialize(state: NodeMaterialBuildState): void;
  12578. /**
  12579. * Set the input block to its default value (based on its type)
  12580. */
  12581. setDefaultValue(): void;
  12582. private _emitConstant;
  12583. /** @hidden */
  12584. get _noContextSwitch(): boolean;
  12585. private _emit;
  12586. /** @hidden */
  12587. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12588. /** @hidden */
  12589. _transmit(effect: Effect, scene: Scene): void;
  12590. protected _buildBlock(state: NodeMaterialBuildState): void;
  12591. protected _dumpPropertiesCode(): string;
  12592. dispose(): void;
  12593. serialize(): any;
  12594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12595. }
  12596. }
  12597. declare module BABYLON {
  12598. /**
  12599. * Enum used to define the compatibility state between two connection points
  12600. */
  12601. export enum NodeMaterialConnectionPointCompatibilityStates {
  12602. /** Points are compatibles */
  12603. Compatible = 0,
  12604. /** Points are incompatible because of their types */
  12605. TypeIncompatible = 1,
  12606. /** Points are incompatible because of their targets (vertex vs fragment) */
  12607. TargetIncompatible = 2
  12608. }
  12609. /**
  12610. * Defines the direction of a connection point
  12611. */
  12612. export enum NodeMaterialConnectionPointDirection {
  12613. /** Input */
  12614. Input = 0,
  12615. /** Output */
  12616. Output = 1
  12617. }
  12618. /**
  12619. * Defines a connection point for a block
  12620. */
  12621. export class NodeMaterialConnectionPoint {
  12622. /**
  12623. * Checks if two types are equivalent
  12624. * @param type1 type 1 to check
  12625. * @param type2 type 2 to check
  12626. * @returns true if both types are equivalent, else false
  12627. */
  12628. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12629. /** @hidden */
  12630. _ownerBlock: NodeMaterialBlock;
  12631. /** @hidden */
  12632. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12633. private _endpoints;
  12634. private _associatedVariableName;
  12635. private _direction;
  12636. /** @hidden */
  12637. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12638. /** @hidden */
  12639. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12640. /** @hidden */
  12641. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12642. private _type;
  12643. /** @hidden */
  12644. _enforceAssociatedVariableName: boolean;
  12645. /** Gets the direction of the point */
  12646. get direction(): NodeMaterialConnectionPointDirection;
  12647. /** Indicates that this connection point needs dual validation before being connected to another point */
  12648. needDualDirectionValidation: boolean;
  12649. /**
  12650. * Gets or sets the additional types supported by this connection point
  12651. */
  12652. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12653. /**
  12654. * Gets or sets the additional types excluded by this connection point
  12655. */
  12656. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12657. /**
  12658. * Observable triggered when this point is connected
  12659. */
  12660. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12661. /**
  12662. * Gets or sets the associated variable name in the shader
  12663. */
  12664. get associatedVariableName(): string;
  12665. set associatedVariableName(value: string);
  12666. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12667. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12668. /**
  12669. * Gets or sets the connection point type (default is float)
  12670. */
  12671. get type(): NodeMaterialBlockConnectionPointTypes;
  12672. set type(value: NodeMaterialBlockConnectionPointTypes);
  12673. /**
  12674. * Gets or sets the connection point name
  12675. */
  12676. name: string;
  12677. /**
  12678. * Gets or sets the connection point name
  12679. */
  12680. displayName: string;
  12681. /**
  12682. * Gets or sets a boolean indicating that this connection point can be omitted
  12683. */
  12684. isOptional: boolean;
  12685. /**
  12686. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12687. */
  12688. isExposedOnFrame: boolean;
  12689. /**
  12690. * Gets or sets number indicating the position that the port is exposed to on a frame
  12691. */
  12692. exposedPortPosition: number;
  12693. /**
  12694. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12695. */
  12696. define: string;
  12697. /** @hidden */
  12698. _prioritizeVertex: boolean;
  12699. private _target;
  12700. /** Gets or sets the target of that connection point */
  12701. get target(): NodeMaterialBlockTargets;
  12702. set target(value: NodeMaterialBlockTargets);
  12703. /**
  12704. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12705. */
  12706. get isConnected(): boolean;
  12707. /**
  12708. * Gets a boolean indicating that the current point is connected to an input block
  12709. */
  12710. get isConnectedToInputBlock(): boolean;
  12711. /**
  12712. * Gets a the connected input block (if any)
  12713. */
  12714. get connectInputBlock(): Nullable<InputBlock>;
  12715. /** Get the other side of the connection (if any) */
  12716. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12717. /** Get the block that owns this connection point */
  12718. get ownerBlock(): NodeMaterialBlock;
  12719. /** Get the block connected on the other side of this connection (if any) */
  12720. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12721. /** Get the block connected on the endpoints of this connection (if any) */
  12722. get connectedBlocks(): Array<NodeMaterialBlock>;
  12723. /** Gets the list of connected endpoints */
  12724. get endpoints(): NodeMaterialConnectionPoint[];
  12725. /** Gets a boolean indicating if that output point is connected to at least one input */
  12726. get hasEndpoints(): boolean;
  12727. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12728. get isConnectedInVertexShader(): boolean;
  12729. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12730. get isConnectedInFragmentShader(): boolean;
  12731. /**
  12732. * Creates a block suitable to be used as an input for this input point.
  12733. * If null is returned, a block based on the point type will be created.
  12734. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  12735. */
  12736. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12737. /**
  12738. * Creates a new connection point
  12739. * @param name defines the connection point name
  12740. * @param ownerBlock defines the block hosting this connection point
  12741. * @param direction defines the direction of the connection point
  12742. */
  12743. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12744. /**
  12745. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12746. * @returns the class name
  12747. */
  12748. getClassName(): string;
  12749. /**
  12750. * Gets a boolean indicating if the current point can be connected to another point
  12751. * @param connectionPoint defines the other connection point
  12752. * @returns a boolean
  12753. */
  12754. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12755. /**
  12756. * Gets a number indicating if the current point can be connected to another point
  12757. * @param connectionPoint defines the other connection point
  12758. * @returns a number defining the compatibility state
  12759. */
  12760. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12761. /**
  12762. * Connect this point to another connection point
  12763. * @param connectionPoint defines the other connection point
  12764. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12765. * @returns the current connection point
  12766. */
  12767. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12768. /**
  12769. * Disconnect this point from one of his endpoint
  12770. * @param endpoint defines the other connection point
  12771. * @returns the current connection point
  12772. */
  12773. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12774. /**
  12775. * Serializes this point in a JSON representation
  12776. * @param isInput defines if the connection point is an input (default is true)
  12777. * @returns the serialized point object
  12778. */
  12779. serialize(isInput?: boolean): any;
  12780. /**
  12781. * Release resources
  12782. */
  12783. dispose(): void;
  12784. }
  12785. }
  12786. declare module BABYLON {
  12787. /**
  12788. * Enum used to define the material modes
  12789. */
  12790. export enum NodeMaterialModes {
  12791. /** Regular material */
  12792. Material = 0,
  12793. /** For post process */
  12794. PostProcess = 1,
  12795. /** For particle system */
  12796. Particle = 2,
  12797. /** For procedural texture */
  12798. ProceduralTexture = 3
  12799. }
  12800. }
  12801. declare module BABYLON {
  12802. /** @hidden */
  12803. export var helperFunctions: {
  12804. name: string;
  12805. shader: string;
  12806. };
  12807. }
  12808. declare module BABYLON {
  12809. /**
  12810. * Block used to read a texture from a sampler
  12811. */
  12812. export class TextureBlock extends NodeMaterialBlock {
  12813. private _defineName;
  12814. private _linearDefineName;
  12815. private _gammaDefineName;
  12816. private _tempTextureRead;
  12817. private _samplerName;
  12818. private _transformedUVName;
  12819. private _textureTransformName;
  12820. private _textureInfoName;
  12821. private _mainUVName;
  12822. private _mainUVDefineName;
  12823. private _fragmentOnly;
  12824. /**
  12825. * Gets or sets the texture associated with the node
  12826. */
  12827. texture: Nullable<Texture>;
  12828. /**
  12829. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12830. */
  12831. convertToGammaSpace: boolean;
  12832. /**
  12833. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12834. */
  12835. convertToLinearSpace: boolean;
  12836. /**
  12837. * Create a new TextureBlock
  12838. * @param name defines the block name
  12839. */
  12840. constructor(name: string, fragmentOnly?: boolean);
  12841. /**
  12842. * Gets the current class name
  12843. * @returns the class name
  12844. */
  12845. getClassName(): string;
  12846. /**
  12847. * Gets the uv input component
  12848. */
  12849. get uv(): NodeMaterialConnectionPoint;
  12850. /**
  12851. * Gets the rgba output component
  12852. */
  12853. get rgba(): NodeMaterialConnectionPoint;
  12854. /**
  12855. * Gets the rgb output component
  12856. */
  12857. get rgb(): NodeMaterialConnectionPoint;
  12858. /**
  12859. * Gets the r output component
  12860. */
  12861. get r(): NodeMaterialConnectionPoint;
  12862. /**
  12863. * Gets the g output component
  12864. */
  12865. get g(): NodeMaterialConnectionPoint;
  12866. /**
  12867. * Gets the b output component
  12868. */
  12869. get b(): NodeMaterialConnectionPoint;
  12870. /**
  12871. * Gets the a output component
  12872. */
  12873. get a(): NodeMaterialConnectionPoint;
  12874. get target(): NodeMaterialBlockTargets;
  12875. autoConfigure(material: NodeMaterial): void;
  12876. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12878. isReady(): boolean;
  12879. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12880. private get _isMixed();
  12881. private _injectVertexCode;
  12882. private _writeTextureRead;
  12883. private _writeOutput;
  12884. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12885. protected _dumpPropertiesCode(): string;
  12886. serialize(): any;
  12887. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12888. }
  12889. }
  12890. declare module BABYLON {
  12891. /** @hidden */
  12892. export var reflectionFunction: {
  12893. name: string;
  12894. shader: string;
  12895. };
  12896. }
  12897. declare module BABYLON {
  12898. /**
  12899. * Base block used to read a reflection texture from a sampler
  12900. */
  12901. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12902. /** @hidden */
  12903. _define3DName: string;
  12904. /** @hidden */
  12905. _defineCubicName: string;
  12906. /** @hidden */
  12907. _defineExplicitName: string;
  12908. /** @hidden */
  12909. _defineProjectionName: string;
  12910. /** @hidden */
  12911. _defineLocalCubicName: string;
  12912. /** @hidden */
  12913. _defineSphericalName: string;
  12914. /** @hidden */
  12915. _definePlanarName: string;
  12916. /** @hidden */
  12917. _defineEquirectangularName: string;
  12918. /** @hidden */
  12919. _defineMirroredEquirectangularFixedName: string;
  12920. /** @hidden */
  12921. _defineEquirectangularFixedName: string;
  12922. /** @hidden */
  12923. _defineSkyboxName: string;
  12924. /** @hidden */
  12925. _defineOppositeZ: string;
  12926. /** @hidden */
  12927. _cubeSamplerName: string;
  12928. /** @hidden */
  12929. _2DSamplerName: string;
  12930. protected _positionUVWName: string;
  12931. protected _directionWName: string;
  12932. protected _reflectionVectorName: string;
  12933. /** @hidden */
  12934. _reflectionCoordsName: string;
  12935. /** @hidden */
  12936. _reflectionMatrixName: string;
  12937. protected _reflectionColorName: string;
  12938. /**
  12939. * Gets or sets the texture associated with the node
  12940. */
  12941. texture: Nullable<BaseTexture>;
  12942. /**
  12943. * Create a new ReflectionTextureBaseBlock
  12944. * @param name defines the block name
  12945. */
  12946. constructor(name: string);
  12947. /**
  12948. * Gets the current class name
  12949. * @returns the class name
  12950. */
  12951. getClassName(): string;
  12952. /**
  12953. * Gets the world position input component
  12954. */
  12955. abstract get position(): NodeMaterialConnectionPoint;
  12956. /**
  12957. * Gets the world position input component
  12958. */
  12959. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12960. /**
  12961. * Gets the world normal input component
  12962. */
  12963. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12964. /**
  12965. * Gets the world input component
  12966. */
  12967. abstract get world(): NodeMaterialConnectionPoint;
  12968. /**
  12969. * Gets the camera (or eye) position component
  12970. */
  12971. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12972. /**
  12973. * Gets the view input component
  12974. */
  12975. abstract get view(): NodeMaterialConnectionPoint;
  12976. protected _getTexture(): Nullable<BaseTexture>;
  12977. autoConfigure(material: NodeMaterial): void;
  12978. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12979. isReady(): boolean;
  12980. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12981. /**
  12982. * Gets the code to inject in the vertex shader
  12983. * @param state current state of the node material building
  12984. * @returns the shader code
  12985. */
  12986. handleVertexSide(state: NodeMaterialBuildState): string;
  12987. /**
  12988. * Handles the inits for the fragment code path
  12989. * @param state node material build state
  12990. */
  12991. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12992. /**
  12993. * Generates the reflection coords code for the fragment code path
  12994. * @param worldNormalVarName name of the world normal variable
  12995. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12996. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12997. * @returns the shader code
  12998. */
  12999. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  13000. /**
  13001. * Generates the reflection color code for the fragment code path
  13002. * @param lodVarName name of the lod variable
  13003. * @param swizzleLookupTexture swizzle to use for the final color variable
  13004. * @returns the shader code
  13005. */
  13006. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  13007. /**
  13008. * Generates the code corresponding to the connected output points
  13009. * @param state node material build state
  13010. * @param varName name of the variable to output
  13011. * @returns the shader code
  13012. */
  13013. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  13014. protected _buildBlock(state: NodeMaterialBuildState): this;
  13015. protected _dumpPropertiesCode(): string;
  13016. serialize(): any;
  13017. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13018. }
  13019. }
  13020. declare module BABYLON {
  13021. /**
  13022. * Defines a connection point to be used for points with a custom object type
  13023. */
  13024. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  13025. private _blockType;
  13026. private _blockName;
  13027. private _nameForCheking?;
  13028. /**
  13029. * Creates a new connection point
  13030. * @param name defines the connection point name
  13031. * @param ownerBlock defines the block hosting this connection point
  13032. * @param direction defines the direction of the connection point
  13033. */
  13034. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  13035. /**
  13036. * Gets a number indicating if the current point can be connected to another point
  13037. * @param connectionPoint defines the other connection point
  13038. * @returns a number defining the compatibility state
  13039. */
  13040. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13041. /**
  13042. * Creates a block suitable to be used as an input for this input point.
  13043. * If null is returned, a block based on the point type will be created.
  13044. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  13045. */
  13046. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13047. }
  13048. }
  13049. declare module BABYLON {
  13050. /**
  13051. * Enum defining the type of properties that can be edited in the property pages in the NME
  13052. */
  13053. export enum PropertyTypeForEdition {
  13054. /** property is a boolean */
  13055. Boolean = 0,
  13056. /** property is a float */
  13057. Float = 1,
  13058. /** property is a Vector2 */
  13059. Vector2 = 2,
  13060. /** property is a list of values */
  13061. List = 3
  13062. }
  13063. /**
  13064. * Interface that defines an option in a variable of type list
  13065. */
  13066. export interface IEditablePropertyListOption {
  13067. /** label of the option */
  13068. "label": string;
  13069. /** value of the option */
  13070. "value": number;
  13071. }
  13072. /**
  13073. * Interface that defines the options available for an editable property
  13074. */
  13075. export interface IEditablePropertyOption {
  13076. /** min value */
  13077. "min"?: number;
  13078. /** max value */
  13079. "max"?: number;
  13080. /** notifiers: indicates which actions to take when the property is changed */
  13081. "notifiers"?: {
  13082. /** the material should be rebuilt */
  13083. "rebuild"?: boolean;
  13084. /** the preview should be updated */
  13085. "update"?: boolean;
  13086. };
  13087. /** list of the options for a variable of type list */
  13088. "options"?: IEditablePropertyListOption[];
  13089. }
  13090. /**
  13091. * Interface that describes an editable property
  13092. */
  13093. export interface IPropertyDescriptionForEdition {
  13094. /** name of the property */
  13095. "propertyName": string;
  13096. /** display name of the property */
  13097. "displayName": string;
  13098. /** type of the property */
  13099. "type": PropertyTypeForEdition;
  13100. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13101. "groupName": string;
  13102. /** options for the property */
  13103. "options": IEditablePropertyOption;
  13104. }
  13105. /**
  13106. * Decorator that flags a property in a node material block as being editable
  13107. */
  13108. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13109. }
  13110. declare module BABYLON {
  13111. /**
  13112. * Block used to implement the refraction part of the sub surface module of the PBR material
  13113. */
  13114. export class RefractionBlock extends NodeMaterialBlock {
  13115. /** @hidden */
  13116. _define3DName: string;
  13117. /** @hidden */
  13118. _refractionMatrixName: string;
  13119. /** @hidden */
  13120. _defineLODRefractionAlpha: string;
  13121. /** @hidden */
  13122. _defineLinearSpecularRefraction: string;
  13123. /** @hidden */
  13124. _defineOppositeZ: string;
  13125. /** @hidden */
  13126. _cubeSamplerName: string;
  13127. /** @hidden */
  13128. _2DSamplerName: string;
  13129. /** @hidden */
  13130. _vRefractionMicrosurfaceInfosName: string;
  13131. /** @hidden */
  13132. _vRefractionInfosName: string;
  13133. /** @hidden */
  13134. _vRefractionFilteringInfoName: string;
  13135. private _scene;
  13136. /**
  13137. * The properties below are set by the main PBR block prior to calling methods of this class.
  13138. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13139. * It's less burden on the user side in the editor part.
  13140. */
  13141. /** @hidden */
  13142. viewConnectionPoint: NodeMaterialConnectionPoint;
  13143. /** @hidden */
  13144. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13145. /**
  13146. * This parameters will make the material used its opacity to control how much it is refracting against not.
  13147. * Materials half opaque for instance using refraction could benefit from this control.
  13148. */
  13149. linkRefractionWithTransparency: boolean;
  13150. /**
  13151. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13152. */
  13153. invertRefractionY: boolean;
  13154. /**
  13155. * Gets or sets the texture associated with the node
  13156. */
  13157. texture: Nullable<BaseTexture>;
  13158. /**
  13159. * Create a new RefractionBlock
  13160. * @param name defines the block name
  13161. */
  13162. constructor(name: string);
  13163. /**
  13164. * Gets the current class name
  13165. * @returns the class name
  13166. */
  13167. getClassName(): string;
  13168. /**
  13169. * Gets the intensity input component
  13170. */
  13171. get intensity(): NodeMaterialConnectionPoint;
  13172. /**
  13173. * Gets the tint at distance input component
  13174. */
  13175. get tintAtDistance(): NodeMaterialConnectionPoint;
  13176. /**
  13177. * Gets the view input component
  13178. */
  13179. get view(): NodeMaterialConnectionPoint;
  13180. /**
  13181. * Gets the refraction object output component
  13182. */
  13183. get refraction(): NodeMaterialConnectionPoint;
  13184. /**
  13185. * Returns true if the block has a texture
  13186. */
  13187. get hasTexture(): boolean;
  13188. protected _getTexture(): Nullable<BaseTexture>;
  13189. autoConfigure(material: NodeMaterial): void;
  13190. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13191. isReady(): boolean;
  13192. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13193. /**
  13194. * Gets the main code of the block (fragment side)
  13195. * @param state current state of the node material building
  13196. * @returns the shader code
  13197. */
  13198. getCode(state: NodeMaterialBuildState): string;
  13199. protected _buildBlock(state: NodeMaterialBuildState): this;
  13200. protected _dumpPropertiesCode(): string;
  13201. serialize(): any;
  13202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13203. }
  13204. }
  13205. declare module BABYLON {
  13206. /**
  13207. * Base block used as input for post process
  13208. */
  13209. export class CurrentScreenBlock extends NodeMaterialBlock {
  13210. private _samplerName;
  13211. private _linearDefineName;
  13212. private _gammaDefineName;
  13213. private _mainUVName;
  13214. private _tempTextureRead;
  13215. /**
  13216. * Gets or sets the texture associated with the node
  13217. */
  13218. texture: Nullable<BaseTexture>;
  13219. /**
  13220. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13221. */
  13222. convertToGammaSpace: boolean;
  13223. /**
  13224. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13225. */
  13226. convertToLinearSpace: boolean;
  13227. /**
  13228. * Create a new CurrentScreenBlock
  13229. * @param name defines the block name
  13230. */
  13231. constructor(name: string);
  13232. /**
  13233. * Gets the current class name
  13234. * @returns the class name
  13235. */
  13236. getClassName(): string;
  13237. /**
  13238. * Gets the uv input component
  13239. */
  13240. get uv(): NodeMaterialConnectionPoint;
  13241. /**
  13242. * Gets the rgba output component
  13243. */
  13244. get rgba(): NodeMaterialConnectionPoint;
  13245. /**
  13246. * Gets the rgb output component
  13247. */
  13248. get rgb(): NodeMaterialConnectionPoint;
  13249. /**
  13250. * Gets the r output component
  13251. */
  13252. get r(): NodeMaterialConnectionPoint;
  13253. /**
  13254. * Gets the g output component
  13255. */
  13256. get g(): NodeMaterialConnectionPoint;
  13257. /**
  13258. * Gets the b output component
  13259. */
  13260. get b(): NodeMaterialConnectionPoint;
  13261. /**
  13262. * Gets the a output component
  13263. */
  13264. get a(): NodeMaterialConnectionPoint;
  13265. /**
  13266. * Initialize the block and prepare the context for build
  13267. * @param state defines the state that will be used for the build
  13268. */
  13269. initialize(state: NodeMaterialBuildState): void;
  13270. get target(): NodeMaterialBlockTargets;
  13271. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13272. isReady(): boolean;
  13273. private _injectVertexCode;
  13274. private _writeTextureRead;
  13275. private _writeOutput;
  13276. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13277. serialize(): any;
  13278. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13279. }
  13280. }
  13281. declare module BABYLON {
  13282. /**
  13283. * Base block used for the particle texture
  13284. */
  13285. export class ParticleTextureBlock extends NodeMaterialBlock {
  13286. private _samplerName;
  13287. private _linearDefineName;
  13288. private _gammaDefineName;
  13289. private _tempTextureRead;
  13290. /**
  13291. * Gets or sets the texture associated with the node
  13292. */
  13293. texture: Nullable<BaseTexture>;
  13294. /**
  13295. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13296. */
  13297. convertToGammaSpace: boolean;
  13298. /**
  13299. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13300. */
  13301. convertToLinearSpace: boolean;
  13302. /**
  13303. * Create a new ParticleTextureBlock
  13304. * @param name defines the block name
  13305. */
  13306. constructor(name: string);
  13307. /**
  13308. * Gets the current class name
  13309. * @returns the class name
  13310. */
  13311. getClassName(): string;
  13312. /**
  13313. * Gets the uv input component
  13314. */
  13315. get uv(): NodeMaterialConnectionPoint;
  13316. /**
  13317. * Gets the rgba output component
  13318. */
  13319. get rgba(): NodeMaterialConnectionPoint;
  13320. /**
  13321. * Gets the rgb output component
  13322. */
  13323. get rgb(): NodeMaterialConnectionPoint;
  13324. /**
  13325. * Gets the r output component
  13326. */
  13327. get r(): NodeMaterialConnectionPoint;
  13328. /**
  13329. * Gets the g output component
  13330. */
  13331. get g(): NodeMaterialConnectionPoint;
  13332. /**
  13333. * Gets the b output component
  13334. */
  13335. get b(): NodeMaterialConnectionPoint;
  13336. /**
  13337. * Gets the a output component
  13338. */
  13339. get a(): NodeMaterialConnectionPoint;
  13340. /**
  13341. * Initialize the block and prepare the context for build
  13342. * @param state defines the state that will be used for the build
  13343. */
  13344. initialize(state: NodeMaterialBuildState): void;
  13345. autoConfigure(material: NodeMaterial): void;
  13346. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13347. isReady(): boolean;
  13348. private _writeOutput;
  13349. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13350. serialize(): any;
  13351. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13352. }
  13353. }
  13354. declare module BABYLON {
  13355. /**
  13356. * Class used to store shared data between 2 NodeMaterialBuildState
  13357. */
  13358. export class NodeMaterialBuildStateSharedData {
  13359. /**
  13360. * Gets the list of emitted varyings
  13361. */
  13362. temps: string[];
  13363. /**
  13364. * Gets the list of emitted varyings
  13365. */
  13366. varyings: string[];
  13367. /**
  13368. * Gets the varying declaration string
  13369. */
  13370. varyingDeclaration: string;
  13371. /**
  13372. * Input blocks
  13373. */
  13374. inputBlocks: InputBlock[];
  13375. /**
  13376. * Input blocks
  13377. */
  13378. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13379. /**
  13380. * Bindable blocks (Blocks that need to set data to the effect)
  13381. */
  13382. bindableBlocks: NodeMaterialBlock[];
  13383. /**
  13384. * List of blocks that can provide a compilation fallback
  13385. */
  13386. blocksWithFallbacks: NodeMaterialBlock[];
  13387. /**
  13388. * List of blocks that can provide a define update
  13389. */
  13390. blocksWithDefines: NodeMaterialBlock[];
  13391. /**
  13392. * List of blocks that can provide a repeatable content
  13393. */
  13394. repeatableContentBlocks: NodeMaterialBlock[];
  13395. /**
  13396. * List of blocks that can provide a dynamic list of uniforms
  13397. */
  13398. dynamicUniformBlocks: NodeMaterialBlock[];
  13399. /**
  13400. * List of blocks that can block the isReady function for the material
  13401. */
  13402. blockingBlocks: NodeMaterialBlock[];
  13403. /**
  13404. * Gets the list of animated inputs
  13405. */
  13406. animatedInputs: InputBlock[];
  13407. /**
  13408. * Build Id used to avoid multiple recompilations
  13409. */
  13410. buildId: number;
  13411. /** List of emitted variables */
  13412. variableNames: {
  13413. [key: string]: number;
  13414. };
  13415. /** List of emitted defines */
  13416. defineNames: {
  13417. [key: string]: number;
  13418. };
  13419. /** Should emit comments? */
  13420. emitComments: boolean;
  13421. /** Emit build activity */
  13422. verbose: boolean;
  13423. /** Gets or sets the hosting scene */
  13424. scene: Scene;
  13425. /**
  13426. * Gets the compilation hints emitted at compilation time
  13427. */
  13428. hints: {
  13429. needWorldViewMatrix: boolean;
  13430. needWorldViewProjectionMatrix: boolean;
  13431. needAlphaBlending: boolean;
  13432. needAlphaTesting: boolean;
  13433. };
  13434. /**
  13435. * List of compilation checks
  13436. */
  13437. checks: {
  13438. emitVertex: boolean;
  13439. emitFragment: boolean;
  13440. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13441. };
  13442. /**
  13443. * Is vertex program allowed to be empty?
  13444. */
  13445. allowEmptyVertexProgram: boolean;
  13446. /** Creates a new shared data */
  13447. constructor();
  13448. /**
  13449. * Emits console errors and exceptions if there is a failing check
  13450. */
  13451. emitErrors(): void;
  13452. }
  13453. }
  13454. declare module BABYLON {
  13455. /**
  13456. * Class used to store node based material build state
  13457. */
  13458. export class NodeMaterialBuildState {
  13459. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13460. supportUniformBuffers: boolean;
  13461. /**
  13462. * Gets the list of emitted attributes
  13463. */
  13464. attributes: string[];
  13465. /**
  13466. * Gets the list of emitted uniforms
  13467. */
  13468. uniforms: string[];
  13469. /**
  13470. * Gets the list of emitted constants
  13471. */
  13472. constants: string[];
  13473. /**
  13474. * Gets the list of emitted samplers
  13475. */
  13476. samplers: string[];
  13477. /**
  13478. * Gets the list of emitted functions
  13479. */
  13480. functions: {
  13481. [key: string]: string;
  13482. };
  13483. /**
  13484. * Gets the list of emitted extensions
  13485. */
  13486. extensions: {
  13487. [key: string]: string;
  13488. };
  13489. /**
  13490. * Gets the target of the compilation state
  13491. */
  13492. target: NodeMaterialBlockTargets;
  13493. /**
  13494. * Gets the list of emitted counters
  13495. */
  13496. counters: {
  13497. [key: string]: number;
  13498. };
  13499. /**
  13500. * Shared data between multiple NodeMaterialBuildState instances
  13501. */
  13502. sharedData: NodeMaterialBuildStateSharedData;
  13503. /** @hidden */
  13504. _vertexState: NodeMaterialBuildState;
  13505. /** @hidden */
  13506. _attributeDeclaration: string;
  13507. /** @hidden */
  13508. _uniformDeclaration: string;
  13509. /** @hidden */
  13510. _constantDeclaration: string;
  13511. /** @hidden */
  13512. _samplerDeclaration: string;
  13513. /** @hidden */
  13514. _varyingTransfer: string;
  13515. /** @hidden */
  13516. _injectAtEnd: string;
  13517. private _repeatableContentAnchorIndex;
  13518. /** @hidden */
  13519. _builtCompilationString: string;
  13520. /**
  13521. * Gets the emitted compilation strings
  13522. */
  13523. compilationString: string;
  13524. /**
  13525. * Finalize the compilation strings
  13526. * @param state defines the current compilation state
  13527. */
  13528. finalize(state: NodeMaterialBuildState): void;
  13529. /** @hidden */
  13530. get _repeatableContentAnchor(): string;
  13531. /** @hidden */
  13532. _getFreeVariableName(prefix: string): string;
  13533. /** @hidden */
  13534. _getFreeDefineName(prefix: string): string;
  13535. /** @hidden */
  13536. _excludeVariableName(name: string): void;
  13537. /** @hidden */
  13538. _emit2DSampler(name: string): void;
  13539. /** @hidden */
  13540. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13541. /** @hidden */
  13542. _emitExtension(name: string, extension: string, define?: string): void;
  13543. /** @hidden */
  13544. _emitFunction(name: string, code: string, comments: string): void;
  13545. /** @hidden */
  13546. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13547. replaceStrings?: {
  13548. search: RegExp;
  13549. replace: string;
  13550. }[];
  13551. repeatKey?: string;
  13552. }): string;
  13553. /** @hidden */
  13554. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13555. repeatKey?: string;
  13556. removeAttributes?: boolean;
  13557. removeUniforms?: boolean;
  13558. removeVaryings?: boolean;
  13559. removeIfDef?: boolean;
  13560. replaceStrings?: {
  13561. search: RegExp;
  13562. replace: string;
  13563. }[];
  13564. }, storeKey?: string): void;
  13565. /** @hidden */
  13566. _registerTempVariable(name: string): boolean;
  13567. /** @hidden */
  13568. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13569. /** @hidden */
  13570. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13571. /** @hidden */
  13572. _emitFloat(value: number): string;
  13573. }
  13574. }
  13575. declare module BABYLON {
  13576. /**
  13577. * Helper class used to generate session unique ID
  13578. */
  13579. export class UniqueIdGenerator {
  13580. private static _UniqueIdCounter;
  13581. /**
  13582. * Gets an unique (relatively to the current scene) Id
  13583. */
  13584. static get UniqueId(): number;
  13585. }
  13586. }
  13587. declare module BABYLON {
  13588. /**
  13589. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13590. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13591. */
  13592. export class EffectFallbacks implements IEffectFallbacks {
  13593. private _defines;
  13594. private _currentRank;
  13595. private _maxRank;
  13596. private _mesh;
  13597. /**
  13598. * Removes the fallback from the bound mesh.
  13599. */
  13600. unBindMesh(): void;
  13601. /**
  13602. * Adds a fallback on the specified property.
  13603. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13604. * @param define The name of the define in the shader
  13605. */
  13606. addFallback(rank: number, define: string): void;
  13607. /**
  13608. * Sets the mesh to use CPU skinning when needing to fallback.
  13609. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13610. * @param mesh The mesh to use the fallbacks.
  13611. */
  13612. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13613. /**
  13614. * Checks to see if more fallbacks are still available.
  13615. */
  13616. get hasMoreFallbacks(): boolean;
  13617. /**
  13618. * Removes the defines that should be removed when falling back.
  13619. * @param currentDefines defines the current define statements for the shader.
  13620. * @param effect defines the current effect we try to compile
  13621. * @returns The resulting defines with defines of the current rank removed.
  13622. */
  13623. reduce(currentDefines: string, effect: Effect): string;
  13624. }
  13625. }
  13626. declare module BABYLON {
  13627. /**
  13628. * Defines a block that can be used inside a node based material
  13629. */
  13630. export class NodeMaterialBlock {
  13631. private _buildId;
  13632. private _buildTarget;
  13633. private _target;
  13634. private _isFinalMerger;
  13635. private _isInput;
  13636. private _name;
  13637. protected _isUnique: boolean;
  13638. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13639. inputsAreExclusive: boolean;
  13640. /** @hidden */
  13641. _codeVariableName: string;
  13642. /** @hidden */
  13643. _inputs: NodeMaterialConnectionPoint[];
  13644. /** @hidden */
  13645. _outputs: NodeMaterialConnectionPoint[];
  13646. /** @hidden */
  13647. _preparationId: number;
  13648. /** @hidden */
  13649. readonly _originalTargetIsNeutral: boolean;
  13650. /**
  13651. * Gets the name of the block
  13652. */
  13653. get name(): string;
  13654. /**
  13655. * Sets the name of the block. Will check if the name is valid.
  13656. */
  13657. set name(newName: string);
  13658. /**
  13659. * Gets or sets the unique id of the node
  13660. */
  13661. uniqueId: number;
  13662. /**
  13663. * Gets or sets the comments associated with this block
  13664. */
  13665. comments: string;
  13666. /**
  13667. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13668. */
  13669. get isUnique(): boolean;
  13670. /**
  13671. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13672. */
  13673. get isFinalMerger(): boolean;
  13674. /**
  13675. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13676. */
  13677. get isInput(): boolean;
  13678. /**
  13679. * Gets or sets the build Id
  13680. */
  13681. get buildId(): number;
  13682. set buildId(value: number);
  13683. /**
  13684. * Gets or sets the target of the block
  13685. */
  13686. get target(): NodeMaterialBlockTargets;
  13687. set target(value: NodeMaterialBlockTargets);
  13688. /**
  13689. * Gets the list of input points
  13690. */
  13691. get inputs(): NodeMaterialConnectionPoint[];
  13692. /** Gets the list of output points */
  13693. get outputs(): NodeMaterialConnectionPoint[];
  13694. /**
  13695. * Find an input by its name
  13696. * @param name defines the name of the input to look for
  13697. * @returns the input or null if not found
  13698. */
  13699. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13700. /**
  13701. * Find an output by its name
  13702. * @param name defines the name of the output to look for
  13703. * @returns the output or null if not found
  13704. */
  13705. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13706. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13707. visibleInInspector: boolean;
  13708. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13709. visibleOnFrame: boolean;
  13710. /**
  13711. * Creates a new NodeMaterialBlock
  13712. * @param name defines the block name
  13713. * @param target defines the target of that block (Vertex by default)
  13714. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13715. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13716. */
  13717. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13718. /**
  13719. * Initialize the block and prepare the context for build
  13720. * @param state defines the state that will be used for the build
  13721. */
  13722. initialize(state: NodeMaterialBuildState): void;
  13723. /**
  13724. * Bind data to effect. Will only be called for blocks with isBindable === true
  13725. * @param effect defines the effect to bind data to
  13726. * @param nodeMaterial defines the hosting NodeMaterial
  13727. * @param mesh defines the mesh that will be rendered
  13728. * @param subMesh defines the submesh that will be rendered
  13729. */
  13730. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13731. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13732. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13733. protected _writeFloat(value: number): string;
  13734. /**
  13735. * Gets the current class name e.g. "NodeMaterialBlock"
  13736. * @returns the class name
  13737. */
  13738. getClassName(): string;
  13739. /**
  13740. * Register a new input. Must be called inside a block constructor
  13741. * @param name defines the connection point name
  13742. * @param type defines the connection point type
  13743. * @param isOptional defines a boolean indicating that this input can be omitted
  13744. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13745. * @param point an already created connection point. If not provided, create a new one
  13746. * @returns the current block
  13747. */
  13748. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13749. /**
  13750. * Register a new output. Must be called inside a block constructor
  13751. * @param name defines the connection point name
  13752. * @param type defines the connection point type
  13753. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13754. * @param point an already created connection point. If not provided, create a new one
  13755. * @returns the current block
  13756. */
  13757. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13758. /**
  13759. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13760. * @param forOutput defines an optional connection point to check compatibility with
  13761. * @returns the first available input or null
  13762. */
  13763. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13764. /**
  13765. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13766. * @param forBlock defines an optional block to check compatibility with
  13767. * @returns the first available input or null
  13768. */
  13769. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13770. /**
  13771. * Gets the sibling of the given output
  13772. * @param current defines the current output
  13773. * @returns the next output in the list or null
  13774. */
  13775. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13776. /**
  13777. * Connect current block with another block
  13778. * @param other defines the block to connect with
  13779. * @param options define the various options to help pick the right connections
  13780. * @returns the current block
  13781. */
  13782. connectTo(other: NodeMaterialBlock, options?: {
  13783. input?: string;
  13784. output?: string;
  13785. outputSwizzle?: string;
  13786. }): this | undefined;
  13787. protected _buildBlock(state: NodeMaterialBuildState): void;
  13788. /**
  13789. * Add uniforms, samplers and uniform buffers at compilation time
  13790. * @param state defines the state to update
  13791. * @param nodeMaterial defines the node material requesting the update
  13792. * @param defines defines the material defines to update
  13793. * @param uniformBuffers defines the list of uniform buffer names
  13794. */
  13795. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13796. /**
  13797. * Add potential fallbacks if shader compilation fails
  13798. * @param mesh defines the mesh to be rendered
  13799. * @param fallbacks defines the current prioritized list of fallbacks
  13800. */
  13801. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13802. /**
  13803. * Initialize defines for shader compilation
  13804. * @param mesh defines the mesh to be rendered
  13805. * @param nodeMaterial defines the node material requesting the update
  13806. * @param defines defines the material defines to update
  13807. * @param useInstances specifies that instances should be used
  13808. */
  13809. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13810. /**
  13811. * Update defines for shader compilation
  13812. * @param mesh defines the mesh to be rendered
  13813. * @param nodeMaterial defines the node material requesting the update
  13814. * @param defines defines the material defines to update
  13815. * @param useInstances specifies that instances should be used
  13816. * @param subMesh defines which submesh to render
  13817. */
  13818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13819. /**
  13820. * Lets the block try to connect some inputs automatically
  13821. * @param material defines the hosting NodeMaterial
  13822. */
  13823. autoConfigure(material: NodeMaterial): void;
  13824. /**
  13825. * Function called when a block is declared as repeatable content generator
  13826. * @param vertexShaderState defines the current compilation state for the vertex shader
  13827. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13828. * @param mesh defines the mesh to be rendered
  13829. * @param defines defines the material defines to update
  13830. */
  13831. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13832. /**
  13833. * Checks if the block is ready
  13834. * @param mesh defines the mesh to be rendered
  13835. * @param nodeMaterial defines the node material requesting the update
  13836. * @param defines defines the material defines to update
  13837. * @param useInstances specifies that instances should be used
  13838. * @returns true if the block is ready
  13839. */
  13840. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13841. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13842. private _processBuild;
  13843. /**
  13844. * Validates the new name for the block node.
  13845. * @param newName the new name to be given to the node.
  13846. * @returns false if the name is a reserve word, else true.
  13847. */
  13848. validateBlockName(newName: string): boolean;
  13849. /**
  13850. * Compile the current node and generate the shader code
  13851. * @param state defines the current compilation state (uniforms, samplers, current string)
  13852. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13853. * @returns true if already built
  13854. */
  13855. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13856. protected _inputRename(name: string): string;
  13857. protected _outputRename(name: string): string;
  13858. protected _dumpPropertiesCode(): string;
  13859. /** @hidden */
  13860. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13861. /** @hidden */
  13862. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13863. /**
  13864. * Clone the current block to a new identical block
  13865. * @param scene defines the hosting scene
  13866. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13867. * @returns a copy of the current block
  13868. */
  13869. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13870. /**
  13871. * Serializes this block in a JSON representation
  13872. * @returns the serialized block object
  13873. */
  13874. serialize(): any;
  13875. /** @hidden */
  13876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13877. private _deserializePortDisplayNamesAndExposedOnFrame;
  13878. /**
  13879. * Release resources
  13880. */
  13881. dispose(): void;
  13882. }
  13883. }
  13884. declare module BABYLON {
  13885. /**
  13886. * Base class of materials working in push mode in babylon JS
  13887. * @hidden
  13888. */
  13889. export class PushMaterial extends Material {
  13890. protected _activeEffect: Effect;
  13891. protected _normalMatrix: Matrix;
  13892. constructor(name: string, scene: Scene);
  13893. getEffect(): Effect;
  13894. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13895. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13896. /**
  13897. * Binds the given world matrix to the active effect
  13898. *
  13899. * @param world the matrix to bind
  13900. */
  13901. bindOnlyWorldMatrix(world: Matrix): void;
  13902. /**
  13903. * Binds the given normal matrix to the active effect
  13904. *
  13905. * @param normalMatrix the matrix to bind
  13906. */
  13907. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13908. bind(world: Matrix, mesh?: Mesh): void;
  13909. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13910. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13911. }
  13912. }
  13913. declare module BABYLON {
  13914. /**
  13915. * Root class for all node material optimizers
  13916. */
  13917. export class NodeMaterialOptimizer {
  13918. /**
  13919. * Function used to optimize a NodeMaterial graph
  13920. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13921. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13922. */
  13923. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13924. }
  13925. }
  13926. declare module BABYLON {
  13927. /**
  13928. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13929. */
  13930. export class TransformBlock extends NodeMaterialBlock {
  13931. /**
  13932. * Defines the value to use to complement W value to transform it to a Vector4
  13933. */
  13934. complementW: number;
  13935. /**
  13936. * Defines the value to use to complement z value to transform it to a Vector4
  13937. */
  13938. complementZ: number;
  13939. /**
  13940. * Creates a new TransformBlock
  13941. * @param name defines the block name
  13942. */
  13943. constructor(name: string);
  13944. /**
  13945. * Gets the current class name
  13946. * @returns the class name
  13947. */
  13948. getClassName(): string;
  13949. /**
  13950. * Gets the vector input
  13951. */
  13952. get vector(): NodeMaterialConnectionPoint;
  13953. /**
  13954. * Gets the output component
  13955. */
  13956. get output(): NodeMaterialConnectionPoint;
  13957. /**
  13958. * Gets the xyz output component
  13959. */
  13960. get xyz(): NodeMaterialConnectionPoint;
  13961. /**
  13962. * Gets the matrix transform input
  13963. */
  13964. get transform(): NodeMaterialConnectionPoint;
  13965. protected _buildBlock(state: NodeMaterialBuildState): this;
  13966. /**
  13967. * Update defines for shader compilation
  13968. * @param mesh defines the mesh to be rendered
  13969. * @param nodeMaterial defines the node material requesting the update
  13970. * @param defines defines the material defines to update
  13971. * @param useInstances specifies that instances should be used
  13972. * @param subMesh defines which submesh to render
  13973. */
  13974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13975. serialize(): any;
  13976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13977. protected _dumpPropertiesCode(): string;
  13978. }
  13979. }
  13980. declare module BABYLON {
  13981. /**
  13982. * Block used to output the vertex position
  13983. */
  13984. export class VertexOutputBlock extends NodeMaterialBlock {
  13985. /**
  13986. * Creates a new VertexOutputBlock
  13987. * @param name defines the block name
  13988. */
  13989. constructor(name: string);
  13990. /**
  13991. * Gets the current class name
  13992. * @returns the class name
  13993. */
  13994. getClassName(): string;
  13995. /**
  13996. * Gets the vector input component
  13997. */
  13998. get vector(): NodeMaterialConnectionPoint;
  13999. protected _buildBlock(state: NodeMaterialBuildState): this;
  14000. }
  14001. }
  14002. declare module BABYLON {
  14003. /**
  14004. * Block used to output the final color
  14005. */
  14006. export class FragmentOutputBlock extends NodeMaterialBlock {
  14007. /**
  14008. * Create a new FragmentOutputBlock
  14009. * @param name defines the block name
  14010. */
  14011. constructor(name: string);
  14012. /**
  14013. * Gets the current class name
  14014. * @returns the class name
  14015. */
  14016. getClassName(): string;
  14017. /**
  14018. * Gets the rgba input component
  14019. */
  14020. get rgba(): NodeMaterialConnectionPoint;
  14021. /**
  14022. * Gets the rgb input component
  14023. */
  14024. get rgb(): NodeMaterialConnectionPoint;
  14025. /**
  14026. * Gets the a input component
  14027. */
  14028. get a(): NodeMaterialConnectionPoint;
  14029. protected _buildBlock(state: NodeMaterialBuildState): this;
  14030. }
  14031. }
  14032. declare module BABYLON {
  14033. /**
  14034. * Block used for the particle ramp gradient section
  14035. */
  14036. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  14037. /**
  14038. * Create a new ParticleRampGradientBlock
  14039. * @param name defines the block name
  14040. */
  14041. constructor(name: string);
  14042. /**
  14043. * Gets the current class name
  14044. * @returns the class name
  14045. */
  14046. getClassName(): string;
  14047. /**
  14048. * Gets the color input component
  14049. */
  14050. get color(): NodeMaterialConnectionPoint;
  14051. /**
  14052. * Gets the rampColor output component
  14053. */
  14054. get rampColor(): NodeMaterialConnectionPoint;
  14055. /**
  14056. * Initialize the block and prepare the context for build
  14057. * @param state defines the state that will be used for the build
  14058. */
  14059. initialize(state: NodeMaterialBuildState): void;
  14060. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14061. }
  14062. }
  14063. declare module BABYLON {
  14064. /**
  14065. * Block used for the particle blend multiply section
  14066. */
  14067. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14068. /**
  14069. * Create a new ParticleBlendMultiplyBlock
  14070. * @param name defines the block name
  14071. */
  14072. constructor(name: string);
  14073. /**
  14074. * Gets the current class name
  14075. * @returns the class name
  14076. */
  14077. getClassName(): string;
  14078. /**
  14079. * Gets the color input component
  14080. */
  14081. get color(): NodeMaterialConnectionPoint;
  14082. /**
  14083. * Gets the alphaTexture input component
  14084. */
  14085. get alphaTexture(): NodeMaterialConnectionPoint;
  14086. /**
  14087. * Gets the alphaColor input component
  14088. */
  14089. get alphaColor(): NodeMaterialConnectionPoint;
  14090. /**
  14091. * Gets the blendColor output component
  14092. */
  14093. get blendColor(): NodeMaterialConnectionPoint;
  14094. /**
  14095. * Initialize the block and prepare the context for build
  14096. * @param state defines the state that will be used for the build
  14097. */
  14098. initialize(state: NodeMaterialBuildState): void;
  14099. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14100. }
  14101. }
  14102. declare module BABYLON {
  14103. /**
  14104. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14105. */
  14106. export class VectorMergerBlock extends NodeMaterialBlock {
  14107. /**
  14108. * Create a new VectorMergerBlock
  14109. * @param name defines the block name
  14110. */
  14111. constructor(name: string);
  14112. /**
  14113. * Gets the current class name
  14114. * @returns the class name
  14115. */
  14116. getClassName(): string;
  14117. /**
  14118. * Gets the xyz component (input)
  14119. */
  14120. get xyzIn(): NodeMaterialConnectionPoint;
  14121. /**
  14122. * Gets the xy component (input)
  14123. */
  14124. get xyIn(): NodeMaterialConnectionPoint;
  14125. /**
  14126. * Gets the x component (input)
  14127. */
  14128. get x(): NodeMaterialConnectionPoint;
  14129. /**
  14130. * Gets the y component (input)
  14131. */
  14132. get y(): NodeMaterialConnectionPoint;
  14133. /**
  14134. * Gets the z component (input)
  14135. */
  14136. get z(): NodeMaterialConnectionPoint;
  14137. /**
  14138. * Gets the w component (input)
  14139. */
  14140. get w(): NodeMaterialConnectionPoint;
  14141. /**
  14142. * Gets the xyzw component (output)
  14143. */
  14144. get xyzw(): NodeMaterialConnectionPoint;
  14145. /**
  14146. * Gets the xyz component (output)
  14147. */
  14148. get xyzOut(): NodeMaterialConnectionPoint;
  14149. /**
  14150. * Gets the xy component (output)
  14151. */
  14152. get xyOut(): NodeMaterialConnectionPoint;
  14153. /**
  14154. * Gets the xy component (output)
  14155. * @deprecated Please use xyOut instead.
  14156. */
  14157. get xy(): NodeMaterialConnectionPoint;
  14158. /**
  14159. * Gets the xyz component (output)
  14160. * @deprecated Please use xyzOut instead.
  14161. */
  14162. get xyz(): NodeMaterialConnectionPoint;
  14163. protected _buildBlock(state: NodeMaterialBuildState): this;
  14164. }
  14165. }
  14166. declare module BABYLON {
  14167. /**
  14168. * Block used to remap a float from a range to a new one
  14169. */
  14170. export class RemapBlock extends NodeMaterialBlock {
  14171. /**
  14172. * Gets or sets the source range
  14173. */
  14174. sourceRange: Vector2;
  14175. /**
  14176. * Gets or sets the target range
  14177. */
  14178. targetRange: Vector2;
  14179. /**
  14180. * Creates a new RemapBlock
  14181. * @param name defines the block name
  14182. */
  14183. constructor(name: string);
  14184. /**
  14185. * Gets the current class name
  14186. * @returns the class name
  14187. */
  14188. getClassName(): string;
  14189. /**
  14190. * Gets the input component
  14191. */
  14192. get input(): NodeMaterialConnectionPoint;
  14193. /**
  14194. * Gets the source min input component
  14195. */
  14196. get sourceMin(): NodeMaterialConnectionPoint;
  14197. /**
  14198. * Gets the source max input component
  14199. */
  14200. get sourceMax(): NodeMaterialConnectionPoint;
  14201. /**
  14202. * Gets the target min input component
  14203. */
  14204. get targetMin(): NodeMaterialConnectionPoint;
  14205. /**
  14206. * Gets the target max input component
  14207. */
  14208. get targetMax(): NodeMaterialConnectionPoint;
  14209. /**
  14210. * Gets the output component
  14211. */
  14212. get output(): NodeMaterialConnectionPoint;
  14213. protected _buildBlock(state: NodeMaterialBuildState): this;
  14214. protected _dumpPropertiesCode(): string;
  14215. serialize(): any;
  14216. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14217. }
  14218. }
  14219. declare module BABYLON {
  14220. /**
  14221. * Block used to multiply 2 values
  14222. */
  14223. export class MultiplyBlock extends NodeMaterialBlock {
  14224. /**
  14225. * Creates a new MultiplyBlock
  14226. * @param name defines the block name
  14227. */
  14228. constructor(name: string);
  14229. /**
  14230. * Gets the current class name
  14231. * @returns the class name
  14232. */
  14233. getClassName(): string;
  14234. /**
  14235. * Gets the left operand input component
  14236. */
  14237. get left(): NodeMaterialConnectionPoint;
  14238. /**
  14239. * Gets the right operand input component
  14240. */
  14241. get right(): NodeMaterialConnectionPoint;
  14242. /**
  14243. * Gets the output component
  14244. */
  14245. get output(): NodeMaterialConnectionPoint;
  14246. protected _buildBlock(state: NodeMaterialBuildState): this;
  14247. }
  14248. }
  14249. declare module BABYLON {
  14250. /** Interface used by value gradients (color, factor, ...) */
  14251. export interface IValueGradient {
  14252. /**
  14253. * Gets or sets the gradient value (between 0 and 1)
  14254. */
  14255. gradient: number;
  14256. }
  14257. /** Class used to store color4 gradient */
  14258. export class ColorGradient implements IValueGradient {
  14259. /**
  14260. * Gets or sets the gradient value (between 0 and 1)
  14261. */
  14262. gradient: number;
  14263. /**
  14264. * Gets or sets first associated color
  14265. */
  14266. color1: Color4;
  14267. /**
  14268. * Gets or sets second associated color
  14269. */
  14270. color2?: Color4 | undefined;
  14271. /**
  14272. * Creates a new color4 gradient
  14273. * @param gradient gets or sets the gradient value (between 0 and 1)
  14274. * @param color1 gets or sets first associated color
  14275. * @param color2 gets or sets first second color
  14276. */
  14277. constructor(
  14278. /**
  14279. * Gets or sets the gradient value (between 0 and 1)
  14280. */
  14281. gradient: number,
  14282. /**
  14283. * Gets or sets first associated color
  14284. */
  14285. color1: Color4,
  14286. /**
  14287. * Gets or sets second associated color
  14288. */
  14289. color2?: Color4 | undefined);
  14290. /**
  14291. * Will get a color picked randomly between color1 and color2.
  14292. * If color2 is undefined then color1 will be used
  14293. * @param result defines the target Color4 to store the result in
  14294. */
  14295. getColorToRef(result: Color4): void;
  14296. }
  14297. /** Class used to store color 3 gradient */
  14298. export class Color3Gradient implements IValueGradient {
  14299. /**
  14300. * Gets or sets the gradient value (between 0 and 1)
  14301. */
  14302. gradient: number;
  14303. /**
  14304. * Gets or sets the associated color
  14305. */
  14306. color: Color3;
  14307. /**
  14308. * Creates a new color3 gradient
  14309. * @param gradient gets or sets the gradient value (between 0 and 1)
  14310. * @param color gets or sets associated color
  14311. */
  14312. constructor(
  14313. /**
  14314. * Gets or sets the gradient value (between 0 and 1)
  14315. */
  14316. gradient: number,
  14317. /**
  14318. * Gets or sets the associated color
  14319. */
  14320. color: Color3);
  14321. }
  14322. /** Class used to store factor gradient */
  14323. export class FactorGradient implements IValueGradient {
  14324. /**
  14325. * Gets or sets the gradient value (between 0 and 1)
  14326. */
  14327. gradient: number;
  14328. /**
  14329. * Gets or sets first associated factor
  14330. */
  14331. factor1: number;
  14332. /**
  14333. * Gets or sets second associated factor
  14334. */
  14335. factor2?: number | undefined;
  14336. /**
  14337. * Creates a new factor gradient
  14338. * @param gradient gets or sets the gradient value (between 0 and 1)
  14339. * @param factor1 gets or sets first associated factor
  14340. * @param factor2 gets or sets second associated factor
  14341. */
  14342. constructor(
  14343. /**
  14344. * Gets or sets the gradient value (between 0 and 1)
  14345. */
  14346. gradient: number,
  14347. /**
  14348. * Gets or sets first associated factor
  14349. */
  14350. factor1: number,
  14351. /**
  14352. * Gets or sets second associated factor
  14353. */
  14354. factor2?: number | undefined);
  14355. /**
  14356. * Will get a number picked randomly between factor1 and factor2.
  14357. * If factor2 is undefined then factor1 will be used
  14358. * @returns the picked number
  14359. */
  14360. getFactor(): number;
  14361. }
  14362. /**
  14363. * Helper used to simplify some generic gradient tasks
  14364. */
  14365. export class GradientHelper {
  14366. /**
  14367. * Gets the current gradient from an array of IValueGradient
  14368. * @param ratio defines the current ratio to get
  14369. * @param gradients defines the array of IValueGradient
  14370. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14371. */
  14372. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14373. }
  14374. }
  14375. declare module BABYLON {
  14376. interface ThinEngine {
  14377. /**
  14378. * Creates a raw texture
  14379. * @param data defines the data to store in the texture
  14380. * @param width defines the width of the texture
  14381. * @param height defines the height of the texture
  14382. * @param format defines the format of the data
  14383. * @param generateMipMaps defines if the engine should generate the mip levels
  14384. * @param invertY defines if data must be stored with Y axis inverted
  14385. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14386. * @param compression defines the compression used (null by default)
  14387. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14388. * @returns the raw texture inside an InternalTexture
  14389. */
  14390. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14391. /**
  14392. * Update a raw texture
  14393. * @param texture defines the texture to update
  14394. * @param data defines the data to store in the texture
  14395. * @param format defines the format of the data
  14396. * @param invertY defines if data must be stored with Y axis inverted
  14397. */
  14398. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14399. /**
  14400. * Update a raw texture
  14401. * @param texture defines the texture to update
  14402. * @param data defines the data to store in the texture
  14403. * @param format defines the format of the data
  14404. * @param invertY defines if data must be stored with Y axis inverted
  14405. * @param compression defines the compression used (null by default)
  14406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14407. */
  14408. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14409. /**
  14410. * Creates a new raw cube texture
  14411. * @param data defines the array of data to use to create each face
  14412. * @param size defines the size of the textures
  14413. * @param format defines the format of the data
  14414. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14415. * @param generateMipMaps defines if the engine should generate the mip levels
  14416. * @param invertY defines if data must be stored with Y axis inverted
  14417. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14418. * @param compression defines the compression used (null by default)
  14419. * @returns the cube texture as an InternalTexture
  14420. */
  14421. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14422. /**
  14423. * Update a raw cube texture
  14424. * @param texture defines the texture to update
  14425. * @param data defines the data to store
  14426. * @param format defines the data format
  14427. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14428. * @param invertY defines if data must be stored with Y axis inverted
  14429. */
  14430. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14431. /**
  14432. * Update a raw cube texture
  14433. * @param texture defines the texture to update
  14434. * @param data defines the data to store
  14435. * @param format defines the data format
  14436. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14437. * @param invertY defines if data must be stored with Y axis inverted
  14438. * @param compression defines the compression used (null by default)
  14439. */
  14440. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14441. /**
  14442. * Update a raw cube texture
  14443. * @param texture defines the texture to update
  14444. * @param data defines the data to store
  14445. * @param format defines the data format
  14446. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14447. * @param invertY defines if data must be stored with Y axis inverted
  14448. * @param compression defines the compression used (null by default)
  14449. * @param level defines which level of the texture to update
  14450. */
  14451. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14452. /**
  14453. * Creates a new raw cube texture from a specified url
  14454. * @param url defines the url where the data is located
  14455. * @param scene defines the current scene
  14456. * @param size defines the size of the textures
  14457. * @param format defines the format of the data
  14458. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14459. * @param noMipmap defines if the engine should avoid generating the mip levels
  14460. * @param callback defines a callback used to extract texture data from loaded data
  14461. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14462. * @param onLoad defines a callback called when texture is loaded
  14463. * @param onError defines a callback called if there is an error
  14464. * @returns the cube texture as an InternalTexture
  14465. */
  14466. createRawCubeTextureFromUrl(url: string, scene: Nullable<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>): InternalTexture;
  14467. /**
  14468. * Creates a new raw cube texture from a specified url
  14469. * @param url defines the url where the data is located
  14470. * @param scene defines the current scene
  14471. * @param size defines the size of the textures
  14472. * @param format defines the format of the data
  14473. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14474. * @param noMipmap defines if the engine should avoid generating the mip levels
  14475. * @param callback defines a callback used to extract texture data from loaded data
  14476. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14477. * @param onLoad defines a callback called when texture is loaded
  14478. * @param onError defines a callback called if there is an error
  14479. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14480. * @param invertY defines if data must be stored with Y axis inverted
  14481. * @returns the cube texture as an InternalTexture
  14482. */
  14483. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  14484. /**
  14485. * Creates a new raw 3D texture
  14486. * @param data defines the data used to create the texture
  14487. * @param width defines the width of the texture
  14488. * @param height defines the height of the texture
  14489. * @param depth defines the depth of the texture
  14490. * @param format defines the format of the texture
  14491. * @param generateMipMaps defines if the engine must generate mip levels
  14492. * @param invertY defines if data must be stored with Y axis inverted
  14493. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14494. * @param compression defines the compressed used (can be null)
  14495. * @param textureType defines the compressed used (can be null)
  14496. * @returns a new raw 3D texture (stored in an InternalTexture)
  14497. */
  14498. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14499. /**
  14500. * Update a raw 3D texture
  14501. * @param texture defines the texture to update
  14502. * @param data defines the data to store
  14503. * @param format defines the data format
  14504. * @param invertY defines if data must be stored with Y axis inverted
  14505. */
  14506. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14507. /**
  14508. * Update a raw 3D texture
  14509. * @param texture defines the texture to update
  14510. * @param data defines the data to store
  14511. * @param format defines the data format
  14512. * @param invertY defines if data must be stored with Y axis inverted
  14513. * @param compression defines the used compression (can be null)
  14514. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14515. */
  14516. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14517. /**
  14518. * Creates a new raw 2D array texture
  14519. * @param data defines the data used to create the texture
  14520. * @param width defines the width of the texture
  14521. * @param height defines the height of the texture
  14522. * @param depth defines the number of layers of the texture
  14523. * @param format defines the format of the texture
  14524. * @param generateMipMaps defines if the engine must generate mip levels
  14525. * @param invertY defines if data must be stored with Y axis inverted
  14526. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14527. * @param compression defines the compressed used (can be null)
  14528. * @param textureType defines the compressed used (can be null)
  14529. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14530. */
  14531. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14532. /**
  14533. * Update a raw 2D array texture
  14534. * @param texture defines the texture to update
  14535. * @param data defines the data to store
  14536. * @param format defines the data format
  14537. * @param invertY defines if data must be stored with Y axis inverted
  14538. */
  14539. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14540. /**
  14541. * Update a raw 2D array texture
  14542. * @param texture defines the texture to update
  14543. * @param data defines the data to store
  14544. * @param format defines the data format
  14545. * @param invertY defines if data must be stored with Y axis inverted
  14546. * @param compression defines the used compression (can be null)
  14547. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14548. */
  14549. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14550. }
  14551. }
  14552. declare module BABYLON {
  14553. /**
  14554. * Raw texture can help creating a texture directly from an array of data.
  14555. * This can be super useful if you either get the data from an uncompressed source or
  14556. * if you wish to create your texture pixel by pixel.
  14557. */
  14558. export class RawTexture extends Texture {
  14559. /**
  14560. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14561. */
  14562. format: number;
  14563. /**
  14564. * Instantiates a new RawTexture.
  14565. * Raw texture can help creating a texture directly from an array of data.
  14566. * This can be super useful if you either get the data from an uncompressed source or
  14567. * if you wish to create your texture pixel by pixel.
  14568. * @param data define the array of data to use to create the texture
  14569. * @param width define the width of the texture
  14570. * @param height define the height of the texture
  14571. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14572. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14573. * @param generateMipMaps define whether mip maps should be generated or not
  14574. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14575. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14576. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14577. */
  14578. constructor(data: ArrayBufferView, width: number, height: number,
  14579. /**
  14580. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14581. */
  14582. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14583. /**
  14584. * Updates the texture underlying data.
  14585. * @param data Define the new data of the texture
  14586. */
  14587. update(data: ArrayBufferView): void;
  14588. /**
  14589. * Creates a luminance texture from some data.
  14590. * @param data Define the texture data
  14591. * @param width Define the width of the texture
  14592. * @param height Define the height of the texture
  14593. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14597. * @returns the luminance texture
  14598. */
  14599. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14600. /**
  14601. * Creates a luminance alpha texture from some data.
  14602. * @param data Define the texture data
  14603. * @param width Define the width of the texture
  14604. * @param height Define the height of the texture
  14605. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14606. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14607. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14608. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14609. * @returns the luminance alpha texture
  14610. */
  14611. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14612. /**
  14613. * Creates an alpha texture from some data.
  14614. * @param data Define the texture data
  14615. * @param width Define the width of the texture
  14616. * @param height Define the height of the texture
  14617. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14618. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14619. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14620. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14621. * @returns the alpha texture
  14622. */
  14623. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14624. /**
  14625. * Creates a RGB texture from some data.
  14626. * @param data Define the texture data
  14627. * @param width Define the width of the texture
  14628. * @param height Define the height of the texture
  14629. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14630. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14631. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14632. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14633. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14634. * @returns the RGB alpha texture
  14635. */
  14636. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14637. /**
  14638. * Creates a RGBA texture from some data.
  14639. * @param data Define the texture data
  14640. * @param width Define the width of the texture
  14641. * @param height Define the height of the texture
  14642. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14643. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14644. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14645. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14646. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14647. * @returns the RGBA texture
  14648. */
  14649. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14650. /**
  14651. * Creates a R texture from some data.
  14652. * @param data Define the texture data
  14653. * @param width Define the width of the texture
  14654. * @param height Define the height of the texture
  14655. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14656. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14657. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14658. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14659. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14660. * @returns the R texture
  14661. */
  14662. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14663. }
  14664. }
  14665. declare module BABYLON {
  14666. interface ThinEngine {
  14667. /**
  14668. * Update a dynamic index buffer
  14669. * @param indexBuffer defines the target index buffer
  14670. * @param indices defines the data to update
  14671. * @param offset defines the offset in the target index buffer where update should start
  14672. */
  14673. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14674. /**
  14675. * Updates a dynamic vertex buffer.
  14676. * @param vertexBuffer the vertex buffer to update
  14677. * @param data the data used to update the vertex buffer
  14678. * @param byteOffset the byte offset of the data
  14679. * @param byteLength the byte length of the data
  14680. */
  14681. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14682. }
  14683. }
  14684. declare module BABYLON {
  14685. interface AbstractScene {
  14686. /**
  14687. * The list of procedural textures added to the scene
  14688. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14689. */
  14690. proceduralTextures: Array<ProceduralTexture>;
  14691. }
  14692. /**
  14693. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14694. * in a given scene.
  14695. */
  14696. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14697. /**
  14698. * The component name helpful to identify the component in the list of scene components.
  14699. */
  14700. readonly name: string;
  14701. /**
  14702. * The scene the component belongs to.
  14703. */
  14704. scene: Scene;
  14705. /**
  14706. * Creates a new instance of the component for the given scene
  14707. * @param scene Defines the scene to register the component in
  14708. */
  14709. constructor(scene: Scene);
  14710. /**
  14711. * Registers the component in a given scene
  14712. */
  14713. register(): void;
  14714. /**
  14715. * Rebuilds the elements related to this component in case of
  14716. * context lost for instance.
  14717. */
  14718. rebuild(): void;
  14719. /**
  14720. * Disposes the component and the associated resources.
  14721. */
  14722. dispose(): void;
  14723. private _beforeClear;
  14724. }
  14725. }
  14726. declare module BABYLON {
  14727. interface ThinEngine {
  14728. /**
  14729. * Creates a new render target cube texture
  14730. * @param size defines the size of the texture
  14731. * @param options defines the options used to create the texture
  14732. * @returns a new render target cube texture stored in an InternalTexture
  14733. */
  14734. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14735. }
  14736. }
  14737. declare module BABYLON {
  14738. /** @hidden */
  14739. export var proceduralVertexShader: {
  14740. name: string;
  14741. shader: string;
  14742. };
  14743. }
  14744. declare module BABYLON {
  14745. /**
  14746. * 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 calmpler' images.
  14747. * This is the base class of any Procedural texture and contains most of the shareable code.
  14748. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14749. */
  14750. export class ProceduralTexture extends Texture {
  14751. /**
  14752. * Define if the texture is enabled or not (disabled texture will not render)
  14753. */
  14754. isEnabled: boolean;
  14755. /**
  14756. * Define if the texture must be cleared before rendering (default is true)
  14757. */
  14758. autoClear: boolean;
  14759. /**
  14760. * Callback called when the texture is generated
  14761. */
  14762. onGenerated: () => void;
  14763. /**
  14764. * Event raised when the texture is generated
  14765. */
  14766. onGeneratedObservable: Observable<ProceduralTexture>;
  14767. /**
  14768. * Event raised before the texture is generated
  14769. */
  14770. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14771. /**
  14772. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14773. */
  14774. nodeMaterialSource: Nullable<NodeMaterial>;
  14775. /** @hidden */
  14776. _generateMipMaps: boolean;
  14777. /** @hidden **/
  14778. _effect: Effect;
  14779. /** @hidden */
  14780. _textures: {
  14781. [key: string]: Texture;
  14782. };
  14783. /** @hidden */
  14784. protected _fallbackTexture: Nullable<Texture>;
  14785. private _size;
  14786. private _textureType;
  14787. private _currentRefreshId;
  14788. private _frameId;
  14789. private _refreshRate;
  14790. private _vertexBuffers;
  14791. private _indexBuffer;
  14792. private _uniforms;
  14793. private _samplers;
  14794. private _fragment;
  14795. private _floats;
  14796. private _ints;
  14797. private _floatsArrays;
  14798. private _colors3;
  14799. private _colors4;
  14800. private _vectors2;
  14801. private _vectors3;
  14802. private _matrices;
  14803. private _fallbackTextureUsed;
  14804. private _fullEngine;
  14805. private _cachedDefines;
  14806. private _contentUpdateId;
  14807. private _contentData;
  14808. /**
  14809. * Instantiates a new procedural texture.
  14810. * 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.
  14811. * This is the base class of any Procedural texture and contains most of the shareable code.
  14812. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14813. * @param name Define the name of the texture
  14814. * @param size Define the size of the texture to create
  14815. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14816. * @param scene Define the scene the texture belongs to
  14817. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14818. * @param generateMipMaps Define if the texture should creates mip maps or not
  14819. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14820. * @param textureType The FBO internal texture type
  14821. */
  14822. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14823. /**
  14824. * The effect that is created when initializing the post process.
  14825. * @returns The created effect corresponding the the postprocess.
  14826. */
  14827. getEffect(): Effect;
  14828. /**
  14829. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14830. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  14831. */
  14832. getContent(): Nullable<Promise<ArrayBufferView>>;
  14833. private _createIndexBuffer;
  14834. /** @hidden */
  14835. _rebuild(): void;
  14836. /**
  14837. * Resets the texture in order to recreate its associated resources.
  14838. * This can be called in case of context loss
  14839. */
  14840. reset(): void;
  14841. protected _getDefines(): string;
  14842. /**
  14843. * Is the texture ready to be used ? (rendered at least once)
  14844. * @returns true if ready, otherwise, false.
  14845. */
  14846. isReady(): boolean;
  14847. /**
  14848. * Resets the refresh counter of the texture and start bak from scratch.
  14849. * Could be useful to regenerate the texture if it is setup to render only once.
  14850. */
  14851. resetRefreshCounter(): void;
  14852. /**
  14853. * Set the fragment shader to use in order to render the texture.
  14854. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14855. */
  14856. setFragment(fragment: any): void;
  14857. /**
  14858. * Define the refresh rate of the texture or the rendering frequency.
  14859. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14860. */
  14861. get refreshRate(): number;
  14862. set refreshRate(value: number);
  14863. /** @hidden */
  14864. _shouldRender(): boolean;
  14865. /**
  14866. * Get the size the texture is rendering at.
  14867. * @returns the size (on cube texture it is always squared)
  14868. */
  14869. getRenderSize(): RenderTargetTextureSize;
  14870. /**
  14871. * Resize the texture to new value.
  14872. * @param size Define the new size the texture should have
  14873. * @param generateMipMaps Define whether the new texture should create mip maps
  14874. */
  14875. resize(size: number, generateMipMaps: boolean): void;
  14876. private _checkUniform;
  14877. /**
  14878. * Set a texture in the shader program used to render.
  14879. * @param name Define the name of the uniform samplers as defined in the shader
  14880. * @param texture Define the texture to bind to this sampler
  14881. * @return the texture itself allowing "fluent" like uniform updates
  14882. */
  14883. setTexture(name: string, texture: Texture): ProceduralTexture;
  14884. /**
  14885. * Set a float in the shader.
  14886. * @param name Define the name of the uniform as defined in the shader
  14887. * @param value Define the value to give to the uniform
  14888. * @return the texture itself allowing "fluent" like uniform updates
  14889. */
  14890. setFloat(name: string, value: number): ProceduralTexture;
  14891. /**
  14892. * Set a int in the shader.
  14893. * @param name Define the name of the uniform as defined in the shader
  14894. * @param value Define the value to give to the uniform
  14895. * @return the texture itself allowing "fluent" like uniform updates
  14896. */
  14897. setInt(name: string, value: number): ProceduralTexture;
  14898. /**
  14899. * Set an array of floats in the shader.
  14900. * @param name Define the name of the uniform as defined in the shader
  14901. * @param value Define the value to give to the uniform
  14902. * @return the texture itself allowing "fluent" like uniform updates
  14903. */
  14904. setFloats(name: string, value: number[]): ProceduralTexture;
  14905. /**
  14906. * Set a vec3 in the shader from a Color3.
  14907. * @param name Define the name of the uniform as defined in the shader
  14908. * @param value Define the value to give to the uniform
  14909. * @return the texture itself allowing "fluent" like uniform updates
  14910. */
  14911. setColor3(name: string, value: Color3): ProceduralTexture;
  14912. /**
  14913. * Set a vec4 in the shader from a Color4.
  14914. * @param name Define the name of the uniform as defined in the shader
  14915. * @param value Define the value to give to the uniform
  14916. * @return the texture itself allowing "fluent" like uniform updates
  14917. */
  14918. setColor4(name: string, value: Color4): ProceduralTexture;
  14919. /**
  14920. * Set a vec2 in the shader from a Vector2.
  14921. * @param name Define the name of the uniform as defined in the shader
  14922. * @param value Define the value to give to the uniform
  14923. * @return the texture itself allowing "fluent" like uniform updates
  14924. */
  14925. setVector2(name: string, value: Vector2): ProceduralTexture;
  14926. /**
  14927. * Set a vec3 in the shader from a Vector3.
  14928. * @param name Define the name of the uniform as defined in the shader
  14929. * @param value Define the value to give to the uniform
  14930. * @return the texture itself allowing "fluent" like uniform updates
  14931. */
  14932. setVector3(name: string, value: Vector3): ProceduralTexture;
  14933. /**
  14934. * Set a mat4 in the shader from a MAtrix.
  14935. * @param name Define the name of the uniform as defined in the shader
  14936. * @param value Define the value to give to the uniform
  14937. * @return the texture itself allowing "fluent" like uniform updates
  14938. */
  14939. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14940. /**
  14941. * Render the texture to its associated render target.
  14942. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14943. */
  14944. render(useCameraPostProcess?: boolean): void;
  14945. /**
  14946. * Clone the texture.
  14947. * @returns the cloned texture
  14948. */
  14949. clone(): ProceduralTexture;
  14950. /**
  14951. * Dispose the texture and release its associated resources.
  14952. */
  14953. dispose(): void;
  14954. }
  14955. }
  14956. declare module BABYLON {
  14957. /**
  14958. * This represents the base class for particle system in Babylon.
  14959. * 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.
  14960. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14961. * @example https://doc.babylonjs.com/babylon101/particles
  14962. */
  14963. export class BaseParticleSystem {
  14964. /**
  14965. * Source color is added to the destination color without alpha affecting the result
  14966. */
  14967. static BLENDMODE_ONEONE: number;
  14968. /**
  14969. * Blend current color and particle color using particle’s alpha
  14970. */
  14971. static BLENDMODE_STANDARD: number;
  14972. /**
  14973. * Add current color and particle color multiplied by particle’s alpha
  14974. */
  14975. static BLENDMODE_ADD: number;
  14976. /**
  14977. * Multiply current color with particle color
  14978. */
  14979. static BLENDMODE_MULTIPLY: number;
  14980. /**
  14981. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14982. */
  14983. static BLENDMODE_MULTIPLYADD: number;
  14984. /**
  14985. * List of animations used by the particle system.
  14986. */
  14987. animations: Animation[];
  14988. /**
  14989. * Gets or sets the unique id of the particle system
  14990. */
  14991. uniqueId: number;
  14992. /**
  14993. * The id of the Particle system.
  14994. */
  14995. id: string;
  14996. /**
  14997. * The friendly name of the Particle system.
  14998. */
  14999. name: string;
  15000. /**
  15001. * Snippet ID if the particle system was created from the snippet server
  15002. */
  15003. snippetId: string;
  15004. /**
  15005. * The rendering group used by the Particle system to chose when to render.
  15006. */
  15007. renderingGroupId: number;
  15008. /**
  15009. * The emitter represents the Mesh or position we are attaching the particle system to.
  15010. */
  15011. emitter: Nullable<AbstractMesh | Vector3>;
  15012. /**
  15013. * The maximum number of particles to emit per frame
  15014. */
  15015. emitRate: number;
  15016. /**
  15017. * If you want to launch only a few particles at once, that can be done, as well.
  15018. */
  15019. manualEmitCount: number;
  15020. /**
  15021. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15022. */
  15023. updateSpeed: number;
  15024. /**
  15025. * The amount of time the particle system is running (depends of the overall update speed).
  15026. */
  15027. targetStopDuration: number;
  15028. /**
  15029. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15030. */
  15031. disposeOnStop: boolean;
  15032. /**
  15033. * Minimum power of emitting particles.
  15034. */
  15035. minEmitPower: number;
  15036. /**
  15037. * Maximum power of emitting particles.
  15038. */
  15039. maxEmitPower: number;
  15040. /**
  15041. * Minimum life time of emitting particles.
  15042. */
  15043. minLifeTime: number;
  15044. /**
  15045. * Maximum life time of emitting particles.
  15046. */
  15047. maxLifeTime: number;
  15048. /**
  15049. * Minimum Size of emitting particles.
  15050. */
  15051. minSize: number;
  15052. /**
  15053. * Maximum Size of emitting particles.
  15054. */
  15055. maxSize: number;
  15056. /**
  15057. * Minimum scale of emitting particles on X axis.
  15058. */
  15059. minScaleX: number;
  15060. /**
  15061. * Maximum scale of emitting particles on X axis.
  15062. */
  15063. maxScaleX: number;
  15064. /**
  15065. * Minimum scale of emitting particles on Y axis.
  15066. */
  15067. minScaleY: number;
  15068. /**
  15069. * Maximum scale of emitting particles on Y axis.
  15070. */
  15071. maxScaleY: number;
  15072. /**
  15073. * Gets or sets the minimal initial rotation in radians.
  15074. */
  15075. minInitialRotation: number;
  15076. /**
  15077. * Gets or sets the maximal initial rotation in radians.
  15078. */
  15079. maxInitialRotation: number;
  15080. /**
  15081. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15082. */
  15083. minAngularSpeed: number;
  15084. /**
  15085. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15086. */
  15087. maxAngularSpeed: number;
  15088. /**
  15089. * The texture used to render each particle. (this can be a spritesheet)
  15090. */
  15091. particleTexture: Nullable<BaseTexture>;
  15092. /**
  15093. * The layer mask we are rendering the particles through.
  15094. */
  15095. layerMask: number;
  15096. /**
  15097. * This can help using your own shader to render the particle system.
  15098. * The according effect will be created
  15099. */
  15100. customShader: any;
  15101. /**
  15102. * By default particle system starts as soon as they are created. This prevents the
  15103. * automatic start to happen and let you decide when to start emitting particles.
  15104. */
  15105. preventAutoStart: boolean;
  15106. protected _rootUrl: string;
  15107. private _noiseTexture;
  15108. /**
  15109. * Gets or sets a texture used to add random noise to particle positions
  15110. */
  15111. get noiseTexture(): Nullable<ProceduralTexture>;
  15112. set noiseTexture(value: Nullable<ProceduralTexture>);
  15113. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15114. noiseStrength: Vector3;
  15115. /**
  15116. * Callback triggered when the particle animation is ending.
  15117. */
  15118. onAnimationEnd: Nullable<() => void>;
  15119. /**
  15120. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15121. */
  15122. blendMode: number;
  15123. /**
  15124. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15125. * to override the particles.
  15126. */
  15127. forceDepthWrite: boolean;
  15128. /** 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 */
  15129. preWarmCycles: number;
  15130. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15131. preWarmStepOffset: number;
  15132. /**
  15133. * 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)
  15134. */
  15135. spriteCellChangeSpeed: number;
  15136. /**
  15137. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15138. */
  15139. startSpriteCellID: number;
  15140. /**
  15141. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15142. */
  15143. endSpriteCellID: number;
  15144. /**
  15145. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15146. */
  15147. spriteCellWidth: number;
  15148. /**
  15149. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15150. */
  15151. spriteCellHeight: number;
  15152. /**
  15153. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15154. */
  15155. spriteRandomStartCell: boolean;
  15156. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15157. translationPivot: Vector2;
  15158. /** @hidden */
  15159. protected _isAnimationSheetEnabled: boolean;
  15160. /**
  15161. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15162. */
  15163. beginAnimationOnStart: boolean;
  15164. /**
  15165. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15166. */
  15167. beginAnimationFrom: number;
  15168. /**
  15169. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15170. */
  15171. beginAnimationTo: number;
  15172. /**
  15173. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15174. */
  15175. beginAnimationLoop: boolean;
  15176. /**
  15177. * Gets or sets a world offset applied to all particles
  15178. */
  15179. worldOffset: Vector3;
  15180. /**
  15181. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15182. */
  15183. get isAnimationSheetEnabled(): boolean;
  15184. set isAnimationSheetEnabled(value: boolean);
  15185. /**
  15186. * Get hosting scene
  15187. * @returns the scene
  15188. */
  15189. getScene(): Nullable<Scene>;
  15190. /**
  15191. * You can use gravity if you want to give an orientation to your particles.
  15192. */
  15193. gravity: Vector3;
  15194. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15195. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15196. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15197. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15198. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15199. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15200. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15201. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15202. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15203. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15204. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15205. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15206. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15207. /**
  15208. * Defines the delay in milliseconds before starting the system (0 by default)
  15209. */
  15210. startDelay: number;
  15211. /**
  15212. * Gets the current list of drag gradients.
  15213. * You must use addDragGradient and removeDragGradient to update this list
  15214. * @returns the list of drag gradients
  15215. */
  15216. getDragGradients(): Nullable<Array<FactorGradient>>;
  15217. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15218. limitVelocityDamping: number;
  15219. /**
  15220. * Gets the current list of limit velocity gradients.
  15221. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  15222. * @returns the list of limit velocity gradients
  15223. */
  15224. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15225. /**
  15226. * Gets the current list of color gradients.
  15227. * You must use addColorGradient and removeColorGradient to update this list
  15228. * @returns the list of color gradients
  15229. */
  15230. getColorGradients(): Nullable<Array<ColorGradient>>;
  15231. /**
  15232. * Gets the current list of size gradients.
  15233. * You must use addSizeGradient and removeSizeGradient to update this list
  15234. * @returns the list of size gradients
  15235. */
  15236. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15237. /**
  15238. * Gets the current list of color remap gradients.
  15239. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  15240. * @returns the list of color remap gradients
  15241. */
  15242. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15243. /**
  15244. * Gets the current list of alpha remap gradients.
  15245. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  15246. * @returns the list of alpha remap gradients
  15247. */
  15248. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15249. /**
  15250. * Gets the current list of life time gradients.
  15251. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  15252. * @returns the list of life time gradients
  15253. */
  15254. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15255. /**
  15256. * Gets the current list of angular speed gradients.
  15257. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  15258. * @returns the list of angular speed gradients
  15259. */
  15260. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15261. /**
  15262. * Gets the current list of velocity gradients.
  15263. * You must use addVelocityGradient and removeVelocityGradient to update this list
  15264. * @returns the list of velocity gradients
  15265. */
  15266. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15267. /**
  15268. * Gets the current list of start size gradients.
  15269. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  15270. * @returns the list of start size gradients
  15271. */
  15272. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15273. /**
  15274. * Gets the current list of emit rate gradients.
  15275. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  15276. * @returns the list of emit rate gradients
  15277. */
  15278. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15279. /**
  15280. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15281. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15282. */
  15283. get direction1(): Vector3;
  15284. set direction1(value: Vector3);
  15285. /**
  15286. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15287. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15288. */
  15289. get direction2(): Vector3;
  15290. set direction2(value: Vector3);
  15291. /**
  15292. * 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.
  15293. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15294. */
  15295. get minEmitBox(): Vector3;
  15296. set minEmitBox(value: Vector3);
  15297. /**
  15298. * 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.
  15299. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15300. */
  15301. get maxEmitBox(): Vector3;
  15302. set maxEmitBox(value: Vector3);
  15303. /**
  15304. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15305. */
  15306. color1: Color4;
  15307. /**
  15308. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15309. */
  15310. color2: Color4;
  15311. /**
  15312. * Color the particle will have at the end of its lifetime
  15313. */
  15314. colorDead: Color4;
  15315. /**
  15316. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15317. */
  15318. textureMask: Color4;
  15319. /**
  15320. * The particle emitter type defines the emitter used by the particle system.
  15321. * It can be for example box, sphere, or cone...
  15322. */
  15323. particleEmitterType: IParticleEmitterType;
  15324. /** @hidden */
  15325. _isSubEmitter: boolean;
  15326. /**
  15327. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15328. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15329. */
  15330. billboardMode: number;
  15331. protected _isBillboardBased: boolean;
  15332. /**
  15333. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15334. */
  15335. get isBillboardBased(): boolean;
  15336. set isBillboardBased(value: boolean);
  15337. /**
  15338. * The scene the particle system belongs to.
  15339. */
  15340. protected _scene: Nullable<Scene>;
  15341. /**
  15342. * The engine the particle system belongs to.
  15343. */
  15344. protected _engine: ThinEngine;
  15345. /**
  15346. * Local cache of defines for image processing.
  15347. */
  15348. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15349. /**
  15350. * Default configuration related to image processing available in the standard Material.
  15351. */
  15352. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15353. /**
  15354. * Gets the image processing configuration used either in this material.
  15355. */
  15356. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15357. /**
  15358. * Sets the Default image processing configuration used either in the this material.
  15359. *
  15360. * If sets to null, the scene one is in use.
  15361. */
  15362. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15363. /**
  15364. * Attaches a new image processing configuration to the Standard Material.
  15365. * @param configuration
  15366. */
  15367. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15368. /** @hidden */
  15369. protected _reset(): void;
  15370. /** @hidden */
  15371. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15372. /**
  15373. * Instantiates a particle system.
  15374. * 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.
  15375. * @param name The name of the particle system
  15376. */
  15377. constructor(name: string);
  15378. /**
  15379. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15380. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15381. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15382. * @returns the emitter
  15383. */
  15384. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15385. /**
  15386. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15387. * @param radius The radius of the hemisphere to emit from
  15388. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15389. * @returns the emitter
  15390. */
  15391. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15392. /**
  15393. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15394. * @param radius The radius of the sphere to emit from
  15395. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15396. * @returns the emitter
  15397. */
  15398. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15399. /**
  15400. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15401. * @param radius The radius of the sphere to emit from
  15402. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15403. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15404. * @returns the emitter
  15405. */
  15406. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15407. /**
  15408. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15409. * @param radius The radius of the emission cylinder
  15410. * @param height The height of the emission cylinder
  15411. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15412. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15413. * @returns the emitter
  15414. */
  15415. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15416. /**
  15417. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15418. * @param radius The radius of the cylinder to emit from
  15419. * @param height The height of the emission cylinder
  15420. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15421. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15422. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15423. * @returns the emitter
  15424. */
  15425. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15426. /**
  15427. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15428. * @param radius The radius of the cone to emit from
  15429. * @param angle The base angle of the cone
  15430. * @returns the emitter
  15431. */
  15432. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15433. /**
  15434. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15435. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15436. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15437. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15438. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15439. * @returns the emitter
  15440. */
  15441. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15442. }
  15443. }
  15444. declare module BABYLON {
  15445. /**
  15446. * Type of sub emitter
  15447. */
  15448. export enum SubEmitterType {
  15449. /**
  15450. * Attached to the particle over it's lifetime
  15451. */
  15452. ATTACHED = 0,
  15453. /**
  15454. * Created when the particle dies
  15455. */
  15456. END = 1
  15457. }
  15458. /**
  15459. * Sub emitter class used to emit particles from an existing particle
  15460. */
  15461. export class SubEmitter {
  15462. /**
  15463. * the particle system to be used by the sub emitter
  15464. */
  15465. particleSystem: ParticleSystem;
  15466. /**
  15467. * Type of the submitter (Default: END)
  15468. */
  15469. type: SubEmitterType;
  15470. /**
  15471. * 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)
  15472. * Note: This only is supported when using an emitter of type Mesh
  15473. */
  15474. inheritDirection: boolean;
  15475. /**
  15476. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15477. */
  15478. inheritedVelocityAmount: number;
  15479. /**
  15480. * Creates a sub emitter
  15481. * @param particleSystem the particle system to be used by the sub emitter
  15482. */
  15483. constructor(
  15484. /**
  15485. * the particle system to be used by the sub emitter
  15486. */
  15487. particleSystem: ParticleSystem);
  15488. /**
  15489. * Clones the sub emitter
  15490. * @returns the cloned sub emitter
  15491. */
  15492. clone(): SubEmitter;
  15493. /**
  15494. * Serialize current object to a JSON object
  15495. * @returns the serialized object
  15496. */
  15497. serialize(): any;
  15498. /** @hidden */
  15499. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15500. /**
  15501. * Creates a new SubEmitter from a serialized JSON version
  15502. * @param serializationObject defines the JSON object to read from
  15503. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15504. * @param rootUrl defines the rootUrl for data loading
  15505. * @returns a new SubEmitter
  15506. */
  15507. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15508. /** Release associated resources */
  15509. dispose(): void;
  15510. }
  15511. }
  15512. declare module BABYLON {
  15513. /** @hidden */
  15514. export var clipPlaneFragmentDeclaration: {
  15515. name: string;
  15516. shader: string;
  15517. };
  15518. }
  15519. declare module BABYLON {
  15520. /** @hidden */
  15521. export var imageProcessingDeclaration: {
  15522. name: string;
  15523. shader: string;
  15524. };
  15525. }
  15526. declare module BABYLON {
  15527. /** @hidden */
  15528. export var imageProcessingFunctions: {
  15529. name: string;
  15530. shader: string;
  15531. };
  15532. }
  15533. declare module BABYLON {
  15534. /** @hidden */
  15535. export var clipPlaneFragment: {
  15536. name: string;
  15537. shader: string;
  15538. };
  15539. }
  15540. declare module BABYLON {
  15541. /** @hidden */
  15542. export var particlesPixelShader: {
  15543. name: string;
  15544. shader: string;
  15545. };
  15546. }
  15547. declare module BABYLON {
  15548. /** @hidden */
  15549. export var clipPlaneVertexDeclaration: {
  15550. name: string;
  15551. shader: string;
  15552. };
  15553. }
  15554. declare module BABYLON {
  15555. /** @hidden */
  15556. export var clipPlaneVertex: {
  15557. name: string;
  15558. shader: string;
  15559. };
  15560. }
  15561. declare module BABYLON {
  15562. /** @hidden */
  15563. export var particlesVertexShader: {
  15564. name: string;
  15565. shader: string;
  15566. };
  15567. }
  15568. declare module BABYLON {
  15569. /**
  15570. * Interface used to define entities containing multiple clip planes
  15571. */
  15572. export interface IClipPlanesHolder {
  15573. /**
  15574. * Gets or sets the active clipplane 1
  15575. */
  15576. clipPlane: Nullable<Plane>;
  15577. /**
  15578. * Gets or sets the active clipplane 2
  15579. */
  15580. clipPlane2: Nullable<Plane>;
  15581. /**
  15582. * Gets or sets the active clipplane 3
  15583. */
  15584. clipPlane3: Nullable<Plane>;
  15585. /**
  15586. * Gets or sets the active clipplane 4
  15587. */
  15588. clipPlane4: Nullable<Plane>;
  15589. /**
  15590. * Gets or sets the active clipplane 5
  15591. */
  15592. clipPlane5: Nullable<Plane>;
  15593. /**
  15594. * Gets or sets the active clipplane 6
  15595. */
  15596. clipPlane6: Nullable<Plane>;
  15597. }
  15598. }
  15599. declare module BABYLON {
  15600. /**
  15601. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15602. *
  15603. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15604. *
  15605. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15606. */
  15607. export class ThinMaterialHelper {
  15608. /**
  15609. * Binds the clip plane information from the holder to the effect.
  15610. * @param effect The effect we are binding the data to
  15611. * @param holder The entity containing the clip plane information
  15612. */
  15613. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15614. }
  15615. }
  15616. declare module BABYLON {
  15617. interface ThinEngine {
  15618. /**
  15619. * Sets alpha constants used by some alpha blending modes
  15620. * @param r defines the red component
  15621. * @param g defines the green component
  15622. * @param b defines the blue component
  15623. * @param a defines the alpha component
  15624. */
  15625. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15626. /**
  15627. * Sets the current alpha mode
  15628. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15629. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15630. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15631. */
  15632. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15633. /**
  15634. * Gets the current alpha mode
  15635. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15636. * @returns the current alpha mode
  15637. */
  15638. getAlphaMode(): number;
  15639. /**
  15640. * Sets the current alpha equation
  15641. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15642. */
  15643. setAlphaEquation(equation: number): void;
  15644. /**
  15645. * Gets the current alpha equation.
  15646. * @returns the current alpha equation
  15647. */
  15648. getAlphaEquation(): number;
  15649. }
  15650. }
  15651. declare module BABYLON {
  15652. /**
  15653. * This represents a particle system in Babylon.
  15654. * 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.
  15655. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15656. * @example https://doc.babylonjs.com/babylon101/particles
  15657. */
  15658. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15659. /**
  15660. * Billboard mode will only apply to Y axis
  15661. */
  15662. static readonly BILLBOARDMODE_Y: number;
  15663. /**
  15664. * Billboard mode will apply to all axes
  15665. */
  15666. static readonly BILLBOARDMODE_ALL: number;
  15667. /**
  15668. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15669. */
  15670. static readonly BILLBOARDMODE_STRETCHED: number;
  15671. /**
  15672. * This function can be defined to provide custom update for active particles.
  15673. * This function will be called instead of regular update (age, position, color, etc.).
  15674. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15675. */
  15676. updateFunction: (particles: Particle[]) => void;
  15677. private _emitterWorldMatrix;
  15678. /**
  15679. * This function can be defined to specify initial direction for every new particle.
  15680. * It by default use the emitterType defined function
  15681. */
  15682. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15683. /**
  15684. * This function can be defined to specify initial position for every new particle.
  15685. * It by default use the emitterType defined function
  15686. */
  15687. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15688. /**
  15689. * @hidden
  15690. */
  15691. _inheritedVelocityOffset: Vector3;
  15692. /**
  15693. * An event triggered when the system is disposed
  15694. */
  15695. onDisposeObservable: Observable<IParticleSystem>;
  15696. /**
  15697. * An event triggered when the system is stopped
  15698. */
  15699. onStoppedObservable: Observable<IParticleSystem>;
  15700. private _onDisposeObserver;
  15701. /**
  15702. * Sets a callback that will be triggered when the system is disposed
  15703. */
  15704. set onDispose(callback: () => void);
  15705. private _particles;
  15706. private _epsilon;
  15707. private _capacity;
  15708. private _stockParticles;
  15709. private _newPartsExcess;
  15710. private _vertexData;
  15711. private _vertexBuffer;
  15712. private _vertexBuffers;
  15713. private _spriteBuffer;
  15714. private _indexBuffer;
  15715. private _effect;
  15716. private _customEffect;
  15717. private _cachedDefines;
  15718. private _scaledColorStep;
  15719. private _colorDiff;
  15720. private _scaledDirection;
  15721. private _scaledGravity;
  15722. private _currentRenderId;
  15723. private _alive;
  15724. private _useInstancing;
  15725. private _vertexArrayObject;
  15726. private _started;
  15727. private _stopped;
  15728. private _actualFrame;
  15729. private _scaledUpdateSpeed;
  15730. private _vertexBufferSize;
  15731. /** @hidden */
  15732. _currentEmitRateGradient: Nullable<FactorGradient>;
  15733. /** @hidden */
  15734. _currentEmitRate1: number;
  15735. /** @hidden */
  15736. _currentEmitRate2: number;
  15737. /** @hidden */
  15738. _currentStartSizeGradient: Nullable<FactorGradient>;
  15739. /** @hidden */
  15740. _currentStartSize1: number;
  15741. /** @hidden */
  15742. _currentStartSize2: number;
  15743. private readonly _rawTextureWidth;
  15744. private _rampGradientsTexture;
  15745. private _useRampGradients;
  15746. /** Gets or sets a matrix to use to compute projection */
  15747. defaultProjectionMatrix: Matrix;
  15748. /** Gets or sets a matrix to use to compute view */
  15749. defaultViewMatrix: Matrix;
  15750. /** Gets or sets a boolean indicating that ramp gradients must be used
  15751. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15752. */
  15753. get useRampGradients(): boolean;
  15754. set useRampGradients(value: boolean);
  15755. /**
  15756. * 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.
  15757. * 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: [])
  15758. */
  15759. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15760. private _subEmitters;
  15761. /**
  15762. * @hidden
  15763. * If the particle systems emitter should be disposed when the particle system is disposed
  15764. */
  15765. _disposeEmitterOnDispose: boolean;
  15766. /**
  15767. * The current active Sub-systems, this property is used by the root particle system only.
  15768. */
  15769. activeSubSystems: Array<ParticleSystem>;
  15770. /**
  15771. * Specifies if the particles are updated in emitter local space or world space
  15772. */
  15773. isLocal: boolean;
  15774. private _rootParticleSystem;
  15775. /**
  15776. * Gets the current list of active particles
  15777. */
  15778. get particles(): Particle[];
  15779. /**
  15780. * Gets the number of particles active at the same time.
  15781. * @returns The number of active particles.
  15782. */
  15783. getActiveCount(): number;
  15784. /**
  15785. * Returns the string "ParticleSystem"
  15786. * @returns a string containing the class name
  15787. */
  15788. getClassName(): string;
  15789. /**
  15790. * Gets a boolean indicating that the system is stopping
  15791. * @returns true if the system is currently stopping
  15792. */
  15793. isStopping(): boolean;
  15794. /**
  15795. * Gets the custom effect used to render the particles
  15796. * @param blendMode Blend mode for which the effect should be retrieved
  15797. * @returns The effect
  15798. */
  15799. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15800. /**
  15801. * Sets the custom effect used to render the particles
  15802. * @param effect The effect to set
  15803. * @param blendMode Blend mode for which the effect should be set
  15804. */
  15805. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15806. /** @hidden */
  15807. private _onBeforeDrawParticlesObservable;
  15808. /**
  15809. * Observable that will be called just before the particles are drawn
  15810. */
  15811. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15812. /**
  15813. * Gets the name of the particle vertex shader
  15814. */
  15815. get vertexShaderName(): string;
  15816. /**
  15817. * Instantiates a particle system.
  15818. * 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.
  15819. * @param name The name of the particle system
  15820. * @param capacity The max number of particles alive at the same time
  15821. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15822. * @param customEffect a custom effect used to change the way particles are rendered by default
  15823. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15824. * @param epsilon Offset used to render the particles
  15825. */
  15826. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15827. private _addFactorGradient;
  15828. private _removeFactorGradient;
  15829. /**
  15830. * Adds a new life time gradient
  15831. * @param gradient defines the gradient to use (between 0 and 1)
  15832. * @param factor defines the life time factor to affect to the specified gradient
  15833. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15834. * @returns the current particle system
  15835. */
  15836. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15837. /**
  15838. * Remove a specific life time gradient
  15839. * @param gradient defines the gradient to remove
  15840. * @returns the current particle system
  15841. */
  15842. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15843. /**
  15844. * Adds a new size gradient
  15845. * @param gradient defines the gradient to use (between 0 and 1)
  15846. * @param factor defines the size factor to affect to the specified gradient
  15847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15848. * @returns the current particle system
  15849. */
  15850. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15851. /**
  15852. * Remove a specific size gradient
  15853. * @param gradient defines the gradient to remove
  15854. * @returns the current particle system
  15855. */
  15856. removeSizeGradient(gradient: number): IParticleSystem;
  15857. /**
  15858. * Adds a new color remap gradient
  15859. * @param gradient defines the gradient to use (between 0 and 1)
  15860. * @param min defines the color remap minimal range
  15861. * @param max defines the color remap maximal range
  15862. * @returns the current particle system
  15863. */
  15864. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15865. /**
  15866. * Remove a specific color remap gradient
  15867. * @param gradient defines the gradient to remove
  15868. * @returns the current particle system
  15869. */
  15870. removeColorRemapGradient(gradient: number): IParticleSystem;
  15871. /**
  15872. * Adds a new alpha remap gradient
  15873. * @param gradient defines the gradient to use (between 0 and 1)
  15874. * @param min defines the alpha remap minimal range
  15875. * @param max defines the alpha remap maximal range
  15876. * @returns the current particle system
  15877. */
  15878. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15879. /**
  15880. * Remove a specific alpha remap gradient
  15881. * @param gradient defines the gradient to remove
  15882. * @returns the current particle system
  15883. */
  15884. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15885. /**
  15886. * Adds a new angular speed gradient
  15887. * @param gradient defines the gradient to use (between 0 and 1)
  15888. * @param factor defines the angular speed to affect to the specified gradient
  15889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15890. * @returns the current particle system
  15891. */
  15892. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15893. /**
  15894. * Remove a specific angular speed gradient
  15895. * @param gradient defines the gradient to remove
  15896. * @returns the current particle system
  15897. */
  15898. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15899. /**
  15900. * Adds a new velocity gradient
  15901. * @param gradient defines the gradient to use (between 0 and 1)
  15902. * @param factor defines the velocity to affect to the specified gradient
  15903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15904. * @returns the current particle system
  15905. */
  15906. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15907. /**
  15908. * Remove a specific velocity gradient
  15909. * @param gradient defines the gradient to remove
  15910. * @returns the current particle system
  15911. */
  15912. removeVelocityGradient(gradient: number): IParticleSystem;
  15913. /**
  15914. * Adds a new limit velocity gradient
  15915. * @param gradient defines the gradient to use (between 0 and 1)
  15916. * @param factor defines the limit velocity value to affect to the specified gradient
  15917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15918. * @returns the current particle system
  15919. */
  15920. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15921. /**
  15922. * Remove a specific limit velocity gradient
  15923. * @param gradient defines the gradient to remove
  15924. * @returns the current particle system
  15925. */
  15926. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15927. /**
  15928. * Adds a new drag gradient
  15929. * @param gradient defines the gradient to use (between 0 and 1)
  15930. * @param factor defines the drag value to affect to the specified gradient
  15931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15932. * @returns the current particle system
  15933. */
  15934. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15935. /**
  15936. * Remove a specific drag gradient
  15937. * @param gradient defines the gradient to remove
  15938. * @returns the current particle system
  15939. */
  15940. removeDragGradient(gradient: number): IParticleSystem;
  15941. /**
  15942. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15943. * @param gradient defines the gradient to use (between 0 and 1)
  15944. * @param factor defines the emit rate value to affect to the specified gradient
  15945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15946. * @returns the current particle system
  15947. */
  15948. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15949. /**
  15950. * Remove a specific emit rate gradient
  15951. * @param gradient defines the gradient to remove
  15952. * @returns the current particle system
  15953. */
  15954. removeEmitRateGradient(gradient: number): IParticleSystem;
  15955. /**
  15956. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15957. * @param gradient defines the gradient to use (between 0 and 1)
  15958. * @param factor defines the start size value to affect to the specified gradient
  15959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15960. * @returns the current particle system
  15961. */
  15962. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15963. /**
  15964. * Remove a specific start size gradient
  15965. * @param gradient defines the gradient to remove
  15966. * @returns the current particle system
  15967. */
  15968. removeStartSizeGradient(gradient: number): IParticleSystem;
  15969. private _createRampGradientTexture;
  15970. /**
  15971. * Gets the current list of ramp gradients.
  15972. * You must use addRampGradient and removeRampGradient to update this list
  15973. * @returns the list of ramp gradients
  15974. */
  15975. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15976. /** Force the system to rebuild all gradients that need to be resync */
  15977. forceRefreshGradients(): void;
  15978. private _syncRampGradientTexture;
  15979. /**
  15980. * Adds a new ramp gradient used to remap particle colors
  15981. * @param gradient defines the gradient to use (between 0 and 1)
  15982. * @param color defines the color to affect to the specified gradient
  15983. * @returns the current particle system
  15984. */
  15985. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15986. /**
  15987. * Remove a specific ramp gradient
  15988. * @param gradient defines the gradient to remove
  15989. * @returns the current particle system
  15990. */
  15991. removeRampGradient(gradient: number): ParticleSystem;
  15992. /**
  15993. * Adds a new color gradient
  15994. * @param gradient defines the gradient to use (between 0 and 1)
  15995. * @param color1 defines the color to affect to the specified gradient
  15996. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15997. * @returns this particle system
  15998. */
  15999. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16000. /**
  16001. * Remove a specific color gradient
  16002. * @param gradient defines the gradient to remove
  16003. * @returns this particle system
  16004. */
  16005. removeColorGradient(gradient: number): IParticleSystem;
  16006. private _fetchR;
  16007. protected _reset(): void;
  16008. private _resetEffect;
  16009. private _createVertexBuffers;
  16010. private _createIndexBuffer;
  16011. /**
  16012. * Gets the maximum number of particles active at the same time.
  16013. * @returns The max number of active particles.
  16014. */
  16015. getCapacity(): number;
  16016. /**
  16017. * Gets whether there are still active particles in the system.
  16018. * @returns True if it is alive, otherwise false.
  16019. */
  16020. isAlive(): boolean;
  16021. /**
  16022. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16023. * @returns True if it has been started, otherwise false.
  16024. */
  16025. isStarted(): boolean;
  16026. private _prepareSubEmitterInternalArray;
  16027. /**
  16028. * Starts the particle system and begins to emit
  16029. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16030. */
  16031. start(delay?: number): void;
  16032. /**
  16033. * Stops the particle system.
  16034. * @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.
  16035. */
  16036. stop(stopSubEmitters?: boolean): void;
  16037. /**
  16038. * Remove all active particles
  16039. */
  16040. reset(): void;
  16041. /**
  16042. * @hidden (for internal use only)
  16043. */
  16044. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16045. /**
  16046. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16047. * Its lifetime will start back at 0.
  16048. */
  16049. recycleParticle: (particle: Particle) => void;
  16050. private _stopSubEmitters;
  16051. private _createParticle;
  16052. private _removeFromRoot;
  16053. private _emitFromParticle;
  16054. private _update;
  16055. /** @hidden */
  16056. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16057. /** @hidden */
  16058. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16059. /**
  16060. * Fill the defines array according to the current settings of the particle system
  16061. * @param defines Array to be updated
  16062. * @param blendMode blend mode to take into account when updating the array
  16063. */
  16064. fillDefines(defines: Array<string>, blendMode: number): void;
  16065. /**
  16066. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16067. * @param uniforms Uniforms array to fill
  16068. * @param attributes Attributes array to fill
  16069. * @param samplers Samplers array to fill
  16070. */
  16071. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16072. /** @hidden */
  16073. private _getEffect;
  16074. /**
  16075. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16076. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16077. */
  16078. animate(preWarmOnly?: boolean): void;
  16079. private _appendParticleVertices;
  16080. /**
  16081. * Rebuilds the particle system.
  16082. */
  16083. rebuild(): void;
  16084. /**
  16085. * Is this system ready to be used/rendered
  16086. * @return true if the system is ready
  16087. */
  16088. isReady(): boolean;
  16089. private _render;
  16090. /**
  16091. * Renders the particle system in its current state.
  16092. * @returns the current number of particles
  16093. */
  16094. render(): number;
  16095. /**
  16096. * Disposes the particle system and free the associated resources
  16097. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  16098. */
  16099. dispose(disposeTexture?: boolean): void;
  16100. /**
  16101. * Clones the particle system.
  16102. * @param name The name of the cloned object
  16103. * @param newEmitter The new emitter to use
  16104. * @returns the cloned particle system
  16105. */
  16106. clone(name: string, newEmitter: any): ParticleSystem;
  16107. /**
  16108. * Serializes the particle system to a JSON object
  16109. * @param serializeTexture defines if the texture must be serialized as well
  16110. * @returns the JSON object
  16111. */
  16112. serialize(serializeTexture?: boolean): any;
  16113. /** @hidden */
  16114. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16115. /** @hidden */
  16116. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16117. /**
  16118. * Parses a JSON object to create a particle system.
  16119. * @param parsedParticleSystem The JSON object to parse
  16120. * @param sceneOrEngine The scene or the engine to create the particle system in
  16121. * @param rootUrl The root url to use to load external dependencies like texture
  16122. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16123. * @returns the Parsed particle system
  16124. */
  16125. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16126. }
  16127. }
  16128. declare module BABYLON {
  16129. /**
  16130. * A particle represents one of the element emitted by a particle system.
  16131. * This is mainly define by its coordinates, direction, velocity and age.
  16132. */
  16133. export class Particle {
  16134. /**
  16135. * The particle system the particle belongs to.
  16136. */
  16137. particleSystem: ParticleSystem;
  16138. private static _Count;
  16139. /**
  16140. * Unique ID of the particle
  16141. */
  16142. id: number;
  16143. /**
  16144. * The world position of the particle in the scene.
  16145. */
  16146. position: Vector3;
  16147. /**
  16148. * The world direction of the particle in the scene.
  16149. */
  16150. direction: Vector3;
  16151. /**
  16152. * The color of the particle.
  16153. */
  16154. color: Color4;
  16155. /**
  16156. * The color change of the particle per step.
  16157. */
  16158. colorStep: Color4;
  16159. /**
  16160. * Defines how long will the life of the particle be.
  16161. */
  16162. lifeTime: number;
  16163. /**
  16164. * The current age of the particle.
  16165. */
  16166. age: number;
  16167. /**
  16168. * The current size of the particle.
  16169. */
  16170. size: number;
  16171. /**
  16172. * The current scale of the particle.
  16173. */
  16174. scale: Vector2;
  16175. /**
  16176. * The current angle of the particle.
  16177. */
  16178. angle: number;
  16179. /**
  16180. * Defines how fast is the angle changing.
  16181. */
  16182. angularSpeed: number;
  16183. /**
  16184. * Defines the cell index used by the particle to be rendered from a sprite.
  16185. */
  16186. cellIndex: number;
  16187. /**
  16188. * The information required to support color remapping
  16189. */
  16190. remapData: Vector4;
  16191. /** @hidden */
  16192. _randomCellOffset?: number;
  16193. /** @hidden */
  16194. _initialDirection: Nullable<Vector3>;
  16195. /** @hidden */
  16196. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16197. /** @hidden */
  16198. _initialStartSpriteCellID: number;
  16199. /** @hidden */
  16200. _initialEndSpriteCellID: number;
  16201. /** @hidden */
  16202. _currentColorGradient: Nullable<ColorGradient>;
  16203. /** @hidden */
  16204. _currentColor1: Color4;
  16205. /** @hidden */
  16206. _currentColor2: Color4;
  16207. /** @hidden */
  16208. _currentSizeGradient: Nullable<FactorGradient>;
  16209. /** @hidden */
  16210. _currentSize1: number;
  16211. /** @hidden */
  16212. _currentSize2: number;
  16213. /** @hidden */
  16214. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16215. /** @hidden */
  16216. _currentAngularSpeed1: number;
  16217. /** @hidden */
  16218. _currentAngularSpeed2: number;
  16219. /** @hidden */
  16220. _currentVelocityGradient: Nullable<FactorGradient>;
  16221. /** @hidden */
  16222. _currentVelocity1: number;
  16223. /** @hidden */
  16224. _currentVelocity2: number;
  16225. /** @hidden */
  16226. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16227. /** @hidden */
  16228. _currentLimitVelocity1: number;
  16229. /** @hidden */
  16230. _currentLimitVelocity2: number;
  16231. /** @hidden */
  16232. _currentDragGradient: Nullable<FactorGradient>;
  16233. /** @hidden */
  16234. _currentDrag1: number;
  16235. /** @hidden */
  16236. _currentDrag2: number;
  16237. /** @hidden */
  16238. _randomNoiseCoordinates1: Vector3;
  16239. /** @hidden */
  16240. _randomNoiseCoordinates2: Vector3;
  16241. /** @hidden */
  16242. _localPosition?: Vector3;
  16243. /**
  16244. * Creates a new instance Particle
  16245. * @param particleSystem the particle system the particle belongs to
  16246. */
  16247. constructor(
  16248. /**
  16249. * The particle system the particle belongs to.
  16250. */
  16251. particleSystem: ParticleSystem);
  16252. private updateCellInfoFromSystem;
  16253. /**
  16254. * Defines how the sprite cell index is updated for the particle
  16255. */
  16256. updateCellIndex(): void;
  16257. /** @hidden */
  16258. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16259. /** @hidden */
  16260. _inheritParticleInfoToSubEmitters(): void;
  16261. /** @hidden */
  16262. _reset(): void;
  16263. /**
  16264. * Copy the properties of particle to another one.
  16265. * @param other the particle to copy the information to.
  16266. */
  16267. copyTo(other: Particle): void;
  16268. }
  16269. }
  16270. declare module BABYLON {
  16271. /**
  16272. * Particle emitter represents a volume emitting particles.
  16273. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16274. */
  16275. export interface IParticleEmitterType {
  16276. /**
  16277. * Called by the particle System when the direction is computed for the created particle.
  16278. * @param worldMatrix is the world matrix of the particle system
  16279. * @param directionToUpdate is the direction vector to update with the result
  16280. * @param particle is the particle we are computed the direction for
  16281. * @param isLocal defines if the direction should be set in local space
  16282. */
  16283. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16284. /**
  16285. * Called by the particle System when the position is computed for the created particle.
  16286. * @param worldMatrix is the world matrix of the particle system
  16287. * @param positionToUpdate is the position vector to update with the result
  16288. * @param particle is the particle we are computed the position for
  16289. * @param isLocal defines if the position should be set in local space
  16290. */
  16291. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16292. /**
  16293. * Clones the current emitter and returns a copy of it
  16294. * @returns the new emitter
  16295. */
  16296. clone(): IParticleEmitterType;
  16297. /**
  16298. * Called by the GPUParticleSystem to setup the update shader
  16299. * @param effect defines the update shader
  16300. */
  16301. applyToShader(effect: Effect): void;
  16302. /**
  16303. * Returns a string to use to update the GPU particles update shader
  16304. * @returns the effect defines string
  16305. */
  16306. getEffectDefines(): string;
  16307. /**
  16308. * Returns a string representing the class name
  16309. * @returns a string containing the class name
  16310. */
  16311. getClassName(): string;
  16312. /**
  16313. * Serializes the particle system to a JSON object.
  16314. * @returns the JSON object
  16315. */
  16316. serialize(): any;
  16317. /**
  16318. * Parse properties from a JSON object
  16319. * @param serializationObject defines the JSON object
  16320. * @param scene defines the hosting scene
  16321. */
  16322. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16323. }
  16324. }
  16325. declare module BABYLON {
  16326. /**
  16327. * Particle emitter emitting particles from the inside of a box.
  16328. * It emits the particles randomly between 2 given directions.
  16329. */
  16330. export class BoxParticleEmitter implements IParticleEmitterType {
  16331. /**
  16332. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16333. */
  16334. direction1: Vector3;
  16335. /**
  16336. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16337. */
  16338. direction2: Vector3;
  16339. /**
  16340. * 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.
  16341. */
  16342. minEmitBox: Vector3;
  16343. /**
  16344. * 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.
  16345. */
  16346. maxEmitBox: Vector3;
  16347. /**
  16348. * Creates a new instance BoxParticleEmitter
  16349. */
  16350. constructor();
  16351. /**
  16352. * Called by the particle System when the direction is computed for the created particle.
  16353. * @param worldMatrix is the world matrix of the particle system
  16354. * @param directionToUpdate is the direction vector to update with the result
  16355. * @param particle is the particle we are computed the direction for
  16356. * @param isLocal defines if the direction should be set in local space
  16357. */
  16358. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16359. /**
  16360. * Called by the particle System when the position is computed for the created particle.
  16361. * @param worldMatrix is the world matrix of the particle system
  16362. * @param positionToUpdate is the position vector to update with the result
  16363. * @param particle is the particle we are computed the position for
  16364. * @param isLocal defines if the position should be set in local space
  16365. */
  16366. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16367. /**
  16368. * Clones the current emitter and returns a copy of it
  16369. * @returns the new emitter
  16370. */
  16371. clone(): BoxParticleEmitter;
  16372. /**
  16373. * Called by the GPUParticleSystem to setup the update shader
  16374. * @param effect defines the update shader
  16375. */
  16376. applyToShader(effect: Effect): void;
  16377. /**
  16378. * Returns a string to use to update the GPU particles update shader
  16379. * @returns a string containing the defines string
  16380. */
  16381. getEffectDefines(): string;
  16382. /**
  16383. * Returns the string "BoxParticleEmitter"
  16384. * @returns a string containing the class name
  16385. */
  16386. getClassName(): string;
  16387. /**
  16388. * Serializes the particle system to a JSON object.
  16389. * @returns the JSON object
  16390. */
  16391. serialize(): any;
  16392. /**
  16393. * Parse properties from a JSON object
  16394. * @param serializationObject defines the JSON object
  16395. */
  16396. parse(serializationObject: any): void;
  16397. }
  16398. }
  16399. declare module BABYLON {
  16400. /**
  16401. * Particle emitter emitting particles from the inside of a cone.
  16402. * It emits the particles alongside the cone volume from the base to the particle.
  16403. * The emission direction might be randomized.
  16404. */
  16405. export class ConeParticleEmitter implements IParticleEmitterType {
  16406. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16407. directionRandomizer: number;
  16408. private _radius;
  16409. private _angle;
  16410. private _height;
  16411. /**
  16412. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16413. */
  16414. radiusRange: number;
  16415. /**
  16416. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16417. */
  16418. heightRange: number;
  16419. /**
  16420. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16421. */
  16422. emitFromSpawnPointOnly: boolean;
  16423. /**
  16424. * Gets or sets the radius of the emission cone
  16425. */
  16426. get radius(): number;
  16427. set radius(value: number);
  16428. /**
  16429. * Gets or sets the angle of the emission cone
  16430. */
  16431. get angle(): number;
  16432. set angle(value: number);
  16433. private _buildHeight;
  16434. /**
  16435. * Creates a new instance ConeParticleEmitter
  16436. * @param radius the radius of the emission cone (1 by default)
  16437. * @param angle the cone base angle (PI by default)
  16438. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16439. */
  16440. constructor(radius?: number, angle?: number,
  16441. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16442. directionRandomizer?: number);
  16443. /**
  16444. * Called by the particle System when the direction is computed for the created particle.
  16445. * @param worldMatrix is the world matrix of the particle system
  16446. * @param directionToUpdate is the direction vector to update with the result
  16447. * @param particle is the particle we are computed the direction for
  16448. * @param isLocal defines if the direction should be set in local space
  16449. */
  16450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16451. /**
  16452. * Called by the particle System when the position is computed for the created particle.
  16453. * @param worldMatrix is the world matrix of the particle system
  16454. * @param positionToUpdate is the position vector to update with the result
  16455. * @param particle is the particle we are computed the position for
  16456. * @param isLocal defines if the position should be set in local space
  16457. */
  16458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16459. /**
  16460. * Clones the current emitter and returns a copy of it
  16461. * @returns the new emitter
  16462. */
  16463. clone(): ConeParticleEmitter;
  16464. /**
  16465. * Called by the GPUParticleSystem to setup the update shader
  16466. * @param effect defines the update shader
  16467. */
  16468. applyToShader(effect: Effect): void;
  16469. /**
  16470. * Returns a string to use to update the GPU particles update shader
  16471. * @returns a string containing the defines string
  16472. */
  16473. getEffectDefines(): string;
  16474. /**
  16475. * Returns the string "ConeParticleEmitter"
  16476. * @returns a string containing the class name
  16477. */
  16478. getClassName(): string;
  16479. /**
  16480. * Serializes the particle system to a JSON object.
  16481. * @returns the JSON object
  16482. */
  16483. serialize(): any;
  16484. /**
  16485. * Parse properties from a JSON object
  16486. * @param serializationObject defines the JSON object
  16487. */
  16488. parse(serializationObject: any): void;
  16489. }
  16490. }
  16491. declare module BABYLON {
  16492. /**
  16493. * Particle emitter emitting particles from the inside of a cylinder.
  16494. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16495. */
  16496. export class CylinderParticleEmitter implements IParticleEmitterType {
  16497. /**
  16498. * The radius of the emission cylinder.
  16499. */
  16500. radius: number;
  16501. /**
  16502. * The height of the emission cylinder.
  16503. */
  16504. height: number;
  16505. /**
  16506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16507. */
  16508. radiusRange: number;
  16509. /**
  16510. * How much to randomize the particle direction [0-1].
  16511. */
  16512. directionRandomizer: number;
  16513. /**
  16514. * Creates a new instance CylinderParticleEmitter
  16515. * @param radius the radius of the emission cylinder (1 by default)
  16516. * @param height the height of the emission cylinder (1 by default)
  16517. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16518. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16519. */
  16520. constructor(
  16521. /**
  16522. * The radius of the emission cylinder.
  16523. */
  16524. radius?: number,
  16525. /**
  16526. * The height of the emission cylinder.
  16527. */
  16528. height?: number,
  16529. /**
  16530. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16531. */
  16532. radiusRange?: number,
  16533. /**
  16534. * How much to randomize the particle direction [0-1].
  16535. */
  16536. directionRandomizer?: number);
  16537. /**
  16538. * Called by the particle System when the direction is computed for the created particle.
  16539. * @param worldMatrix is the world matrix of the particle system
  16540. * @param directionToUpdate is the direction vector to update with the result
  16541. * @param particle is the particle we are computed the direction for
  16542. * @param isLocal defines if the direction should be set in local space
  16543. */
  16544. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16545. /**
  16546. * Called by the particle System when the position is computed for the created particle.
  16547. * @param worldMatrix is the world matrix of the particle system
  16548. * @param positionToUpdate is the position vector to update with the result
  16549. * @param particle is the particle we are computed the position for
  16550. * @param isLocal defines if the position should be set in local space
  16551. */
  16552. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16553. /**
  16554. * Clones the current emitter and returns a copy of it
  16555. * @returns the new emitter
  16556. */
  16557. clone(): CylinderParticleEmitter;
  16558. /**
  16559. * Called by the GPUParticleSystem to setup the update shader
  16560. * @param effect defines the update shader
  16561. */
  16562. applyToShader(effect: Effect): void;
  16563. /**
  16564. * Returns a string to use to update the GPU particles update shader
  16565. * @returns a string containing the defines string
  16566. */
  16567. getEffectDefines(): string;
  16568. /**
  16569. * Returns the string "CylinderParticleEmitter"
  16570. * @returns a string containing the class name
  16571. */
  16572. getClassName(): string;
  16573. /**
  16574. * Serializes the particle system to a JSON object.
  16575. * @returns the JSON object
  16576. */
  16577. serialize(): any;
  16578. /**
  16579. * Parse properties from a JSON object
  16580. * @param serializationObject defines the JSON object
  16581. */
  16582. parse(serializationObject: any): void;
  16583. }
  16584. /**
  16585. * Particle emitter emitting particles from the inside of a cylinder.
  16586. * It emits the particles randomly between two vectors.
  16587. */
  16588. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16589. /**
  16590. * The min limit of the emission direction.
  16591. */
  16592. direction1: Vector3;
  16593. /**
  16594. * The max limit of the emission direction.
  16595. */
  16596. direction2: Vector3;
  16597. /**
  16598. * Creates a new instance CylinderDirectedParticleEmitter
  16599. * @param radius the radius of the emission cylinder (1 by default)
  16600. * @param height the height of the emission cylinder (1 by default)
  16601. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16602. * @param direction1 the min limit of the emission direction (up vector by default)
  16603. * @param direction2 the max limit of the emission direction (up vector by default)
  16604. */
  16605. constructor(radius?: number, height?: number, radiusRange?: number,
  16606. /**
  16607. * The min limit of the emission direction.
  16608. */
  16609. direction1?: Vector3,
  16610. /**
  16611. * The max limit of the emission direction.
  16612. */
  16613. direction2?: Vector3);
  16614. /**
  16615. * Called by the particle System when the direction is computed for the created particle.
  16616. * @param worldMatrix is the world matrix of the particle system
  16617. * @param directionToUpdate is the direction vector to update with the result
  16618. * @param particle is the particle we are computed the direction for
  16619. */
  16620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16621. /**
  16622. * Clones the current emitter and returns a copy of it
  16623. * @returns the new emitter
  16624. */
  16625. clone(): CylinderDirectedParticleEmitter;
  16626. /**
  16627. * Called by the GPUParticleSystem to setup the update shader
  16628. * @param effect defines the update shader
  16629. */
  16630. applyToShader(effect: Effect): void;
  16631. /**
  16632. * Returns a string to use to update the GPU particles update shader
  16633. * @returns a string containing the defines string
  16634. */
  16635. getEffectDefines(): string;
  16636. /**
  16637. * Returns the string "CylinderDirectedParticleEmitter"
  16638. * @returns a string containing the class name
  16639. */
  16640. getClassName(): string;
  16641. /**
  16642. * Serializes the particle system to a JSON object.
  16643. * @returns the JSON object
  16644. */
  16645. serialize(): any;
  16646. /**
  16647. * Parse properties from a JSON object
  16648. * @param serializationObject defines the JSON object
  16649. */
  16650. parse(serializationObject: any): void;
  16651. }
  16652. }
  16653. declare module BABYLON {
  16654. /**
  16655. * Particle emitter emitting particles from the inside of a hemisphere.
  16656. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16657. */
  16658. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16659. /**
  16660. * The radius of the emission hemisphere.
  16661. */
  16662. radius: number;
  16663. /**
  16664. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16665. */
  16666. radiusRange: number;
  16667. /**
  16668. * How much to randomize the particle direction [0-1].
  16669. */
  16670. directionRandomizer: number;
  16671. /**
  16672. * Creates a new instance HemisphericParticleEmitter
  16673. * @param radius the radius of the emission hemisphere (1 by default)
  16674. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16675. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16676. */
  16677. constructor(
  16678. /**
  16679. * The radius of the emission hemisphere.
  16680. */
  16681. radius?: number,
  16682. /**
  16683. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16684. */
  16685. radiusRange?: number,
  16686. /**
  16687. * How much to randomize the particle direction [0-1].
  16688. */
  16689. directionRandomizer?: number);
  16690. /**
  16691. * Called by the particle System when the direction is computed for the created particle.
  16692. * @param worldMatrix is the world matrix of the particle system
  16693. * @param directionToUpdate is the direction vector to update with the result
  16694. * @param particle is the particle we are computed the direction for
  16695. * @param isLocal defines if the direction should be set in local space
  16696. */
  16697. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16698. /**
  16699. * Called by the particle System when the position is computed for the created particle.
  16700. * @param worldMatrix is the world matrix of the particle system
  16701. * @param positionToUpdate is the position vector to update with the result
  16702. * @param particle is the particle we are computed the position for
  16703. * @param isLocal defines if the position should be set in local space
  16704. */
  16705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16706. /**
  16707. * Clones the current emitter and returns a copy of it
  16708. * @returns the new emitter
  16709. */
  16710. clone(): HemisphericParticleEmitter;
  16711. /**
  16712. * Called by the GPUParticleSystem to setup the update shader
  16713. * @param effect defines the update shader
  16714. */
  16715. applyToShader(effect: Effect): void;
  16716. /**
  16717. * Returns a string to use to update the GPU particles update shader
  16718. * @returns a string containing the defines string
  16719. */
  16720. getEffectDefines(): string;
  16721. /**
  16722. * Returns the string "HemisphericParticleEmitter"
  16723. * @returns a string containing the class name
  16724. */
  16725. getClassName(): string;
  16726. /**
  16727. * Serializes the particle system to a JSON object.
  16728. * @returns the JSON object
  16729. */
  16730. serialize(): any;
  16731. /**
  16732. * Parse properties from a JSON object
  16733. * @param serializationObject defines the JSON object
  16734. */
  16735. parse(serializationObject: any): void;
  16736. }
  16737. }
  16738. declare module BABYLON {
  16739. /**
  16740. * Particle emitter emitting particles from a point.
  16741. * It emits the particles randomly between 2 given directions.
  16742. */
  16743. export class PointParticleEmitter implements IParticleEmitterType {
  16744. /**
  16745. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16746. */
  16747. direction1: Vector3;
  16748. /**
  16749. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16750. */
  16751. direction2: Vector3;
  16752. /**
  16753. * Creates a new instance PointParticleEmitter
  16754. */
  16755. constructor();
  16756. /**
  16757. * Called by the particle System when the direction is computed for the created particle.
  16758. * @param worldMatrix is the world matrix of the particle system
  16759. * @param directionToUpdate is the direction vector to update with the result
  16760. * @param particle is the particle we are computed the direction for
  16761. * @param isLocal defines if the direction should be set in local space
  16762. */
  16763. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16764. /**
  16765. * Called by the particle System when the position is computed for the created particle.
  16766. * @param worldMatrix is the world matrix of the particle system
  16767. * @param positionToUpdate is the position vector to update with the result
  16768. * @param particle is the particle we are computed the position for
  16769. * @param isLocal defines if the position should be set in local space
  16770. */
  16771. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16772. /**
  16773. * Clones the current emitter and returns a copy of it
  16774. * @returns the new emitter
  16775. */
  16776. clone(): PointParticleEmitter;
  16777. /**
  16778. * Called by the GPUParticleSystem to setup the update shader
  16779. * @param effect defines the update shader
  16780. */
  16781. applyToShader(effect: Effect): void;
  16782. /**
  16783. * Returns a string to use to update the GPU particles update shader
  16784. * @returns a string containing the defines string
  16785. */
  16786. getEffectDefines(): string;
  16787. /**
  16788. * Returns the string "PointParticleEmitter"
  16789. * @returns a string containing the class name
  16790. */
  16791. getClassName(): string;
  16792. /**
  16793. * Serializes the particle system to a JSON object.
  16794. * @returns the JSON object
  16795. */
  16796. serialize(): any;
  16797. /**
  16798. * Parse properties from a JSON object
  16799. * @param serializationObject defines the JSON object
  16800. */
  16801. parse(serializationObject: any): void;
  16802. }
  16803. }
  16804. declare module BABYLON {
  16805. /**
  16806. * Particle emitter emitting particles from the inside of a sphere.
  16807. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16808. */
  16809. export class SphereParticleEmitter implements IParticleEmitterType {
  16810. /**
  16811. * The radius of the emission sphere.
  16812. */
  16813. radius: number;
  16814. /**
  16815. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16816. */
  16817. radiusRange: number;
  16818. /**
  16819. * How much to randomize the particle direction [0-1].
  16820. */
  16821. directionRandomizer: number;
  16822. /**
  16823. * Creates a new instance SphereParticleEmitter
  16824. * @param radius the radius of the emission sphere (1 by default)
  16825. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16826. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16827. */
  16828. constructor(
  16829. /**
  16830. * The radius of the emission sphere.
  16831. */
  16832. radius?: number,
  16833. /**
  16834. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16835. */
  16836. radiusRange?: number,
  16837. /**
  16838. * How much to randomize the particle direction [0-1].
  16839. */
  16840. directionRandomizer?: number);
  16841. /**
  16842. * Called by the particle System when the direction is computed for the created particle.
  16843. * @param worldMatrix is the world matrix of the particle system
  16844. * @param directionToUpdate is the direction vector to update with the result
  16845. * @param particle is the particle we are computed the direction for
  16846. * @param isLocal defines if the direction should be set in local space
  16847. */
  16848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16849. /**
  16850. * Called by the particle System when the position is computed for the created particle.
  16851. * @param worldMatrix is the world matrix of the particle system
  16852. * @param positionToUpdate is the position vector to update with the result
  16853. * @param particle is the particle we are computed the position for
  16854. * @param isLocal defines if the position should be set in local space
  16855. */
  16856. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16857. /**
  16858. * Clones the current emitter and returns a copy of it
  16859. * @returns the new emitter
  16860. */
  16861. clone(): SphereParticleEmitter;
  16862. /**
  16863. * Called by the GPUParticleSystem to setup the update shader
  16864. * @param effect defines the update shader
  16865. */
  16866. applyToShader(effect: Effect): void;
  16867. /**
  16868. * Returns a string to use to update the GPU particles update shader
  16869. * @returns a string containing the defines string
  16870. */
  16871. getEffectDefines(): string;
  16872. /**
  16873. * Returns the string "SphereParticleEmitter"
  16874. * @returns a string containing the class name
  16875. */
  16876. getClassName(): string;
  16877. /**
  16878. * Serializes the particle system to a JSON object.
  16879. * @returns the JSON object
  16880. */
  16881. serialize(): any;
  16882. /**
  16883. * Parse properties from a JSON object
  16884. * @param serializationObject defines the JSON object
  16885. */
  16886. parse(serializationObject: any): void;
  16887. }
  16888. /**
  16889. * Particle emitter emitting particles from the inside of a sphere.
  16890. * It emits the particles randomly between two vectors.
  16891. */
  16892. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16893. /**
  16894. * The min limit of the emission direction.
  16895. */
  16896. direction1: Vector3;
  16897. /**
  16898. * The max limit of the emission direction.
  16899. */
  16900. direction2: Vector3;
  16901. /**
  16902. * Creates a new instance SphereDirectedParticleEmitter
  16903. * @param radius the radius of the emission sphere (1 by default)
  16904. * @param direction1 the min limit of the emission direction (up vector by default)
  16905. * @param direction2 the max limit of the emission direction (up vector by default)
  16906. */
  16907. constructor(radius?: number,
  16908. /**
  16909. * The min limit of the emission direction.
  16910. */
  16911. direction1?: Vector3,
  16912. /**
  16913. * The max limit of the emission direction.
  16914. */
  16915. direction2?: Vector3);
  16916. /**
  16917. * Called by the particle System when the direction is computed for the created particle.
  16918. * @param worldMatrix is the world matrix of the particle system
  16919. * @param directionToUpdate is the direction vector to update with the result
  16920. * @param particle is the particle we are computed the direction for
  16921. */
  16922. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16923. /**
  16924. * Clones the current emitter and returns a copy of it
  16925. * @returns the new emitter
  16926. */
  16927. clone(): SphereDirectedParticleEmitter;
  16928. /**
  16929. * Called by the GPUParticleSystem to setup the update shader
  16930. * @param effect defines the update shader
  16931. */
  16932. applyToShader(effect: Effect): void;
  16933. /**
  16934. * Returns a string to use to update the GPU particles update shader
  16935. * @returns a string containing the defines string
  16936. */
  16937. getEffectDefines(): string;
  16938. /**
  16939. * Returns the string "SphereDirectedParticleEmitter"
  16940. * @returns a string containing the class name
  16941. */
  16942. getClassName(): string;
  16943. /**
  16944. * Serializes the particle system to a JSON object.
  16945. * @returns the JSON object
  16946. */
  16947. serialize(): any;
  16948. /**
  16949. * Parse properties from a JSON object
  16950. * @param serializationObject defines the JSON object
  16951. */
  16952. parse(serializationObject: any): void;
  16953. }
  16954. }
  16955. declare module BABYLON {
  16956. /**
  16957. * Particle emitter emitting particles from a custom list of positions.
  16958. */
  16959. export class CustomParticleEmitter implements IParticleEmitterType {
  16960. /**
  16961. * Gets or sets the position generator that will create the initial position of each particle.
  16962. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16963. */
  16964. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16965. /**
  16966. * Gets or sets the destination generator that will create the final destination of each particle.
  16967. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16968. */
  16969. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16970. /**
  16971. * Creates a new instance CustomParticleEmitter
  16972. */
  16973. constructor();
  16974. /**
  16975. * Called by the particle System when the direction is computed for the created particle.
  16976. * @param worldMatrix is the world matrix of the particle system
  16977. * @param directionToUpdate is the direction vector to update with the result
  16978. * @param particle is the particle we are computed the direction for
  16979. * @param isLocal defines if the direction should be set in local space
  16980. */
  16981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16982. /**
  16983. * Called by the particle System when the position is computed for the created particle.
  16984. * @param worldMatrix is the world matrix of the particle system
  16985. * @param positionToUpdate is the position vector to update with the result
  16986. * @param particle is the particle we are computed the position for
  16987. * @param isLocal defines if the position should be set in local space
  16988. */
  16989. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16990. /**
  16991. * Clones the current emitter and returns a copy of it
  16992. * @returns the new emitter
  16993. */
  16994. clone(): CustomParticleEmitter;
  16995. /**
  16996. * Called by the GPUParticleSystem to setup the update shader
  16997. * @param effect defines the update shader
  16998. */
  16999. applyToShader(effect: Effect): void;
  17000. /**
  17001. * Returns a string to use to update the GPU particles update shader
  17002. * @returns a string containing the defines string
  17003. */
  17004. getEffectDefines(): string;
  17005. /**
  17006. * Returns the string "PointParticleEmitter"
  17007. * @returns a string containing the class name
  17008. */
  17009. getClassName(): string;
  17010. /**
  17011. * Serializes the particle system to a JSON object.
  17012. * @returns the JSON object
  17013. */
  17014. serialize(): any;
  17015. /**
  17016. * Parse properties from a JSON object
  17017. * @param serializationObject defines the JSON object
  17018. */
  17019. parse(serializationObject: any): void;
  17020. }
  17021. }
  17022. declare module BABYLON {
  17023. /**
  17024. * Particle emitter emitting particles from the inside of a box.
  17025. * It emits the particles randomly between 2 given directions.
  17026. */
  17027. export class MeshParticleEmitter implements IParticleEmitterType {
  17028. private _indices;
  17029. private _positions;
  17030. private _normals;
  17031. private _storedNormal;
  17032. private _mesh;
  17033. /**
  17034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17035. */
  17036. direction1: Vector3;
  17037. /**
  17038. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17039. */
  17040. direction2: Vector3;
  17041. /**
  17042. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  17043. */
  17044. useMeshNormalsForDirection: boolean;
  17045. /** Defines the mesh to use as source */
  17046. get mesh(): Nullable<AbstractMesh>;
  17047. set mesh(value: Nullable<AbstractMesh>);
  17048. /**
  17049. * Creates a new instance MeshParticleEmitter
  17050. * @param mesh defines the mesh to use as source
  17051. */
  17052. constructor(mesh?: Nullable<AbstractMesh>);
  17053. /**
  17054. * Called by the particle System when the direction is computed for the created particle.
  17055. * @param worldMatrix is the world matrix of the particle system
  17056. * @param directionToUpdate is the direction vector to update with the result
  17057. * @param particle is the particle we are computed the direction for
  17058. * @param isLocal defines if the direction should be set in local space
  17059. */
  17060. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17061. /**
  17062. * Called by the particle System when the position is computed for the created particle.
  17063. * @param worldMatrix is the world matrix of the particle system
  17064. * @param positionToUpdate is the position vector to update with the result
  17065. * @param particle is the particle we are computed the position for
  17066. * @param isLocal defines if the position should be set in local space
  17067. */
  17068. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17069. /**
  17070. * Clones the current emitter and returns a copy of it
  17071. * @returns the new emitter
  17072. */
  17073. clone(): MeshParticleEmitter;
  17074. /**
  17075. * Called by the GPUParticleSystem to setup the update shader
  17076. * @param effect defines the update shader
  17077. */
  17078. applyToShader(effect: Effect): void;
  17079. /**
  17080. * Returns a string to use to update the GPU particles update shader
  17081. * @returns a string containing the defines string
  17082. */
  17083. getEffectDefines(): string;
  17084. /**
  17085. * Returns the string "BoxParticleEmitter"
  17086. * @returns a string containing the class name
  17087. */
  17088. getClassName(): string;
  17089. /**
  17090. * Serializes the particle system to a JSON object.
  17091. * @returns the JSON object
  17092. */
  17093. serialize(): any;
  17094. /**
  17095. * Parse properties from a JSON object
  17096. * @param serializationObject defines the JSON object
  17097. * @param scene defines the hosting scene
  17098. */
  17099. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17100. }
  17101. }
  17102. declare module BABYLON {
  17103. /**
  17104. * Interface representing a particle system in Babylon.js.
  17105. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17106. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17107. */
  17108. export interface IParticleSystem {
  17109. /**
  17110. * List of animations used by the particle system.
  17111. */
  17112. animations: Animation[];
  17113. /**
  17114. * The id of the Particle system.
  17115. */
  17116. id: string;
  17117. /**
  17118. * The name of the Particle system.
  17119. */
  17120. name: string;
  17121. /**
  17122. * The emitter represents the Mesh or position we are attaching the particle system to.
  17123. */
  17124. emitter: Nullable<AbstractMesh | Vector3>;
  17125. /**
  17126. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17127. */
  17128. isBillboardBased: boolean;
  17129. /**
  17130. * The rendering group used by the Particle system to chose when to render.
  17131. */
  17132. renderingGroupId: number;
  17133. /**
  17134. * The layer mask we are rendering the particles through.
  17135. */
  17136. layerMask: number;
  17137. /**
  17138. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17139. */
  17140. updateSpeed: number;
  17141. /**
  17142. * The amount of time the particle system is running (depends of the overall update speed).
  17143. */
  17144. targetStopDuration: number;
  17145. /**
  17146. * The texture used to render each particle. (this can be a spritesheet)
  17147. */
  17148. particleTexture: Nullable<BaseTexture>;
  17149. /**
  17150. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17151. */
  17152. blendMode: number;
  17153. /**
  17154. * Minimum life time of emitting particles.
  17155. */
  17156. minLifeTime: number;
  17157. /**
  17158. * Maximum life time of emitting particles.
  17159. */
  17160. maxLifeTime: number;
  17161. /**
  17162. * Minimum Size of emitting particles.
  17163. */
  17164. minSize: number;
  17165. /**
  17166. * Maximum Size of emitting particles.
  17167. */
  17168. maxSize: number;
  17169. /**
  17170. * Minimum scale of emitting particles on X axis.
  17171. */
  17172. minScaleX: number;
  17173. /**
  17174. * Maximum scale of emitting particles on X axis.
  17175. */
  17176. maxScaleX: number;
  17177. /**
  17178. * Minimum scale of emitting particles on Y axis.
  17179. */
  17180. minScaleY: number;
  17181. /**
  17182. * Maximum scale of emitting particles on Y axis.
  17183. */
  17184. maxScaleY: number;
  17185. /**
  17186. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17187. */
  17188. color1: Color4;
  17189. /**
  17190. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17191. */
  17192. color2: Color4;
  17193. /**
  17194. * Color the particle will have at the end of its lifetime.
  17195. */
  17196. colorDead: Color4;
  17197. /**
  17198. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17199. */
  17200. emitRate: number;
  17201. /**
  17202. * You can use gravity if you want to give an orientation to your particles.
  17203. */
  17204. gravity: Vector3;
  17205. /**
  17206. * Minimum power of emitting particles.
  17207. */
  17208. minEmitPower: number;
  17209. /**
  17210. * Maximum power of emitting particles.
  17211. */
  17212. maxEmitPower: number;
  17213. /**
  17214. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17215. */
  17216. minAngularSpeed: number;
  17217. /**
  17218. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17219. */
  17220. maxAngularSpeed: number;
  17221. /**
  17222. * Gets or sets the minimal initial rotation in radians.
  17223. */
  17224. minInitialRotation: number;
  17225. /**
  17226. * Gets or sets the maximal initial rotation in radians.
  17227. */
  17228. maxInitialRotation: number;
  17229. /**
  17230. * The particle emitter type defines the emitter used by the particle system.
  17231. * It can be for example box, sphere, or cone...
  17232. */
  17233. particleEmitterType: Nullable<IParticleEmitterType>;
  17234. /**
  17235. * Defines the delay in milliseconds before starting the system (0 by default)
  17236. */
  17237. startDelay: number;
  17238. /**
  17239. * 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
  17240. */
  17241. preWarmCycles: number;
  17242. /**
  17243. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17244. */
  17245. preWarmStepOffset: number;
  17246. /**
  17247. * 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)
  17248. */
  17249. spriteCellChangeSpeed: number;
  17250. /**
  17251. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17252. */
  17253. startSpriteCellID: number;
  17254. /**
  17255. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17256. */
  17257. endSpriteCellID: number;
  17258. /**
  17259. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17260. */
  17261. spriteCellWidth: number;
  17262. /**
  17263. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17264. */
  17265. spriteCellHeight: number;
  17266. /**
  17267. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17268. */
  17269. spriteRandomStartCell: boolean;
  17270. /**
  17271. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17272. */
  17273. isAnimationSheetEnabled: boolean;
  17274. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17275. translationPivot: Vector2;
  17276. /**
  17277. * Gets or sets a texture used to add random noise to particle positions
  17278. */
  17279. noiseTexture: Nullable<BaseTexture>;
  17280. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17281. noiseStrength: Vector3;
  17282. /**
  17283. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17284. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17285. */
  17286. billboardMode: number;
  17287. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17288. limitVelocityDamping: number;
  17289. /**
  17290. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17291. */
  17292. beginAnimationOnStart: boolean;
  17293. /**
  17294. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17295. */
  17296. beginAnimationFrom: number;
  17297. /**
  17298. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17299. */
  17300. beginAnimationTo: number;
  17301. /**
  17302. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17303. */
  17304. beginAnimationLoop: boolean;
  17305. /**
  17306. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17307. */
  17308. disposeOnStop: boolean;
  17309. /**
  17310. * If you want to launch only a few particles at once, that can be done, as well.
  17311. */
  17312. manualEmitCount: number;
  17313. /**
  17314. * Specifies if the particles are updated in emitter local space or world space
  17315. */
  17316. isLocal: boolean;
  17317. /** Snippet ID if the particle system was created from the snippet server */
  17318. snippetId: string;
  17319. /** Gets or sets a matrix to use to compute projection */
  17320. defaultProjectionMatrix: Matrix;
  17321. /**
  17322. * Gets the maximum number of particles active at the same time.
  17323. * @returns The max number of active particles.
  17324. */
  17325. getCapacity(): number;
  17326. /**
  17327. * Gets the number of particles active at the same time.
  17328. * @returns The number of active particles.
  17329. */
  17330. getActiveCount(): number;
  17331. /**
  17332. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17333. * @returns True if it has been started, otherwise false.
  17334. */
  17335. isStarted(): boolean;
  17336. /**
  17337. * Animates the particle system for this frame.
  17338. */
  17339. animate(): void;
  17340. /**
  17341. * Renders the particle system in its current state.
  17342. * @returns the current number of particles
  17343. */
  17344. render(): number;
  17345. /**
  17346. * Dispose the particle system and frees its associated resources.
  17347. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  17348. */
  17349. dispose(disposeTexture?: boolean): void;
  17350. /**
  17351. * An event triggered when the system is disposed
  17352. */
  17353. onDisposeObservable: Observable<IParticleSystem>;
  17354. /**
  17355. * An event triggered when the system is stopped
  17356. */
  17357. onStoppedObservable: Observable<IParticleSystem>;
  17358. /**
  17359. * Clones the particle system.
  17360. * @param name The name of the cloned object
  17361. * @param newEmitter The new emitter to use
  17362. * @returns the cloned particle system
  17363. */
  17364. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17365. /**
  17366. * Serializes the particle system to a JSON object
  17367. * @param serializeTexture defines if the texture must be serialized as well
  17368. * @returns the JSON object
  17369. */
  17370. serialize(serializeTexture: boolean): any;
  17371. /**
  17372. * Rebuild the particle system
  17373. */
  17374. rebuild(): void;
  17375. /** Force the system to rebuild all gradients that need to be resync */
  17376. forceRefreshGradients(): void;
  17377. /**
  17378. * Starts the particle system and begins to emit
  17379. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17380. */
  17381. start(delay?: number): void;
  17382. /**
  17383. * Stops the particle system.
  17384. */
  17385. stop(): void;
  17386. /**
  17387. * Remove all active particles
  17388. */
  17389. reset(): void;
  17390. /**
  17391. * Gets a boolean indicating that the system is stopping
  17392. * @returns true if the system is currently stopping
  17393. */
  17394. isStopping(): boolean;
  17395. /**
  17396. * Is this system ready to be used/rendered
  17397. * @return true if the system is ready
  17398. */
  17399. isReady(): boolean;
  17400. /**
  17401. * Returns the string "ParticleSystem"
  17402. * @returns a string containing the class name
  17403. */
  17404. getClassName(): string;
  17405. /**
  17406. * Gets the custom effect used to render the particles
  17407. * @param blendMode Blend mode for which the effect should be retrieved
  17408. * @returns The effect
  17409. */
  17410. getCustomEffect(blendMode: number): Nullable<Effect>;
  17411. /**
  17412. * Sets the custom effect used to render the particles
  17413. * @param effect The effect to set
  17414. * @param blendMode Blend mode for which the effect should be set
  17415. */
  17416. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17417. /**
  17418. * Fill the defines array according to the current settings of the particle system
  17419. * @param defines Array to be updated
  17420. * @param blendMode blend mode to take into account when updating the array
  17421. */
  17422. fillDefines(defines: Array<string>, blendMode: number): void;
  17423. /**
  17424. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17425. * @param uniforms Uniforms array to fill
  17426. * @param attributes Attributes array to fill
  17427. * @param samplers Samplers array to fill
  17428. */
  17429. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17430. /**
  17431. * Observable that will be called just before the particles are drawn
  17432. */
  17433. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17434. /**
  17435. * Gets the name of the particle vertex shader
  17436. */
  17437. vertexShaderName: string;
  17438. /**
  17439. * Adds a new color gradient
  17440. * @param gradient defines the gradient to use (between 0 and 1)
  17441. * @param color1 defines the color to affect to the specified gradient
  17442. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17443. * @returns the current particle system
  17444. */
  17445. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17446. /**
  17447. * Remove a specific color gradient
  17448. * @param gradient defines the gradient to remove
  17449. * @returns the current particle system
  17450. */
  17451. removeColorGradient(gradient: number): IParticleSystem;
  17452. /**
  17453. * Adds a new size gradient
  17454. * @param gradient defines the gradient to use (between 0 and 1)
  17455. * @param factor defines the size factor to affect to the specified gradient
  17456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17457. * @returns the current particle system
  17458. */
  17459. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17460. /**
  17461. * Remove a specific size gradient
  17462. * @param gradient defines the gradient to remove
  17463. * @returns the current particle system
  17464. */
  17465. removeSizeGradient(gradient: number): IParticleSystem;
  17466. /**
  17467. * Gets the current list of color gradients.
  17468. * You must use addColorGradient and removeColorGradient to update this list
  17469. * @returns the list of color gradients
  17470. */
  17471. getColorGradients(): Nullable<Array<ColorGradient>>;
  17472. /**
  17473. * Gets the current list of size gradients.
  17474. * You must use addSizeGradient and removeSizeGradient to update this list
  17475. * @returns the list of size gradients
  17476. */
  17477. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17478. /**
  17479. * Gets the current list of angular speed gradients.
  17480. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  17481. * @returns the list of angular speed gradients
  17482. */
  17483. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17484. /**
  17485. * Adds a new angular speed gradient
  17486. * @param gradient defines the gradient to use (between 0 and 1)
  17487. * @param factor defines the angular speed to affect to the specified gradient
  17488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17489. * @returns the current particle system
  17490. */
  17491. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17492. /**
  17493. * Remove a specific angular speed gradient
  17494. * @param gradient defines the gradient to remove
  17495. * @returns the current particle system
  17496. */
  17497. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17498. /**
  17499. * Gets the current list of velocity gradients.
  17500. * You must use addVelocityGradient and removeVelocityGradient to update this list
  17501. * @returns the list of velocity gradients
  17502. */
  17503. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17504. /**
  17505. * Adds a new velocity gradient
  17506. * @param gradient defines the gradient to use (between 0 and 1)
  17507. * @param factor defines the velocity to affect to the specified gradient
  17508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17509. * @returns the current particle system
  17510. */
  17511. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17512. /**
  17513. * Remove a specific velocity gradient
  17514. * @param gradient defines the gradient to remove
  17515. * @returns the current particle system
  17516. */
  17517. removeVelocityGradient(gradient: number): IParticleSystem;
  17518. /**
  17519. * Gets the current list of limit velocity gradients.
  17520. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  17521. * @returns the list of limit velocity gradients
  17522. */
  17523. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17524. /**
  17525. * Adds a new limit velocity gradient
  17526. * @param gradient defines the gradient to use (between 0 and 1)
  17527. * @param factor defines the limit velocity to affect to the specified gradient
  17528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17529. * @returns the current particle system
  17530. */
  17531. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17532. /**
  17533. * Remove a specific limit velocity gradient
  17534. * @param gradient defines the gradient to remove
  17535. * @returns the current particle system
  17536. */
  17537. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17538. /**
  17539. * Adds a new drag gradient
  17540. * @param gradient defines the gradient to use (between 0 and 1)
  17541. * @param factor defines the drag to affect to the specified gradient
  17542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17543. * @returns the current particle system
  17544. */
  17545. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17546. /**
  17547. * Remove a specific drag gradient
  17548. * @param gradient defines the gradient to remove
  17549. * @returns the current particle system
  17550. */
  17551. removeDragGradient(gradient: number): IParticleSystem;
  17552. /**
  17553. * Gets the current list of drag gradients.
  17554. * You must use addDragGradient and removeDragGradient to update this list
  17555. * @returns the list of drag gradients
  17556. */
  17557. getDragGradients(): Nullable<Array<FactorGradient>>;
  17558. /**
  17559. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17560. * @param gradient defines the gradient to use (between 0 and 1)
  17561. * @param factor defines the emit rate to affect to the specified gradient
  17562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17563. * @returns the current particle system
  17564. */
  17565. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17566. /**
  17567. * Remove a specific emit rate gradient
  17568. * @param gradient defines the gradient to remove
  17569. * @returns the current particle system
  17570. */
  17571. removeEmitRateGradient(gradient: number): IParticleSystem;
  17572. /**
  17573. * Gets the current list of emit rate gradients.
  17574. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  17575. * @returns the list of emit rate gradients
  17576. */
  17577. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17578. /**
  17579. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17580. * @param gradient defines the gradient to use (between 0 and 1)
  17581. * @param factor defines the start size to affect to the specified gradient
  17582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17583. * @returns the current particle system
  17584. */
  17585. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17586. /**
  17587. * Remove a specific start size gradient
  17588. * @param gradient defines the gradient to remove
  17589. * @returns the current particle system
  17590. */
  17591. removeStartSizeGradient(gradient: number): IParticleSystem;
  17592. /**
  17593. * Gets the current list of start size gradients.
  17594. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  17595. * @returns the list of start size gradients
  17596. */
  17597. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17598. /**
  17599. * Adds a new life time gradient
  17600. * @param gradient defines the gradient to use (between 0 and 1)
  17601. * @param factor defines the life time factor to affect to the specified gradient
  17602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17603. * @returns the current particle system
  17604. */
  17605. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17606. /**
  17607. * Remove a specific life time gradient
  17608. * @param gradient defines the gradient to remove
  17609. * @returns the current particle system
  17610. */
  17611. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17612. /**
  17613. * Gets the current list of life time gradients.
  17614. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  17615. * @returns the list of life time gradients
  17616. */
  17617. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17618. /**
  17619. * Gets the current list of color gradients.
  17620. * You must use addColorGradient and removeColorGradient to update this list
  17621. * @returns the list of color gradients
  17622. */
  17623. getColorGradients(): Nullable<Array<ColorGradient>>;
  17624. /**
  17625. * Adds a new ramp gradient used to remap particle colors
  17626. * @param gradient defines the gradient to use (between 0 and 1)
  17627. * @param color defines the color to affect to the specified gradient
  17628. * @returns the current particle system
  17629. */
  17630. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17631. /**
  17632. * Gets the current list of ramp gradients.
  17633. * You must use addRampGradient and removeRampGradient to update this list
  17634. * @returns the list of ramp gradients
  17635. */
  17636. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17637. /** Gets or sets a boolean indicating that ramp gradients must be used
  17638. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17639. */
  17640. useRampGradients: boolean;
  17641. /**
  17642. * Adds a new color remap gradient
  17643. * @param gradient defines the gradient to use (between 0 and 1)
  17644. * @param min defines the color remap minimal range
  17645. * @param max defines the color remap maximal range
  17646. * @returns the current particle system
  17647. */
  17648. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17649. /**
  17650. * Gets the current list of color remap gradients.
  17651. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  17652. * @returns the list of color remap gradients
  17653. */
  17654. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17655. /**
  17656. * Adds a new alpha remap gradient
  17657. * @param gradient defines the gradient to use (between 0 and 1)
  17658. * @param min defines the alpha remap minimal range
  17659. * @param max defines the alpha remap maximal range
  17660. * @returns the current particle system
  17661. */
  17662. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17663. /**
  17664. * Gets the current list of alpha remap gradients.
  17665. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  17666. * @returns the list of alpha remap gradients
  17667. */
  17668. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17669. /**
  17670. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17671. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17672. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17673. * @returns the emitter
  17674. */
  17675. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17676. /**
  17677. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17678. * @param radius The radius of the hemisphere to emit from
  17679. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17680. * @returns the emitter
  17681. */
  17682. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17683. /**
  17684. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17685. * @param radius The radius of the sphere to emit from
  17686. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17687. * @returns the emitter
  17688. */
  17689. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17690. /**
  17691. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17692. * @param radius The radius of the sphere to emit from
  17693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17695. * @returns the emitter
  17696. */
  17697. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17698. /**
  17699. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17700. * @param radius The radius of the emission cylinder
  17701. * @param height The height of the emission cylinder
  17702. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17703. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17704. * @returns the emitter
  17705. */
  17706. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17707. /**
  17708. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17709. * @param radius The radius of the cylinder to emit from
  17710. * @param height The height of the emission cylinder
  17711. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17712. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17713. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17714. * @returns the emitter
  17715. */
  17716. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17717. /**
  17718. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17719. * @param radius The radius of the cone to emit from
  17720. * @param angle The base angle of the cone
  17721. * @returns the emitter
  17722. */
  17723. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17724. /**
  17725. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17726. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17727. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17728. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17729. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17730. * @returns the emitter
  17731. */
  17732. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17733. /**
  17734. * Get hosting scene
  17735. * @returns the scene
  17736. */
  17737. getScene(): Nullable<Scene>;
  17738. }
  17739. }
  17740. declare module BABYLON {
  17741. /**
  17742. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17743. */
  17744. export class ColorSplitterBlock extends NodeMaterialBlock {
  17745. /**
  17746. * Create a new ColorSplitterBlock
  17747. * @param name defines the block name
  17748. */
  17749. constructor(name: string);
  17750. /**
  17751. * Gets the current class name
  17752. * @returns the class name
  17753. */
  17754. getClassName(): string;
  17755. /**
  17756. * Gets the rgba component (input)
  17757. */
  17758. get rgba(): NodeMaterialConnectionPoint;
  17759. /**
  17760. * Gets the rgb component (input)
  17761. */
  17762. get rgbIn(): NodeMaterialConnectionPoint;
  17763. /**
  17764. * Gets the rgb component (output)
  17765. */
  17766. get rgbOut(): NodeMaterialConnectionPoint;
  17767. /**
  17768. * Gets the r component (output)
  17769. */
  17770. get r(): NodeMaterialConnectionPoint;
  17771. /**
  17772. * Gets the g component (output)
  17773. */
  17774. get g(): NodeMaterialConnectionPoint;
  17775. /**
  17776. * Gets the b component (output)
  17777. */
  17778. get b(): NodeMaterialConnectionPoint;
  17779. /**
  17780. * Gets the a component (output)
  17781. */
  17782. get a(): NodeMaterialConnectionPoint;
  17783. protected _inputRename(name: string): string;
  17784. protected _outputRename(name: string): string;
  17785. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17786. }
  17787. }
  17788. declare module BABYLON {
  17789. /**
  17790. * Operations supported by the Trigonometry block
  17791. */
  17792. export enum TrigonometryBlockOperations {
  17793. /** Cos */
  17794. Cos = 0,
  17795. /** Sin */
  17796. Sin = 1,
  17797. /** Abs */
  17798. Abs = 2,
  17799. /** Exp */
  17800. Exp = 3,
  17801. /** Exp2 */
  17802. Exp2 = 4,
  17803. /** Round */
  17804. Round = 5,
  17805. /** Floor */
  17806. Floor = 6,
  17807. /** Ceiling */
  17808. Ceiling = 7,
  17809. /** Square root */
  17810. Sqrt = 8,
  17811. /** Log */
  17812. Log = 9,
  17813. /** Tangent */
  17814. Tan = 10,
  17815. /** Arc tangent */
  17816. ArcTan = 11,
  17817. /** Arc cosinus */
  17818. ArcCos = 12,
  17819. /** Arc sinus */
  17820. ArcSin = 13,
  17821. /** Fraction */
  17822. Fract = 14,
  17823. /** Sign */
  17824. Sign = 15,
  17825. /** To radians (from degrees) */
  17826. Radians = 16,
  17827. /** To degrees (from radians) */
  17828. Degrees = 17
  17829. }
  17830. /**
  17831. * Block used to apply trigonometry operation to floats
  17832. */
  17833. export class TrigonometryBlock extends NodeMaterialBlock {
  17834. /**
  17835. * Gets or sets the operation applied by the block
  17836. */
  17837. operation: TrigonometryBlockOperations;
  17838. /**
  17839. * Creates a new TrigonometryBlock
  17840. * @param name defines the block name
  17841. */
  17842. constructor(name: string);
  17843. /**
  17844. * Gets the current class name
  17845. * @returns the class name
  17846. */
  17847. getClassName(): string;
  17848. /**
  17849. * Gets the input component
  17850. */
  17851. get input(): NodeMaterialConnectionPoint;
  17852. /**
  17853. * Gets the output component
  17854. */
  17855. get output(): NodeMaterialConnectionPoint;
  17856. protected _buildBlock(state: NodeMaterialBuildState): this;
  17857. serialize(): any;
  17858. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17859. protected _dumpPropertiesCode(): string;
  17860. }
  17861. }
  17862. declare module BABYLON {
  17863. /**
  17864. * Interface used to configure the node material editor
  17865. */
  17866. export interface INodeMaterialEditorOptions {
  17867. /** Define the URl to load node editor script */
  17868. editorURL?: string;
  17869. }
  17870. /** @hidden */
  17871. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17872. NORMAL: boolean;
  17873. TANGENT: boolean;
  17874. UV1: boolean;
  17875. /** BONES */
  17876. NUM_BONE_INFLUENCERS: number;
  17877. BonesPerMesh: number;
  17878. BONETEXTURE: boolean;
  17879. /** MORPH TARGETS */
  17880. MORPHTARGETS: boolean;
  17881. MORPHTARGETS_NORMAL: boolean;
  17882. MORPHTARGETS_TANGENT: boolean;
  17883. MORPHTARGETS_UV: boolean;
  17884. NUM_MORPH_INFLUENCERS: number;
  17885. /** IMAGE PROCESSING */
  17886. IMAGEPROCESSING: boolean;
  17887. VIGNETTE: boolean;
  17888. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17889. VIGNETTEBLENDMODEOPAQUE: boolean;
  17890. TONEMAPPING: boolean;
  17891. TONEMAPPING_ACES: boolean;
  17892. CONTRAST: boolean;
  17893. EXPOSURE: boolean;
  17894. COLORCURVES: boolean;
  17895. COLORGRADING: boolean;
  17896. COLORGRADING3D: boolean;
  17897. SAMPLER3DGREENDEPTH: boolean;
  17898. SAMPLER3DBGRMAP: boolean;
  17899. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17900. /** MISC. */
  17901. BUMPDIRECTUV: number;
  17902. constructor();
  17903. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17904. }
  17905. /**
  17906. * Class used to configure NodeMaterial
  17907. */
  17908. export interface INodeMaterialOptions {
  17909. /**
  17910. * Defines if blocks should emit comments
  17911. */
  17912. emitComments: boolean;
  17913. }
  17914. /**
  17915. * Class used to create a node based material built by assembling shader blocks
  17916. */
  17917. export class NodeMaterial extends PushMaterial {
  17918. private static _BuildIdGenerator;
  17919. private _options;
  17920. private _vertexCompilationState;
  17921. private _fragmentCompilationState;
  17922. private _sharedData;
  17923. private _buildId;
  17924. private _buildWasSuccessful;
  17925. private _cachedWorldViewMatrix;
  17926. private _cachedWorldViewProjectionMatrix;
  17927. private _optimizers;
  17928. private _animationFrame;
  17929. /** Define the Url to load node editor script */
  17930. static EditorURL: string;
  17931. /** Define the Url to load snippets */
  17932. static SnippetUrl: string;
  17933. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17934. static IgnoreTexturesAtLoadTime: boolean;
  17935. private BJSNODEMATERIALEDITOR;
  17936. /** Get the inspector from bundle or global */
  17937. private _getGlobalNodeMaterialEditor;
  17938. /**
  17939. * Snippet ID if the material was created from the snippet server
  17940. */
  17941. snippetId: string;
  17942. /**
  17943. * Gets or sets data used by visual editor
  17944. * @see https://nme.babylonjs.com
  17945. */
  17946. editorData: any;
  17947. /**
  17948. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  17949. */
  17950. ignoreAlpha: boolean;
  17951. /**
  17952. * Defines the maximum number of lights that can be used in the material
  17953. */
  17954. maxSimultaneousLights: number;
  17955. /**
  17956. * Observable raised when the material is built
  17957. */
  17958. onBuildObservable: Observable<NodeMaterial>;
  17959. /**
  17960. * Gets or sets the root nodes of the material vertex shader
  17961. */
  17962. _vertexOutputNodes: NodeMaterialBlock[];
  17963. /**
  17964. * Gets or sets the root nodes of the material fragment (pixel) shader
  17965. */
  17966. _fragmentOutputNodes: NodeMaterialBlock[];
  17967. /** Gets or sets options to control the node material overall behavior */
  17968. get options(): INodeMaterialOptions;
  17969. set options(options: INodeMaterialOptions);
  17970. /**
  17971. * Default configuration related to image processing available in the standard Material.
  17972. */
  17973. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17974. /**
  17975. * Gets the image processing configuration used either in this material.
  17976. */
  17977. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17978. /**
  17979. * Sets the Default image processing configuration used either in the this material.
  17980. *
  17981. * If sets to null, the scene one is in use.
  17982. */
  17983. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17984. /**
  17985. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17986. */
  17987. attachedBlocks: NodeMaterialBlock[];
  17988. /**
  17989. * Specifies the mode of the node material
  17990. * @hidden
  17991. */
  17992. _mode: NodeMaterialModes;
  17993. /**
  17994. * Gets the mode property
  17995. */
  17996. get mode(): NodeMaterialModes;
  17997. /**
  17998. * A free comment about the material
  17999. */
  18000. comment: string;
  18001. /**
  18002. * Create a new node based material
  18003. * @param name defines the material name
  18004. * @param scene defines the hosting scene
  18005. * @param options defines creation option
  18006. */
  18007. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  18008. /**
  18009. * Gets the current class name of the material e.g. "NodeMaterial"
  18010. * @returns the class name
  18011. */
  18012. getClassName(): string;
  18013. /**
  18014. * Keep track of the image processing observer to allow dispose and replace.
  18015. */
  18016. private _imageProcessingObserver;
  18017. /**
  18018. * Attaches a new image processing configuration to the Standard Material.
  18019. * @param configuration
  18020. */
  18021. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18022. /**
  18023. * Get a block by its name
  18024. * @param name defines the name of the block to retrieve
  18025. * @returns the required block or null if not found
  18026. */
  18027. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  18028. /**
  18029. * Get a block by its name
  18030. * @param predicate defines the predicate used to find the good candidate
  18031. * @returns the required block or null if not found
  18032. */
  18033. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  18034. /**
  18035. * Get an input block by its name
  18036. * @param predicate defines the predicate used to find the good candidate
  18037. * @returns the required input block or null if not found
  18038. */
  18039. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  18040. /**
  18041. * Gets the list of input blocks attached to this material
  18042. * @returns an array of InputBlocks
  18043. */
  18044. getInputBlocks(): InputBlock[];
  18045. /**
  18046. * Adds a new optimizer to the list of optimizers
  18047. * @param optimizer defines the optimizers to add
  18048. * @returns the current material
  18049. */
  18050. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18051. /**
  18052. * Remove an optimizer from the list of optimizers
  18053. * @param optimizer defines the optimizers to remove
  18054. * @returns the current material
  18055. */
  18056. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18057. /**
  18058. * Add a new block to the list of output nodes
  18059. * @param node defines the node to add
  18060. * @returns the current material
  18061. */
  18062. addOutputNode(node: NodeMaterialBlock): this;
  18063. /**
  18064. * Remove a block from the list of root nodes
  18065. * @param node defines the node to remove
  18066. * @returns the current material
  18067. */
  18068. removeOutputNode(node: NodeMaterialBlock): this;
  18069. private _addVertexOutputNode;
  18070. private _removeVertexOutputNode;
  18071. private _addFragmentOutputNode;
  18072. private _removeFragmentOutputNode;
  18073. /**
  18074. * Specifies if the material will require alpha blending
  18075. * @returns a boolean specifying if alpha blending is needed
  18076. */
  18077. needAlphaBlending(): boolean;
  18078. /**
  18079. * Specifies if this material should be rendered in alpha test mode
  18080. * @returns a boolean specifying if an alpha test is needed.
  18081. */
  18082. needAlphaTesting(): boolean;
  18083. private _initializeBlock;
  18084. private _resetDualBlocks;
  18085. /**
  18086. * Remove a block from the current node material
  18087. * @param block defines the block to remove
  18088. */
  18089. removeBlock(block: NodeMaterialBlock): void;
  18090. /**
  18091. * Build the material and generates the inner effect
  18092. * @param verbose defines if the build should log activity
  18093. */
  18094. build(verbose?: boolean): void;
  18095. /**
  18096. * Runs an otpimization phase to try to improve the shader code
  18097. */
  18098. optimize(): void;
  18099. private _prepareDefinesForAttributes;
  18100. /**
  18101. * Create a post process from the material
  18102. * @param camera The camera to apply the render pass to.
  18103. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18105. * @param engine The engine which the post process will be applied. (default: current engine)
  18106. * @param reusable If the post process can be reused on the same frame. (default: false)
  18107. * @param textureType Type of textures used when performing the post process. (default: 0)
  18108. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18109. * @returns the post process created
  18110. */
  18111. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18112. /**
  18113. * Create the post process effect from the material
  18114. * @param postProcess The post process to create the effect for
  18115. */
  18116. createEffectForPostProcess(postProcess: PostProcess): void;
  18117. private _createEffectForPostProcess;
  18118. /**
  18119. * Create a new procedural texture based on this node material
  18120. * @param size defines the size of the texture
  18121. * @param scene defines the hosting scene
  18122. * @returns the new procedural texture attached to this node material
  18123. */
  18124. createProceduralTexture(size: number | {
  18125. width: number;
  18126. height: number;
  18127. layers?: number;
  18128. }, scene: Scene): Nullable<ProceduralTexture>;
  18129. private _createEffectForParticles;
  18130. private _checkInternals;
  18131. /**
  18132. * Create the effect to be used as the custom effect for a particle system
  18133. * @param particleSystem Particle system to create the effect for
  18134. * @param onCompiled defines a function to call when the effect creation is successful
  18135. * @param onError defines a function to call when the effect creation has failed
  18136. */
  18137. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18138. private _processDefines;
  18139. /**
  18140. * Get if the submesh is ready to be used and all its information available.
  18141. * Child classes can use it to update shaders
  18142. * @param mesh defines the mesh to check
  18143. * @param subMesh defines which submesh to check
  18144. * @param useInstances specifies that instances should be used
  18145. * @returns a boolean indicating that the submesh is ready or not
  18146. */
  18147. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18148. /**
  18149. * Get a string representing the shaders built by the current node graph
  18150. */
  18151. get compiledShaders(): string;
  18152. /**
  18153. * Binds the world matrix to the material
  18154. * @param world defines the world transformation matrix
  18155. */
  18156. bindOnlyWorldMatrix(world: Matrix): void;
  18157. /**
  18158. * Binds the submesh to this material by preparing the effect and shader to draw
  18159. * @param world defines the world transformation matrix
  18160. * @param mesh defines the mesh containing the submesh
  18161. * @param subMesh defines the submesh to bind the material to
  18162. */
  18163. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18164. /**
  18165. * Gets the active textures from the material
  18166. * @returns an array of textures
  18167. */
  18168. getActiveTextures(): BaseTexture[];
  18169. /**
  18170. * Gets the list of texture blocks
  18171. * @returns an array of texture blocks
  18172. */
  18173. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18174. /**
  18175. * Specifies if the material uses a texture
  18176. * @param texture defines the texture to check against the material
  18177. * @returns a boolean specifying if the material uses the texture
  18178. */
  18179. hasTexture(texture: BaseTexture): boolean;
  18180. /**
  18181. * Disposes the material
  18182. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18183. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18184. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18185. */
  18186. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18187. /** Creates the node editor window. */
  18188. private _createNodeEditor;
  18189. /**
  18190. * Launch the node material editor
  18191. * @param config Define the configuration of the editor
  18192. * @return a promise fulfilled when the node editor is visible
  18193. */
  18194. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18195. /**
  18196. * Clear the current material
  18197. */
  18198. clear(): void;
  18199. /**
  18200. * Clear the current material and set it to a default state
  18201. */
  18202. setToDefault(): void;
  18203. /**
  18204. * Clear the current material and set it to a default state for post process
  18205. */
  18206. setToDefaultPostProcess(): void;
  18207. /**
  18208. * Clear the current material and set it to a default state for procedural texture
  18209. */
  18210. setToDefaultProceduralTexture(): void;
  18211. /**
  18212. * Clear the current material and set it to a default state for particle
  18213. */
  18214. setToDefaultParticle(): void;
  18215. /**
  18216. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18217. * @param url defines the url to load from
  18218. * @returns a promise that will fulfil when the material is fully loaded
  18219. */
  18220. loadAsync(url: string): Promise<void>;
  18221. private _gatherBlocks;
  18222. /**
  18223. * Generate a string containing the code declaration required to create an equivalent of this material
  18224. * @returns a string
  18225. */
  18226. generateCode(): string;
  18227. /**
  18228. * Serializes this material in a JSON representation
  18229. * @returns the serialized material object
  18230. */
  18231. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18232. private _restoreConnections;
  18233. /**
  18234. * Clear the current graph and load a new one from a serialization object
  18235. * @param source defines the JSON representation of the material
  18236. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18237. * @param merge defines whether or not the source must be merged or replace the current content
  18238. */
  18239. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18240. /**
  18241. * Makes a duplicate of the current material.
  18242. * @param name - name to use for the new material.
  18243. */
  18244. clone(name: string): NodeMaterial;
  18245. /**
  18246. * Creates a node material from parsed material data
  18247. * @param source defines the JSON representation of the material
  18248. * @param scene defines the hosting scene
  18249. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18250. * @returns a new node material
  18251. */
  18252. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18253. /**
  18254. * Creates a node material from a snippet saved in a remote file
  18255. * @param name defines the name of the material to create
  18256. * @param url defines the url to load from
  18257. * @param scene defines the hosting scene
  18258. * @returns a promise that will resolve to the new node material
  18259. */
  18260. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18261. /**
  18262. * Creates a node material from a snippet saved by the node material editor
  18263. * @param snippetId defines the snippet to load
  18264. * @param scene defines the hosting scene
  18265. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18266. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18267. * @returns a promise that will resolve to the new node material
  18268. */
  18269. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18270. /**
  18271. * Creates a new node material set to default basic configuration
  18272. * @param name defines the name of the material
  18273. * @param scene defines the hosting scene
  18274. * @returns a new NodeMaterial
  18275. */
  18276. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18277. }
  18278. }
  18279. declare module BABYLON {
  18280. interface ThinEngine {
  18281. /**
  18282. * Unbind a list of render target textures from the webGL context
  18283. * This is used only when drawBuffer extension or webGL2 are active
  18284. * @param textures defines the render target textures to unbind
  18285. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18286. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18287. */
  18288. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18289. /**
  18290. * Create a multi render target texture
  18291. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18292. * @param size defines the size of the texture
  18293. * @param options defines the creation options
  18294. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18295. * @returns the cube texture as an InternalTexture
  18296. */
  18297. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): InternalTexture[];
  18298. /**
  18299. * Update the sample count for a given multiple render target texture
  18300. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18301. * @param textures defines the textures to update
  18302. * @param samples defines the sample count to set
  18303. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18304. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18305. */
  18306. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number, initializeBuffers?: boolean): number;
  18307. /**
  18308. * Select a subsets of attachments to draw to.
  18309. * @param attachments gl attachments
  18310. */
  18311. bindAttachments(attachments: number[]): void;
  18312. /**
  18313. * Creates a layout object to draw/clear on specific textures in a MRT
  18314. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18315. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18316. */
  18317. buildTextureLayout(textureStatus: boolean[]): number[];
  18318. /**
  18319. * Restores the webgl state to only draw on the main color attachment
  18320. * when the frame buffer associated is the canvas frame buffer
  18321. */
  18322. restoreSingleAttachment(): void;
  18323. /**
  18324. * Restores the webgl state to only draw on the main color attachment
  18325. * when the frame buffer associated is not the canvas frame buffer
  18326. */
  18327. restoreSingleAttachmentForRenderTarget(): void;
  18328. /**
  18329. * Clears a list of attachments
  18330. * @param attachments list of the attachments
  18331. * @param colorMain clear color for the main attachment (the first one)
  18332. * @param colorOthers clear color for the other attachments
  18333. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18334. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18335. */
  18336. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18337. }
  18338. }
  18339. declare module BABYLON {
  18340. /**
  18341. * Creation options of the multi render target texture.
  18342. */
  18343. export interface IMultiRenderTargetOptions {
  18344. /**
  18345. * Define if the texture needs to create mip maps after render.
  18346. */
  18347. generateMipMaps?: boolean;
  18348. /**
  18349. * Define the types of all the draw buffers we want to create
  18350. */
  18351. types?: number[];
  18352. /**
  18353. * Define the sampling modes of all the draw buffers we want to create
  18354. */
  18355. samplingModes?: number[];
  18356. /**
  18357. * Define if a depth buffer is required
  18358. */
  18359. generateDepthBuffer?: boolean;
  18360. /**
  18361. * Define if a stencil buffer is required
  18362. */
  18363. generateStencilBuffer?: boolean;
  18364. /**
  18365. * Define if a depth texture is required instead of a depth buffer
  18366. */
  18367. generateDepthTexture?: boolean;
  18368. /**
  18369. * Define the number of desired draw buffers
  18370. */
  18371. textureCount?: number;
  18372. /**
  18373. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18374. */
  18375. doNotChangeAspectRatio?: boolean;
  18376. /**
  18377. * Define the default type of the buffers we are creating
  18378. */
  18379. defaultType?: number;
  18380. /**
  18381. * Define the default type of the buffers we are creating
  18382. */
  18383. drawOnlyOnFirstAttachmentByDefault?: boolean;
  18384. }
  18385. /**
  18386. * A multi render target, like a render target provides the ability to render to a texture.
  18387. * Unlike the render target, it can render to several draw buffers in one draw.
  18388. * This is specially interesting in deferred rendering or for any effects requiring more than
  18389. * just one color from a single pass.
  18390. */
  18391. export class MultiRenderTarget extends RenderTargetTexture {
  18392. private _internalTextures;
  18393. private _textures;
  18394. private _multiRenderTargetOptions;
  18395. private _count;
  18396. private _drawOnlyOnFirstAttachmentByDefault;
  18397. /**
  18398. * Get if draw buffers are currently supported by the used hardware and browser.
  18399. */
  18400. get isSupported(): boolean;
  18401. /**
  18402. * Get the list of textures generated by the multi render target.
  18403. */
  18404. get textures(): Texture[];
  18405. /**
  18406. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18407. */
  18408. get count(): number;
  18409. /**
  18410. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18411. */
  18412. get depthTexture(): Texture;
  18413. /**
  18414. * Set the wrapping mode on U of all the textures we are rendering to.
  18415. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18416. */
  18417. set wrapU(wrap: number);
  18418. /**
  18419. * Set the wrapping mode on V of all the textures we are rendering to.
  18420. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18421. */
  18422. set wrapV(wrap: number);
  18423. /**
  18424. * Instantiate a new multi render target texture.
  18425. * A multi render target, like a render target provides the ability to render to a texture.
  18426. * Unlike the render target, it can render to several draw buffers in one draw.
  18427. * This is specially interesting in deferred rendering or for any effects requiring more than
  18428. * just one color from a single pass.
  18429. * @param name Define the name of the texture
  18430. * @param size Define the size of the buffers to render to
  18431. * @param count Define the number of target we are rendering into
  18432. * @param scene Define the scene the texture belongs to
  18433. * @param options Define the options used to create the multi render target
  18434. */
  18435. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18436. private _initTypes;
  18437. /** @hidden */
  18438. _rebuild(forceFullRebuild?: boolean): void;
  18439. private _createInternalTextures;
  18440. private _createTextures;
  18441. /**
  18442. * Replaces a texture within the MRT.
  18443. * @param texture The new texture to insert in the MRT
  18444. * @param index The index of the texture to replace
  18445. */
  18446. replaceTexture(texture: Texture, index: number): void;
  18447. /**
  18448. * Define the number of samples used if MSAA is enabled.
  18449. */
  18450. get samples(): number;
  18451. set samples(value: number);
  18452. /**
  18453. * Resize all the textures in the multi render target.
  18454. * Be careful as it will recreate all the data in the new texture.
  18455. * @param size Define the new size
  18456. */
  18457. resize(size: any): void;
  18458. /**
  18459. * Changes the number of render targets in this MRT
  18460. * Be careful as it will recreate all the data in the new texture.
  18461. * @param count new texture count
  18462. * @param options Specifies texture types and sampling modes for new textures
  18463. */
  18464. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18465. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18466. /**
  18467. * Dispose the render targets and their associated resources
  18468. */
  18469. dispose(): void;
  18470. /**
  18471. * Release all the underlying texture used as draw buffers.
  18472. */
  18473. releaseInternalTextures(): void;
  18474. }
  18475. }
  18476. declare module BABYLON {
  18477. /** @hidden */
  18478. export var imageProcessingPixelShader: {
  18479. name: string;
  18480. shader: string;
  18481. };
  18482. }
  18483. declare module BABYLON {
  18484. /**
  18485. * ImageProcessingPostProcess
  18486. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18487. */
  18488. export class ImageProcessingPostProcess extends PostProcess {
  18489. /**
  18490. * Default configuration related to image processing available in the PBR Material.
  18491. */
  18492. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18493. /**
  18494. * Gets the image processing configuration used either in this material.
  18495. */
  18496. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18497. /**
  18498. * Sets the Default image processing configuration used either in the this material.
  18499. *
  18500. * If sets to null, the scene one is in use.
  18501. */
  18502. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18503. /**
  18504. * Keep track of the image processing observer to allow dispose and replace.
  18505. */
  18506. private _imageProcessingObserver;
  18507. /**
  18508. * Attaches a new image processing configuration to the PBR Material.
  18509. * @param configuration
  18510. */
  18511. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18512. /**
  18513. * If the post process is supported.
  18514. */
  18515. get isSupported(): boolean;
  18516. /**
  18517. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18518. */
  18519. get colorCurves(): Nullable<ColorCurves>;
  18520. /**
  18521. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18522. */
  18523. set colorCurves(value: Nullable<ColorCurves>);
  18524. /**
  18525. * Gets whether the color curves effect is enabled.
  18526. */
  18527. get colorCurvesEnabled(): boolean;
  18528. /**
  18529. * Sets whether the color curves effect is enabled.
  18530. */
  18531. set colorCurvesEnabled(value: boolean);
  18532. /**
  18533. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18534. */
  18535. get colorGradingTexture(): Nullable<BaseTexture>;
  18536. /**
  18537. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18538. */
  18539. set colorGradingTexture(value: Nullable<BaseTexture>);
  18540. /**
  18541. * Gets whether the color grading effect is enabled.
  18542. */
  18543. get colorGradingEnabled(): boolean;
  18544. /**
  18545. * Gets whether the color grading effect is enabled.
  18546. */
  18547. set colorGradingEnabled(value: boolean);
  18548. /**
  18549. * Gets exposure used in the effect.
  18550. */
  18551. get exposure(): number;
  18552. /**
  18553. * Sets exposure used in the effect.
  18554. */
  18555. set exposure(value: number);
  18556. /**
  18557. * Gets whether tonemapping is enabled or not.
  18558. */
  18559. get toneMappingEnabled(): boolean;
  18560. /**
  18561. * Sets whether tonemapping is enabled or not
  18562. */
  18563. set toneMappingEnabled(value: boolean);
  18564. /**
  18565. * Gets the type of tone mapping effect.
  18566. */
  18567. get toneMappingType(): number;
  18568. /**
  18569. * Sets the type of tone mapping effect.
  18570. */
  18571. set toneMappingType(value: number);
  18572. /**
  18573. * Gets contrast used in the effect.
  18574. */
  18575. get contrast(): number;
  18576. /**
  18577. * Sets contrast used in the effect.
  18578. */
  18579. set contrast(value: number);
  18580. /**
  18581. * Gets Vignette stretch size.
  18582. */
  18583. get vignetteStretch(): number;
  18584. /**
  18585. * Sets Vignette stretch size.
  18586. */
  18587. set vignetteStretch(value: number);
  18588. /**
  18589. * Gets Vignette centre X Offset.
  18590. */
  18591. get vignetteCentreX(): number;
  18592. /**
  18593. * Sets Vignette centre X Offset.
  18594. */
  18595. set vignetteCentreX(value: number);
  18596. /**
  18597. * Gets Vignette centre Y Offset.
  18598. */
  18599. get vignetteCentreY(): number;
  18600. /**
  18601. * Sets Vignette centre Y Offset.
  18602. */
  18603. set vignetteCentreY(value: number);
  18604. /**
  18605. * Gets Vignette weight or intensity of the vignette effect.
  18606. */
  18607. get vignetteWeight(): number;
  18608. /**
  18609. * Sets Vignette weight or intensity of the vignette effect.
  18610. */
  18611. set vignetteWeight(value: number);
  18612. /**
  18613. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18614. * if vignetteEnabled is set to true.
  18615. */
  18616. get vignetteColor(): Color4;
  18617. /**
  18618. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18619. * if vignetteEnabled is set to true.
  18620. */
  18621. set vignetteColor(value: Color4);
  18622. /**
  18623. * Gets Camera field of view used by the Vignette effect.
  18624. */
  18625. get vignetteCameraFov(): number;
  18626. /**
  18627. * Sets Camera field of view used by the Vignette effect.
  18628. */
  18629. set vignetteCameraFov(value: number);
  18630. /**
  18631. * Gets the vignette blend mode allowing different kind of effect.
  18632. */
  18633. get vignetteBlendMode(): number;
  18634. /**
  18635. * Sets the vignette blend mode allowing different kind of effect.
  18636. */
  18637. set vignetteBlendMode(value: number);
  18638. /**
  18639. * Gets whether the vignette effect is enabled.
  18640. */
  18641. get vignetteEnabled(): boolean;
  18642. /**
  18643. * Sets whether the vignette effect is enabled.
  18644. */
  18645. set vignetteEnabled(value: boolean);
  18646. private _fromLinearSpace;
  18647. /**
  18648. * Gets whether the input of the processing is in Gamma or Linear Space.
  18649. */
  18650. get fromLinearSpace(): boolean;
  18651. /**
  18652. * Sets whether the input of the processing is in Gamma or Linear Space.
  18653. */
  18654. set fromLinearSpace(value: boolean);
  18655. /**
  18656. * Defines cache preventing GC.
  18657. */
  18658. private _defines;
  18659. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18660. /**
  18661. * "ImageProcessingPostProcess"
  18662. * @returns "ImageProcessingPostProcess"
  18663. */
  18664. getClassName(): string;
  18665. /**
  18666. * @hidden
  18667. */
  18668. _updateParameters(): void;
  18669. dispose(camera?: Camera): void;
  18670. }
  18671. }
  18672. declare module BABYLON {
  18673. /**
  18674. * A multi render target designed to render the prepass.
  18675. * Prepass is a scene component used to render information in multiple textures
  18676. * alongside with the scene materials rendering.
  18677. * Note : This is an internal class, and you should NOT need to instanciate this.
  18678. * Only the `PrePassRenderer` should instanciate this class.
  18679. * It is more likely that you need a regular `MultiRenderTarget`
  18680. * @hidden
  18681. */
  18682. export class PrePassRenderTarget extends MultiRenderTarget {
  18683. /**
  18684. * @hidden
  18685. */
  18686. _beforeCompositionPostProcesses: PostProcess[];
  18687. /**
  18688. * Image processing post process for composition
  18689. */
  18690. imageProcessingPostProcess: ImageProcessingPostProcess;
  18691. /**
  18692. * @hidden
  18693. */
  18694. _engine: Engine;
  18695. /**
  18696. * @hidden
  18697. */
  18698. _scene: Scene;
  18699. /**
  18700. * @hidden
  18701. */
  18702. _outputPostProcess: Nullable<PostProcess>;
  18703. /**
  18704. * @hidden
  18705. */
  18706. _internalTextureDirty: boolean;
  18707. /**
  18708. * Is this render target enabled for prepass rendering
  18709. */
  18710. enabled: boolean;
  18711. /**
  18712. * Render target associated with this prePassRenderTarget
  18713. * If this is `null`, it means this prePassRenderTarget is associated with the scene
  18714. */
  18715. renderTargetTexture: Nullable<RenderTargetTexture>;
  18716. constructor(name: string, renderTargetTexture: Nullable<RenderTargetTexture>, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions | undefined);
  18717. /**
  18718. * Creates a composition effect for this RT
  18719. * @hidden
  18720. */
  18721. _createCompositionEffect(): void;
  18722. /**
  18723. * Checks that the size of this RT is still adapted to the desired render size.
  18724. * @hidden
  18725. */
  18726. _checkSize(): void;
  18727. /**
  18728. * Changes the number of render targets in this MRT
  18729. * Be careful as it will recreate all the data in the new texture.
  18730. * @param count new texture count
  18731. * @param options Specifies texture types and sampling modes for new textures
  18732. */
  18733. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18734. /**
  18735. * Resets the post processes chains applied to this RT.
  18736. * @hidden
  18737. */
  18738. _resetPostProcessChain(): void;
  18739. /**
  18740. * Diposes this render target
  18741. */
  18742. dispose(): void;
  18743. }
  18744. }
  18745. declare module BABYLON {
  18746. /**
  18747. * Interface for defining prepass effects in the prepass post-process pipeline
  18748. */
  18749. export interface PrePassEffectConfiguration {
  18750. /**
  18751. * Name of the effect
  18752. */
  18753. name: string;
  18754. /**
  18755. * Post process to attach for this effect
  18756. */
  18757. postProcess?: PostProcess;
  18758. /**
  18759. * Textures required in the MRT
  18760. */
  18761. texturesRequired: number[];
  18762. /**
  18763. * Is the effect enabled
  18764. */
  18765. enabled: boolean;
  18766. /**
  18767. * Does the output of this prepass need to go through imageprocessing
  18768. */
  18769. needsImageProcessing?: boolean;
  18770. /**
  18771. * Disposes the effect configuration
  18772. */
  18773. dispose?: () => void;
  18774. /**
  18775. * Creates the associated post process
  18776. */
  18777. createPostProcess?: () => PostProcess;
  18778. }
  18779. }
  18780. declare module BABYLON {
  18781. /**
  18782. * Options to be used when creating a FresnelParameters.
  18783. */
  18784. export type IFresnelParametersCreationOptions = {
  18785. /**
  18786. * Define the color used on edges (grazing angle)
  18787. */
  18788. leftColor?: Color3;
  18789. /**
  18790. * Define the color used on center
  18791. */
  18792. rightColor?: Color3;
  18793. /**
  18794. * Define bias applied to computed fresnel term
  18795. */
  18796. bias?: number;
  18797. /**
  18798. * Defined the power exponent applied to fresnel term
  18799. */
  18800. power?: number;
  18801. /**
  18802. * Define if the fresnel effect is enable or not.
  18803. */
  18804. isEnabled?: boolean;
  18805. };
  18806. /**
  18807. * Serialized format for FresnelParameters.
  18808. */
  18809. export type IFresnelParametersSerialized = {
  18810. /**
  18811. * Define the color used on edges (grazing angle) [as an array]
  18812. */
  18813. leftColor: number[];
  18814. /**
  18815. * Define the color used on center [as an array]
  18816. */
  18817. rightColor: number[];
  18818. /**
  18819. * Define bias applied to computed fresnel term
  18820. */
  18821. bias: number;
  18822. /**
  18823. * Defined the power exponent applied to fresnel term
  18824. */
  18825. power?: number;
  18826. /**
  18827. * Define if the fresnel effect is enable or not.
  18828. */
  18829. isEnabled: boolean;
  18830. };
  18831. /**
  18832. * This represents all the required information to add a fresnel effect on a material:
  18833. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18834. */
  18835. export class FresnelParameters {
  18836. private _isEnabled;
  18837. /**
  18838. * Define if the fresnel effect is enable or not.
  18839. */
  18840. get isEnabled(): boolean;
  18841. set isEnabled(value: boolean);
  18842. /**
  18843. * Define the color used on edges (grazing angle)
  18844. */
  18845. leftColor: Color3;
  18846. /**
  18847. * Define the color used on center
  18848. */
  18849. rightColor: Color3;
  18850. /**
  18851. * Define bias applied to computed fresnel term
  18852. */
  18853. bias: number;
  18854. /**
  18855. * Defined the power exponent applied to fresnel term
  18856. */
  18857. power: number;
  18858. /**
  18859. * Creates a new FresnelParameters object.
  18860. *
  18861. * @param options provide your own settings to optionally to override defaults
  18862. */
  18863. constructor(options?: IFresnelParametersCreationOptions);
  18864. /**
  18865. * Clones the current fresnel and its values
  18866. * @returns a clone fresnel configuration
  18867. */
  18868. clone(): FresnelParameters;
  18869. /**
  18870. * Determines equality between FresnelParameters objects
  18871. * @param otherFresnelParameters defines the second operand
  18872. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18873. */
  18874. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18875. /**
  18876. * Serializes the current fresnel parameters to a JSON representation.
  18877. * @return the JSON serialization
  18878. */
  18879. serialize(): IFresnelParametersSerialized;
  18880. /**
  18881. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18882. * @param parsedFresnelParameters Define the JSON representation
  18883. * @returns the parsed parameters
  18884. */
  18885. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18886. }
  18887. }
  18888. declare module BABYLON {
  18889. /**
  18890. * This groups all the flags used to control the materials channel.
  18891. */
  18892. export class MaterialFlags {
  18893. private static _DiffuseTextureEnabled;
  18894. /**
  18895. * Are diffuse textures enabled in the application.
  18896. */
  18897. static get DiffuseTextureEnabled(): boolean;
  18898. static set DiffuseTextureEnabled(value: boolean);
  18899. private static _DetailTextureEnabled;
  18900. /**
  18901. * Are detail textures enabled in the application.
  18902. */
  18903. static get DetailTextureEnabled(): boolean;
  18904. static set DetailTextureEnabled(value: boolean);
  18905. private static _AmbientTextureEnabled;
  18906. /**
  18907. * Are ambient textures enabled in the application.
  18908. */
  18909. static get AmbientTextureEnabled(): boolean;
  18910. static set AmbientTextureEnabled(value: boolean);
  18911. private static _OpacityTextureEnabled;
  18912. /**
  18913. * Are opacity textures enabled in the application.
  18914. */
  18915. static get OpacityTextureEnabled(): boolean;
  18916. static set OpacityTextureEnabled(value: boolean);
  18917. private static _ReflectionTextureEnabled;
  18918. /**
  18919. * Are reflection textures enabled in the application.
  18920. */
  18921. static get ReflectionTextureEnabled(): boolean;
  18922. static set ReflectionTextureEnabled(value: boolean);
  18923. private static _EmissiveTextureEnabled;
  18924. /**
  18925. * Are emissive textures enabled in the application.
  18926. */
  18927. static get EmissiveTextureEnabled(): boolean;
  18928. static set EmissiveTextureEnabled(value: boolean);
  18929. private static _SpecularTextureEnabled;
  18930. /**
  18931. * Are specular textures enabled in the application.
  18932. */
  18933. static get SpecularTextureEnabled(): boolean;
  18934. static set SpecularTextureEnabled(value: boolean);
  18935. private static _BumpTextureEnabled;
  18936. /**
  18937. * Are bump textures enabled in the application.
  18938. */
  18939. static get BumpTextureEnabled(): boolean;
  18940. static set BumpTextureEnabled(value: boolean);
  18941. private static _LightmapTextureEnabled;
  18942. /**
  18943. * Are lightmap textures enabled in the application.
  18944. */
  18945. static get LightmapTextureEnabled(): boolean;
  18946. static set LightmapTextureEnabled(value: boolean);
  18947. private static _RefractionTextureEnabled;
  18948. /**
  18949. * Are refraction textures enabled in the application.
  18950. */
  18951. static get RefractionTextureEnabled(): boolean;
  18952. static set RefractionTextureEnabled(value: boolean);
  18953. private static _ColorGradingTextureEnabled;
  18954. /**
  18955. * Are color grading textures enabled in the application.
  18956. */
  18957. static get ColorGradingTextureEnabled(): boolean;
  18958. static set ColorGradingTextureEnabled(value: boolean);
  18959. private static _FresnelEnabled;
  18960. /**
  18961. * Are fresnels enabled in the application.
  18962. */
  18963. static get FresnelEnabled(): boolean;
  18964. static set FresnelEnabled(value: boolean);
  18965. private static _ClearCoatTextureEnabled;
  18966. /**
  18967. * Are clear coat textures enabled in the application.
  18968. */
  18969. static get ClearCoatTextureEnabled(): boolean;
  18970. static set ClearCoatTextureEnabled(value: boolean);
  18971. private static _ClearCoatBumpTextureEnabled;
  18972. /**
  18973. * Are clear coat bump textures enabled in the application.
  18974. */
  18975. static get ClearCoatBumpTextureEnabled(): boolean;
  18976. static set ClearCoatBumpTextureEnabled(value: boolean);
  18977. private static _ClearCoatTintTextureEnabled;
  18978. /**
  18979. * Are clear coat tint textures enabled in the application.
  18980. */
  18981. static get ClearCoatTintTextureEnabled(): boolean;
  18982. static set ClearCoatTintTextureEnabled(value: boolean);
  18983. private static _SheenTextureEnabled;
  18984. /**
  18985. * Are sheen textures enabled in the application.
  18986. */
  18987. static get SheenTextureEnabled(): boolean;
  18988. static set SheenTextureEnabled(value: boolean);
  18989. private static _AnisotropicTextureEnabled;
  18990. /**
  18991. * Are anisotropic textures enabled in the application.
  18992. */
  18993. static get AnisotropicTextureEnabled(): boolean;
  18994. static set AnisotropicTextureEnabled(value: boolean);
  18995. private static _ThicknessTextureEnabled;
  18996. /**
  18997. * Are thickness textures enabled in the application.
  18998. */
  18999. static get ThicknessTextureEnabled(): boolean;
  19000. static set ThicknessTextureEnabled(value: boolean);
  19001. }
  19002. }
  19003. declare module BABYLON {
  19004. /** @hidden */
  19005. export var defaultFragmentDeclaration: {
  19006. name: string;
  19007. shader: string;
  19008. };
  19009. }
  19010. declare module BABYLON {
  19011. /** @hidden */
  19012. export var sceneUboDeclaration: {
  19013. name: string;
  19014. shader: string;
  19015. };
  19016. }
  19017. declare module BABYLON {
  19018. /** @hidden */
  19019. export var meshUboDeclaration: {
  19020. name: string;
  19021. shader: string;
  19022. };
  19023. }
  19024. declare module BABYLON {
  19025. /** @hidden */
  19026. export var defaultUboDeclaration: {
  19027. name: string;
  19028. shader: string;
  19029. };
  19030. }
  19031. declare module BABYLON {
  19032. /** @hidden */
  19033. export var prePassDeclaration: {
  19034. name: string;
  19035. shader: string;
  19036. };
  19037. }
  19038. declare module BABYLON {
  19039. /** @hidden */
  19040. export var lightFragmentDeclaration: {
  19041. name: string;
  19042. shader: string;
  19043. };
  19044. }
  19045. declare module BABYLON {
  19046. /** @hidden */
  19047. export var lightUboDeclaration: {
  19048. name: string;
  19049. shader: string;
  19050. };
  19051. }
  19052. declare module BABYLON {
  19053. /** @hidden */
  19054. export var lightsFragmentFunctions: {
  19055. name: string;
  19056. shader: string;
  19057. };
  19058. }
  19059. declare module BABYLON {
  19060. /** @hidden */
  19061. export var shadowsFragmentFunctions: {
  19062. name: string;
  19063. shader: string;
  19064. };
  19065. }
  19066. declare module BABYLON {
  19067. /** @hidden */
  19068. export var fresnelFunction: {
  19069. name: string;
  19070. shader: string;
  19071. };
  19072. }
  19073. declare module BABYLON {
  19074. /** @hidden */
  19075. export var bumpFragmentMainFunctions: {
  19076. name: string;
  19077. shader: string;
  19078. };
  19079. }
  19080. declare module BABYLON {
  19081. /** @hidden */
  19082. export var bumpFragmentFunctions: {
  19083. name: string;
  19084. shader: string;
  19085. };
  19086. }
  19087. declare module BABYLON {
  19088. /** @hidden */
  19089. export var logDepthDeclaration: {
  19090. name: string;
  19091. shader: string;
  19092. };
  19093. }
  19094. declare module BABYLON {
  19095. /** @hidden */
  19096. export var fogFragmentDeclaration: {
  19097. name: string;
  19098. shader: string;
  19099. };
  19100. }
  19101. declare module BABYLON {
  19102. /** @hidden */
  19103. export var bumpFragment: {
  19104. name: string;
  19105. shader: string;
  19106. };
  19107. }
  19108. declare module BABYLON {
  19109. /** @hidden */
  19110. export var depthPrePass: {
  19111. name: string;
  19112. shader: string;
  19113. };
  19114. }
  19115. declare module BABYLON {
  19116. /** @hidden */
  19117. export var lightFragment: {
  19118. name: string;
  19119. shader: string;
  19120. };
  19121. }
  19122. declare module BABYLON {
  19123. /** @hidden */
  19124. export var logDepthFragment: {
  19125. name: string;
  19126. shader: string;
  19127. };
  19128. }
  19129. declare module BABYLON {
  19130. /** @hidden */
  19131. export var fogFragment: {
  19132. name: string;
  19133. shader: string;
  19134. };
  19135. }
  19136. declare module BABYLON {
  19137. /** @hidden */
  19138. export var defaultPixelShader: {
  19139. name: string;
  19140. shader: string;
  19141. };
  19142. }
  19143. declare module BABYLON {
  19144. /** @hidden */
  19145. export var defaultVertexDeclaration: {
  19146. name: string;
  19147. shader: string;
  19148. };
  19149. }
  19150. declare module BABYLON {
  19151. /** @hidden */
  19152. export var bonesDeclaration: {
  19153. name: string;
  19154. shader: string;
  19155. };
  19156. }
  19157. declare module BABYLON {
  19158. /** @hidden */
  19159. export var prePassVertexDeclaration: {
  19160. name: string;
  19161. shader: string;
  19162. };
  19163. }
  19164. declare module BABYLON {
  19165. /** @hidden */
  19166. export var bumpVertexDeclaration: {
  19167. name: string;
  19168. shader: string;
  19169. };
  19170. }
  19171. declare module BABYLON {
  19172. /** @hidden */
  19173. export var fogVertexDeclaration: {
  19174. name: string;
  19175. shader: string;
  19176. };
  19177. }
  19178. declare module BABYLON {
  19179. /** @hidden */
  19180. export var lightVxFragmentDeclaration: {
  19181. name: string;
  19182. shader: string;
  19183. };
  19184. }
  19185. declare module BABYLON {
  19186. /** @hidden */
  19187. export var lightVxUboDeclaration: {
  19188. name: string;
  19189. shader: string;
  19190. };
  19191. }
  19192. declare module BABYLON {
  19193. /** @hidden */
  19194. export var morphTargetsVertexGlobalDeclaration: {
  19195. name: string;
  19196. shader: string;
  19197. };
  19198. }
  19199. declare module BABYLON {
  19200. /** @hidden */
  19201. export var morphTargetsVertexDeclaration: {
  19202. name: string;
  19203. shader: string;
  19204. };
  19205. }
  19206. declare module BABYLON {
  19207. /** @hidden */
  19208. export var morphTargetsVertex: {
  19209. name: string;
  19210. shader: string;
  19211. };
  19212. }
  19213. declare module BABYLON {
  19214. /** @hidden */
  19215. export var instancesVertex: {
  19216. name: string;
  19217. shader: string;
  19218. };
  19219. }
  19220. declare module BABYLON {
  19221. /** @hidden */
  19222. export var bonesVertex: {
  19223. name: string;
  19224. shader: string;
  19225. };
  19226. }
  19227. declare module BABYLON {
  19228. /** @hidden */
  19229. export var prePassVertex: {
  19230. name: string;
  19231. shader: string;
  19232. };
  19233. }
  19234. declare module BABYLON {
  19235. /** @hidden */
  19236. export var bumpVertex: {
  19237. name: string;
  19238. shader: string;
  19239. };
  19240. }
  19241. declare module BABYLON {
  19242. /** @hidden */
  19243. export var fogVertex: {
  19244. name: string;
  19245. shader: string;
  19246. };
  19247. }
  19248. declare module BABYLON {
  19249. /** @hidden */
  19250. export var shadowsVertex: {
  19251. name: string;
  19252. shader: string;
  19253. };
  19254. }
  19255. declare module BABYLON {
  19256. /** @hidden */
  19257. export var pointCloudVertex: {
  19258. name: string;
  19259. shader: string;
  19260. };
  19261. }
  19262. declare module BABYLON {
  19263. /** @hidden */
  19264. export var logDepthVertex: {
  19265. name: string;
  19266. shader: string;
  19267. };
  19268. }
  19269. declare module BABYLON {
  19270. /** @hidden */
  19271. export var defaultVertexShader: {
  19272. name: string;
  19273. shader: string;
  19274. };
  19275. }
  19276. declare module BABYLON {
  19277. /**
  19278. * @hidden
  19279. */
  19280. export interface IMaterialDetailMapDefines {
  19281. DETAIL: boolean;
  19282. DETAILDIRECTUV: number;
  19283. DETAIL_NORMALBLENDMETHOD: number;
  19284. /** @hidden */
  19285. _areTexturesDirty: boolean;
  19286. }
  19287. /**
  19288. * Define the code related to the detail map parameters of a material
  19289. *
  19290. * Inspired from:
  19291. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  19292. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19293. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19294. */
  19295. export class DetailMapConfiguration {
  19296. private _texture;
  19297. /**
  19298. * The detail texture of the material.
  19299. */
  19300. texture: Nullable<BaseTexture>;
  19301. /**
  19302. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19303. * Bigger values mean stronger blending
  19304. */
  19305. diffuseBlendLevel: number;
  19306. /**
  19307. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19308. * Bigger values mean stronger blending. Only used with PBR materials
  19309. */
  19310. roughnessBlendLevel: number;
  19311. /**
  19312. * Defines how strong the bump effect from the detail map is
  19313. * Bigger values mean stronger effect
  19314. */
  19315. bumpLevel: number;
  19316. private _normalBlendMethod;
  19317. /**
  19318. * The method used to blend the bump and detail normals together
  19319. */
  19320. normalBlendMethod: number;
  19321. private _isEnabled;
  19322. /**
  19323. * Enable or disable the detail map on this material
  19324. */
  19325. isEnabled: boolean;
  19326. /** @hidden */
  19327. private _internalMarkAllSubMeshesAsTexturesDirty;
  19328. /** @hidden */
  19329. _markAllSubMeshesAsTexturesDirty(): void;
  19330. /**
  19331. * Instantiate a new detail map
  19332. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19333. */
  19334. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19335. /**
  19336. * Gets whether the submesh is ready to be used or not.
  19337. * @param defines the list of "defines" to update.
  19338. * @param scene defines the scene the material belongs to.
  19339. * @returns - boolean indicating that the submesh is ready or not.
  19340. */
  19341. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19342. /**
  19343. * Update the defines for detail map usage
  19344. * @param defines the list of "defines" to update.
  19345. * @param scene defines the scene the material belongs to.
  19346. */
  19347. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19348. /**
  19349. * Binds the material data.
  19350. * @param uniformBuffer defines the Uniform buffer to fill in.
  19351. * @param scene defines the scene the material belongs to.
  19352. * @param isFrozen defines whether the material is frozen or not.
  19353. */
  19354. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19355. /**
  19356. * Checks to see if a texture is used in the material.
  19357. * @param texture - Base texture to use.
  19358. * @returns - Boolean specifying if a texture is used in the material.
  19359. */
  19360. hasTexture(texture: BaseTexture): boolean;
  19361. /**
  19362. * Returns an array of the actively used textures.
  19363. * @param activeTextures Array of BaseTextures
  19364. */
  19365. getActiveTextures(activeTextures: BaseTexture[]): void;
  19366. /**
  19367. * Returns the animatable textures.
  19368. * @param animatables Array of animatable textures.
  19369. */
  19370. getAnimatables(animatables: IAnimatable[]): void;
  19371. /**
  19372. * Disposes the resources of the material.
  19373. * @param forceDisposeTextures - Forces the disposal of all textures.
  19374. */
  19375. dispose(forceDisposeTextures?: boolean): void;
  19376. /**
  19377. * Get the current class name useful for serialization or dynamic coding.
  19378. * @returns "DetailMap"
  19379. */
  19380. getClassName(): string;
  19381. /**
  19382. * Add the required uniforms to the current list.
  19383. * @param uniforms defines the current uniform list.
  19384. */
  19385. static AddUniforms(uniforms: string[]): void;
  19386. /**
  19387. * Add the required samplers to the current list.
  19388. * @param samplers defines the current sampler list.
  19389. */
  19390. static AddSamplers(samplers: string[]): void;
  19391. /**
  19392. * Add the required uniforms to the current buffer.
  19393. * @param uniformBuffer defines the current uniform buffer.
  19394. */
  19395. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19396. /**
  19397. * Makes a duplicate of the current instance into another one.
  19398. * @param detailMap define the instance where to copy the info
  19399. */
  19400. copyTo(detailMap: DetailMapConfiguration): void;
  19401. /**
  19402. * Serializes this detail map instance
  19403. * @returns - An object with the serialized instance.
  19404. */
  19405. serialize(): any;
  19406. /**
  19407. * Parses a detail map setting from a serialized object.
  19408. * @param source - Serialized object.
  19409. * @param scene Defines the scene we are parsing for
  19410. * @param rootUrl Defines the rootUrl to load from
  19411. */
  19412. parse(source: any, scene: Scene, rootUrl: string): void;
  19413. }
  19414. }
  19415. declare module BABYLON {
  19416. /** @hidden */
  19417. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19418. MAINUV1: boolean;
  19419. MAINUV2: boolean;
  19420. DIFFUSE: boolean;
  19421. DIFFUSEDIRECTUV: number;
  19422. DETAIL: boolean;
  19423. DETAILDIRECTUV: number;
  19424. DETAIL_NORMALBLENDMETHOD: number;
  19425. AMBIENT: boolean;
  19426. AMBIENTDIRECTUV: number;
  19427. OPACITY: boolean;
  19428. OPACITYDIRECTUV: number;
  19429. OPACITYRGB: boolean;
  19430. REFLECTION: boolean;
  19431. EMISSIVE: boolean;
  19432. EMISSIVEDIRECTUV: number;
  19433. SPECULAR: boolean;
  19434. SPECULARDIRECTUV: number;
  19435. BUMP: boolean;
  19436. BUMPDIRECTUV: number;
  19437. PARALLAX: boolean;
  19438. PARALLAXOCCLUSION: boolean;
  19439. SPECULAROVERALPHA: boolean;
  19440. CLIPPLANE: boolean;
  19441. CLIPPLANE2: boolean;
  19442. CLIPPLANE3: boolean;
  19443. CLIPPLANE4: boolean;
  19444. CLIPPLANE5: boolean;
  19445. CLIPPLANE6: boolean;
  19446. ALPHATEST: boolean;
  19447. DEPTHPREPASS: boolean;
  19448. ALPHAFROMDIFFUSE: boolean;
  19449. POINTSIZE: boolean;
  19450. FOG: boolean;
  19451. SPECULARTERM: boolean;
  19452. DIFFUSEFRESNEL: boolean;
  19453. OPACITYFRESNEL: boolean;
  19454. REFLECTIONFRESNEL: boolean;
  19455. REFRACTIONFRESNEL: boolean;
  19456. EMISSIVEFRESNEL: boolean;
  19457. FRESNEL: boolean;
  19458. NORMAL: boolean;
  19459. UV1: boolean;
  19460. UV2: boolean;
  19461. VERTEXCOLOR: boolean;
  19462. VERTEXALPHA: boolean;
  19463. NUM_BONE_INFLUENCERS: number;
  19464. BonesPerMesh: number;
  19465. BONETEXTURE: boolean;
  19466. BONES_VELOCITY_ENABLED: boolean;
  19467. INSTANCES: boolean;
  19468. THIN_INSTANCES: boolean;
  19469. GLOSSINESS: boolean;
  19470. ROUGHNESS: boolean;
  19471. EMISSIVEASILLUMINATION: boolean;
  19472. LINKEMISSIVEWITHDIFFUSE: boolean;
  19473. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19474. LIGHTMAP: boolean;
  19475. LIGHTMAPDIRECTUV: number;
  19476. OBJECTSPACE_NORMALMAP: boolean;
  19477. USELIGHTMAPASSHADOWMAP: boolean;
  19478. REFLECTIONMAP_3D: boolean;
  19479. REFLECTIONMAP_SPHERICAL: boolean;
  19480. REFLECTIONMAP_PLANAR: boolean;
  19481. REFLECTIONMAP_CUBIC: boolean;
  19482. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19483. REFLECTIONMAP_PROJECTION: boolean;
  19484. REFLECTIONMAP_SKYBOX: boolean;
  19485. REFLECTIONMAP_EXPLICIT: boolean;
  19486. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19487. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19488. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19489. REFLECTIONMAP_OPPOSITEZ: boolean;
  19490. INVERTCUBICMAP: boolean;
  19491. LOGARITHMICDEPTH: boolean;
  19492. REFRACTION: boolean;
  19493. REFRACTIONMAP_3D: boolean;
  19494. REFLECTIONOVERALPHA: boolean;
  19495. TWOSIDEDLIGHTING: boolean;
  19496. SHADOWFLOAT: boolean;
  19497. MORPHTARGETS: boolean;
  19498. MORPHTARGETS_NORMAL: boolean;
  19499. MORPHTARGETS_TANGENT: boolean;
  19500. MORPHTARGETS_UV: boolean;
  19501. NUM_MORPH_INFLUENCERS: number;
  19502. NONUNIFORMSCALING: boolean;
  19503. PREMULTIPLYALPHA: boolean;
  19504. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19505. ALPHABLEND: boolean;
  19506. PREPASS: boolean;
  19507. PREPASS_IRRADIANCE: boolean;
  19508. PREPASS_IRRADIANCE_INDEX: number;
  19509. PREPASS_ALBEDO: boolean;
  19510. PREPASS_ALBEDO_INDEX: number;
  19511. PREPASS_DEPTH: boolean;
  19512. PREPASS_DEPTH_INDEX: number;
  19513. PREPASS_NORMAL: boolean;
  19514. PREPASS_NORMAL_INDEX: number;
  19515. PREPASS_POSITION: boolean;
  19516. PREPASS_POSITION_INDEX: number;
  19517. PREPASS_VELOCITY: boolean;
  19518. PREPASS_VELOCITY_INDEX: number;
  19519. PREPASS_REFLECTIVITY: boolean;
  19520. PREPASS_REFLECTIVITY_INDEX: number;
  19521. SCENE_MRT_COUNT: number;
  19522. RGBDLIGHTMAP: boolean;
  19523. RGBDREFLECTION: boolean;
  19524. RGBDREFRACTION: boolean;
  19525. IMAGEPROCESSING: boolean;
  19526. VIGNETTE: boolean;
  19527. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19528. VIGNETTEBLENDMODEOPAQUE: boolean;
  19529. TONEMAPPING: boolean;
  19530. TONEMAPPING_ACES: boolean;
  19531. CONTRAST: boolean;
  19532. COLORCURVES: boolean;
  19533. COLORGRADING: boolean;
  19534. COLORGRADING3D: boolean;
  19535. SAMPLER3DGREENDEPTH: boolean;
  19536. SAMPLER3DBGRMAP: boolean;
  19537. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19538. MULTIVIEW: boolean;
  19539. /**
  19540. * If the reflection texture on this material is in linear color space
  19541. * @hidden
  19542. */
  19543. IS_REFLECTION_LINEAR: boolean;
  19544. /**
  19545. * If the refraction texture on this material is in linear color space
  19546. * @hidden
  19547. */
  19548. IS_REFRACTION_LINEAR: boolean;
  19549. EXPOSURE: boolean;
  19550. constructor();
  19551. setReflectionMode(modeToEnable: string): void;
  19552. }
  19553. /**
  19554. * This is the default material used in Babylon. It is the best trade off between quality
  19555. * and performances.
  19556. * @see https://doc.babylonjs.com/babylon101/materials
  19557. */
  19558. export class StandardMaterial extends PushMaterial {
  19559. private _diffuseTexture;
  19560. /**
  19561. * The basic texture of the material as viewed under a light.
  19562. */
  19563. diffuseTexture: Nullable<BaseTexture>;
  19564. private _ambientTexture;
  19565. /**
  19566. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19567. */
  19568. ambientTexture: Nullable<BaseTexture>;
  19569. private _opacityTexture;
  19570. /**
  19571. * Define the transparency of the material from a texture.
  19572. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19573. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19574. */
  19575. opacityTexture: Nullable<BaseTexture>;
  19576. private _reflectionTexture;
  19577. /**
  19578. * Define the texture used to display the reflection.
  19579. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19580. */
  19581. reflectionTexture: Nullable<BaseTexture>;
  19582. private _emissiveTexture;
  19583. /**
  19584. * Define texture of the material as if self lit.
  19585. * This will be mixed in the final result even in the absence of light.
  19586. */
  19587. emissiveTexture: Nullable<BaseTexture>;
  19588. private _specularTexture;
  19589. /**
  19590. * Define how the color and intensity of the highlight given by the light in the material.
  19591. */
  19592. specularTexture: Nullable<BaseTexture>;
  19593. private _bumpTexture;
  19594. /**
  19595. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19596. * 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.
  19597. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19598. */
  19599. bumpTexture: Nullable<BaseTexture>;
  19600. private _lightmapTexture;
  19601. /**
  19602. * Complex lighting can be computationally expensive to compute at runtime.
  19603. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19604. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19605. */
  19606. lightmapTexture: Nullable<BaseTexture>;
  19607. private _refractionTexture;
  19608. /**
  19609. * Define the texture used to display the refraction.
  19610. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19611. */
  19612. refractionTexture: Nullable<BaseTexture>;
  19613. /**
  19614. * The color of the material lit by the environmental background lighting.
  19615. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19616. */
  19617. ambientColor: Color3;
  19618. /**
  19619. * The basic color of the material as viewed under a light.
  19620. */
  19621. diffuseColor: Color3;
  19622. /**
  19623. * Define how the color and intensity of the highlight given by the light in the material.
  19624. */
  19625. specularColor: Color3;
  19626. /**
  19627. * Define the color of the material as if self lit.
  19628. * This will be mixed in the final result even in the absence of light.
  19629. */
  19630. emissiveColor: Color3;
  19631. /**
  19632. * Defines how sharp are the highlights in the material.
  19633. * The bigger the value the sharper giving a more glossy feeling to the result.
  19634. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19635. */
  19636. specularPower: number;
  19637. private _useAlphaFromDiffuseTexture;
  19638. /**
  19639. * Does the transparency come from the diffuse texture alpha channel.
  19640. */
  19641. useAlphaFromDiffuseTexture: boolean;
  19642. private _useEmissiveAsIllumination;
  19643. /**
  19644. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19645. */
  19646. useEmissiveAsIllumination: boolean;
  19647. private _linkEmissiveWithDiffuse;
  19648. /**
  19649. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19650. * the emissive level when the final color is close to one.
  19651. */
  19652. linkEmissiveWithDiffuse: boolean;
  19653. private _useSpecularOverAlpha;
  19654. /**
  19655. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  19656. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19657. */
  19658. useSpecularOverAlpha: boolean;
  19659. private _useReflectionOverAlpha;
  19660. /**
  19661. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  19662. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19663. */
  19664. useReflectionOverAlpha: boolean;
  19665. private _disableLighting;
  19666. /**
  19667. * Does lights from the scene impacts this material.
  19668. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19669. */
  19670. disableLighting: boolean;
  19671. private _useObjectSpaceNormalMap;
  19672. /**
  19673. * Allows using an object space normal map (instead of tangent space).
  19674. */
  19675. useObjectSpaceNormalMap: boolean;
  19676. private _useParallax;
  19677. /**
  19678. * Is parallax enabled or not.
  19679. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19680. */
  19681. useParallax: boolean;
  19682. private _useParallaxOcclusion;
  19683. /**
  19684. * Is parallax occlusion enabled or not.
  19685. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19686. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19687. */
  19688. useParallaxOcclusion: boolean;
  19689. /**
  19690. * 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.
  19691. */
  19692. parallaxScaleBias: number;
  19693. private _roughness;
  19694. /**
  19695. * Helps to define how blurry the reflections should appears in the material.
  19696. */
  19697. roughness: number;
  19698. /**
  19699. * In case of refraction, define the value of the index of refraction.
  19700. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19701. */
  19702. indexOfRefraction: number;
  19703. /**
  19704. * Invert the refraction texture alongside the y axis.
  19705. * It can be useful with procedural textures or probe for instance.
  19706. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19707. */
  19708. invertRefractionY: boolean;
  19709. /**
  19710. * Defines the alpha limits in alpha test mode.
  19711. */
  19712. alphaCutOff: number;
  19713. private _useLightmapAsShadowmap;
  19714. /**
  19715. * In case of light mapping, define whether the map contains light or shadow informations.
  19716. */
  19717. useLightmapAsShadowmap: boolean;
  19718. private _diffuseFresnelParameters;
  19719. /**
  19720. * Define the diffuse fresnel parameters of the material.
  19721. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19722. */
  19723. diffuseFresnelParameters: FresnelParameters;
  19724. private _opacityFresnelParameters;
  19725. /**
  19726. * Define the opacity fresnel parameters of the material.
  19727. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19728. */
  19729. opacityFresnelParameters: FresnelParameters;
  19730. private _reflectionFresnelParameters;
  19731. /**
  19732. * Define the reflection fresnel parameters of the material.
  19733. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19734. */
  19735. reflectionFresnelParameters: FresnelParameters;
  19736. private _refractionFresnelParameters;
  19737. /**
  19738. * Define the refraction fresnel parameters of the material.
  19739. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19740. */
  19741. refractionFresnelParameters: FresnelParameters;
  19742. private _emissiveFresnelParameters;
  19743. /**
  19744. * Define the emissive fresnel parameters of the material.
  19745. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19746. */
  19747. emissiveFresnelParameters: FresnelParameters;
  19748. private _useReflectionFresnelFromSpecular;
  19749. /**
  19750. * If true automatically deducts the fresnels values from the material specularity.
  19751. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19752. */
  19753. useReflectionFresnelFromSpecular: boolean;
  19754. private _useGlossinessFromSpecularMapAlpha;
  19755. /**
  19756. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19757. */
  19758. useGlossinessFromSpecularMapAlpha: boolean;
  19759. private _maxSimultaneousLights;
  19760. /**
  19761. * Defines the maximum number of lights that can be used in the material
  19762. */
  19763. maxSimultaneousLights: number;
  19764. private _invertNormalMapX;
  19765. /**
  19766. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19767. */
  19768. invertNormalMapX: boolean;
  19769. private _invertNormalMapY;
  19770. /**
  19771. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19772. */
  19773. invertNormalMapY: boolean;
  19774. private _twoSidedLighting;
  19775. /**
  19776. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19777. */
  19778. twoSidedLighting: boolean;
  19779. /**
  19780. * Default configuration related to image processing available in the standard Material.
  19781. */
  19782. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19783. /**
  19784. * Gets the image processing configuration used either in this material.
  19785. */
  19786. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19787. /**
  19788. * Sets the Default image processing configuration used either in the this material.
  19789. *
  19790. * If sets to null, the scene one is in use.
  19791. */
  19792. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19793. /**
  19794. * Keep track of the image processing observer to allow dispose and replace.
  19795. */
  19796. private _imageProcessingObserver;
  19797. /**
  19798. * Attaches a new image processing configuration to the Standard Material.
  19799. * @param configuration
  19800. */
  19801. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19802. /**
  19803. * Defines additional PrePass parameters for the material.
  19804. */
  19805. readonly prePassConfiguration: PrePassConfiguration;
  19806. /**
  19807. * Can this material render to prepass
  19808. */
  19809. get isPrePassCapable(): boolean;
  19810. /**
  19811. * Gets whether the color curves effect is enabled.
  19812. */
  19813. get cameraColorCurvesEnabled(): boolean;
  19814. /**
  19815. * Sets whether the color curves effect is enabled.
  19816. */
  19817. set cameraColorCurvesEnabled(value: boolean);
  19818. /**
  19819. * Gets whether the color grading effect is enabled.
  19820. */
  19821. get cameraColorGradingEnabled(): boolean;
  19822. /**
  19823. * Gets whether the color grading effect is enabled.
  19824. */
  19825. set cameraColorGradingEnabled(value: boolean);
  19826. /**
  19827. * Gets whether tonemapping is enabled or not.
  19828. */
  19829. get cameraToneMappingEnabled(): boolean;
  19830. /**
  19831. * Sets whether tonemapping is enabled or not
  19832. */
  19833. set cameraToneMappingEnabled(value: boolean);
  19834. /**
  19835. * The camera exposure used on this material.
  19836. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19837. * This corresponds to a photographic exposure.
  19838. */
  19839. get cameraExposure(): number;
  19840. /**
  19841. * The camera exposure used on this material.
  19842. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19843. * This corresponds to a photographic exposure.
  19844. */
  19845. set cameraExposure(value: number);
  19846. /**
  19847. * Gets The camera contrast used on this material.
  19848. */
  19849. get cameraContrast(): number;
  19850. /**
  19851. * Sets The camera contrast used on this material.
  19852. */
  19853. set cameraContrast(value: number);
  19854. /**
  19855. * Gets the Color Grading 2D Lookup Texture.
  19856. */
  19857. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19858. /**
  19859. * Sets the Color Grading 2D Lookup Texture.
  19860. */
  19861. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19862. /**
  19863. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19864. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19865. * 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;
  19866. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19867. */
  19868. get cameraColorCurves(): Nullable<ColorCurves>;
  19869. /**
  19870. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  19871. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19872. * 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;
  19873. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19874. */
  19875. set cameraColorCurves(value: Nullable<ColorCurves>);
  19876. /**
  19877. * Can this material render to several textures at once
  19878. */
  19879. get canRenderToMRT(): boolean;
  19880. /**
  19881. * Defines the detail map parameters for the material.
  19882. */
  19883. readonly detailMap: DetailMapConfiguration;
  19884. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19885. protected _worldViewProjectionMatrix: Matrix;
  19886. protected _globalAmbientColor: Color3;
  19887. protected _useLogarithmicDepth: boolean;
  19888. protected _rebuildInParallel: boolean;
  19889. /**
  19890. * Instantiates a new standard material.
  19891. * This is the default material used in Babylon. It is the best trade off between quality
  19892. * and performances.
  19893. * @see https://doc.babylonjs.com/babylon101/materials
  19894. * @param name Define the name of the material in the scene
  19895. * @param scene Define the scene the material belong to
  19896. */
  19897. constructor(name: string, scene: Scene);
  19898. /**
  19899. * Gets a boolean indicating that current material needs to register RTT
  19900. */
  19901. get hasRenderTargetTextures(): boolean;
  19902. /**
  19903. * Gets the current class name of the material e.g. "StandardMaterial"
  19904. * Mainly use in serialization.
  19905. * @returns the class name
  19906. */
  19907. getClassName(): string;
  19908. /**
  19909. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19910. * You can try switching to logarithmic depth.
  19911. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19912. */
  19913. get useLogarithmicDepth(): boolean;
  19914. set useLogarithmicDepth(value: boolean);
  19915. /**
  19916. * Specifies if the material will require alpha blending
  19917. * @returns a boolean specifying if alpha blending is needed
  19918. */
  19919. needAlphaBlending(): boolean;
  19920. /**
  19921. * Specifies if this material should be rendered in alpha test mode
  19922. * @returns a boolean specifying if an alpha test is needed.
  19923. */
  19924. needAlphaTesting(): boolean;
  19925. /**
  19926. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19927. */
  19928. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19929. /**
  19930. * Specifies whether or not there is a usable alpha channel for transparency.
  19931. */
  19932. protected _hasAlphaChannel(): boolean;
  19933. /**
  19934. * Get the texture used for alpha test purpose.
  19935. * @returns the diffuse texture in case of the standard material.
  19936. */
  19937. getAlphaTestTexture(): Nullable<BaseTexture>;
  19938. /**
  19939. * Get if the submesh is ready to be used and all its information available.
  19940. * Child classes can use it to update shaders
  19941. * @param mesh defines the mesh to check
  19942. * @param subMesh defines which submesh to check
  19943. * @param useInstances specifies that instances should be used
  19944. * @returns a boolean indicating that the submesh is ready or not
  19945. */
  19946. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19947. /**
  19948. * Builds the material UBO layouts.
  19949. * Used internally during the effect preparation.
  19950. */
  19951. buildUniformLayout(): void;
  19952. /**
  19953. * Unbinds the material from the mesh
  19954. */
  19955. unbind(): void;
  19956. /**
  19957. * Binds the submesh to this material by preparing the effect and shader to draw
  19958. * @param world defines the world transformation matrix
  19959. * @param mesh defines the mesh containing the submesh
  19960. * @param subMesh defines the submesh to bind the material to
  19961. */
  19962. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19963. /**
  19964. * Get the list of animatables in the material.
  19965. * @returns the list of animatables object used in the material
  19966. */
  19967. getAnimatables(): IAnimatable[];
  19968. /**
  19969. * Gets the active textures from the material
  19970. * @returns an array of textures
  19971. */
  19972. getActiveTextures(): BaseTexture[];
  19973. /**
  19974. * Specifies if the material uses a texture
  19975. * @param texture defines the texture to check against the material
  19976. * @returns a boolean specifying if the material uses the texture
  19977. */
  19978. hasTexture(texture: BaseTexture): boolean;
  19979. /**
  19980. * Disposes the material
  19981. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19982. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19983. */
  19984. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19985. /**
  19986. * Makes a duplicate of the material, and gives it a new name
  19987. * @param name defines the new name for the duplicated material
  19988. * @returns the cloned material
  19989. */
  19990. clone(name: string): StandardMaterial;
  19991. /**
  19992. * Serializes this material in a JSON representation
  19993. * @returns the serialized material object
  19994. */
  19995. serialize(): any;
  19996. /**
  19997. * Creates a standard material from parsed material data
  19998. * @param source defines the JSON representation of the material
  19999. * @param scene defines the hosting scene
  20000. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20001. * @returns a new standard material
  20002. */
  20003. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  20004. /**
  20005. * Are diffuse textures enabled in the application.
  20006. */
  20007. static get DiffuseTextureEnabled(): boolean;
  20008. static set DiffuseTextureEnabled(value: boolean);
  20009. /**
  20010. * Are detail textures enabled in the application.
  20011. */
  20012. static get DetailTextureEnabled(): boolean;
  20013. static set DetailTextureEnabled(value: boolean);
  20014. /**
  20015. * Are ambient textures enabled in the application.
  20016. */
  20017. static get AmbientTextureEnabled(): boolean;
  20018. static set AmbientTextureEnabled(value: boolean);
  20019. /**
  20020. * Are opacity textures enabled in the application.
  20021. */
  20022. static get OpacityTextureEnabled(): boolean;
  20023. static set OpacityTextureEnabled(value: boolean);
  20024. /**
  20025. * Are reflection textures enabled in the application.
  20026. */
  20027. static get ReflectionTextureEnabled(): boolean;
  20028. static set ReflectionTextureEnabled(value: boolean);
  20029. /**
  20030. * Are emissive textures enabled in the application.
  20031. */
  20032. static get EmissiveTextureEnabled(): boolean;
  20033. static set EmissiveTextureEnabled(value: boolean);
  20034. /**
  20035. * Are specular textures enabled in the application.
  20036. */
  20037. static get SpecularTextureEnabled(): boolean;
  20038. static set SpecularTextureEnabled(value: boolean);
  20039. /**
  20040. * Are bump textures enabled in the application.
  20041. */
  20042. static get BumpTextureEnabled(): boolean;
  20043. static set BumpTextureEnabled(value: boolean);
  20044. /**
  20045. * Are lightmap textures enabled in the application.
  20046. */
  20047. static get LightmapTextureEnabled(): boolean;
  20048. static set LightmapTextureEnabled(value: boolean);
  20049. /**
  20050. * Are refraction textures enabled in the application.
  20051. */
  20052. static get RefractionTextureEnabled(): boolean;
  20053. static set RefractionTextureEnabled(value: boolean);
  20054. /**
  20055. * Are color grading textures enabled in the application.
  20056. */
  20057. static get ColorGradingTextureEnabled(): boolean;
  20058. static set ColorGradingTextureEnabled(value: boolean);
  20059. /**
  20060. * Are fresnels enabled in the application.
  20061. */
  20062. static get FresnelEnabled(): boolean;
  20063. static set FresnelEnabled(value: boolean);
  20064. }
  20065. }
  20066. declare module BABYLON {
  20067. /** @hidden */
  20068. export var rgbdDecodePixelShader: {
  20069. name: string;
  20070. shader: string;
  20071. };
  20072. }
  20073. declare module BABYLON {
  20074. /** @hidden */
  20075. export var passPixelShader: {
  20076. name: string;
  20077. shader: string;
  20078. };
  20079. }
  20080. declare module BABYLON {
  20081. /** @hidden */
  20082. export var passCubePixelShader: {
  20083. name: string;
  20084. shader: string;
  20085. };
  20086. }
  20087. declare module BABYLON {
  20088. /**
  20089. * PassPostProcess which produces an output the same as it's input
  20090. */
  20091. export class PassPostProcess extends PostProcess {
  20092. /**
  20093. * Gets a string identifying the name of the class
  20094. * @returns "PassPostProcess" string
  20095. */
  20096. getClassName(): string;
  20097. /**
  20098. * Creates the PassPostProcess
  20099. * @param name The name of the effect.
  20100. * @param options The required width/height ratio to downsize to before computing the render pass.
  20101. * @param camera The camera to apply the render pass to.
  20102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20103. * @param engine The engine which the post process will be applied. (default: current engine)
  20104. * @param reusable If the post process can be reused on the same frame. (default: false)
  20105. * @param textureType The type of texture to be used when performing the post processing.
  20106. * @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)
  20107. */
  20108. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20109. /** @hidden */
  20110. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20111. }
  20112. /**
  20113. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20114. */
  20115. export class PassCubePostProcess extends PostProcess {
  20116. private _face;
  20117. /**
  20118. * Gets or sets the cube face to display.
  20119. * * 0 is +X
  20120. * * 1 is -X
  20121. * * 2 is +Y
  20122. * * 3 is -Y
  20123. * * 4 is +Z
  20124. * * 5 is -Z
  20125. */
  20126. get face(): number;
  20127. set face(value: number);
  20128. /**
  20129. * Gets a string identifying the name of the class
  20130. * @returns "PassCubePostProcess" string
  20131. */
  20132. getClassName(): string;
  20133. /**
  20134. * Creates the PassCubePostProcess
  20135. * @param name The name of the effect.
  20136. * @param options The required width/height ratio to downsize to before computing the render pass.
  20137. * @param camera The camera to apply the render pass to.
  20138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20139. * @param engine The engine which the post process will be applied. (default: current engine)
  20140. * @param reusable If the post process can be reused on the same frame. (default: false)
  20141. * @param textureType The type of texture to be used when performing the post processing.
  20142. * @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)
  20143. */
  20144. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20145. /** @hidden */
  20146. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20147. }
  20148. }
  20149. declare module BABYLON {
  20150. /**
  20151. * Class used to host texture specific utilities
  20152. */
  20153. export class TextureTools {
  20154. /**
  20155. * Uses the GPU to create a copy texture rescaled at a given size
  20156. * @param texture Texture to copy from
  20157. * @param width defines the desired width
  20158. * @param height defines the desired height
  20159. * @param useBilinearMode defines if bilinear mode has to be used
  20160. * @return the generated texture
  20161. */
  20162. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20163. /**
  20164. * Apply a post process to a texture
  20165. * @param postProcessName name of the fragment post process
  20166. * @param internalTexture the texture to encode
  20167. * @param scene the scene hosting the texture
  20168. * @param type type of the output texture. If not provided, use the one from internalTexture
  20169. * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
  20170. * @param format format of the output texture. If not provided, use the one from internalTexture
  20171. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20172. */
  20173. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20174. }
  20175. }
  20176. declare module BABYLON {
  20177. /**
  20178. * Class used to host RGBD texture specific utilities
  20179. */
  20180. export class RGBDTextureTools {
  20181. /**
  20182. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20183. * @param texture the texture to expand.
  20184. */
  20185. static ExpandRGBDTexture(texture: Texture): void;
  20186. /**
  20187. * Encode the texture to RGBD if possible.
  20188. * @param internalTexture the texture to encode
  20189. * @param scene the scene hosting the texture
  20190. * @param outputTextureType type of the texture in which the encoding is performed
  20191. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20192. */
  20193. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20194. }
  20195. }
  20196. declare module BABYLON {
  20197. /**
  20198. * Class used to host texture specific utilities
  20199. */
  20200. export class BRDFTextureTools {
  20201. /**
  20202. * Prevents texture cache collision
  20203. */
  20204. private static _instanceNumber;
  20205. /**
  20206. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20207. * @param scene defines the hosting scene
  20208. * @returns the environment BRDF texture
  20209. */
  20210. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20211. private static _environmentBRDFBase64Texture;
  20212. }
  20213. }
  20214. declare module BABYLON {
  20215. /**
  20216. * @hidden
  20217. */
  20218. export interface IMaterialClearCoatDefines {
  20219. CLEARCOAT: boolean;
  20220. CLEARCOAT_DEFAULTIOR: boolean;
  20221. CLEARCOAT_TEXTURE: boolean;
  20222. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20223. CLEARCOAT_TEXTUREDIRECTUV: number;
  20224. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20225. CLEARCOAT_BUMP: boolean;
  20226. CLEARCOAT_BUMPDIRECTUV: number;
  20227. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20228. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20229. CLEARCOAT_REMAP_F0: boolean;
  20230. CLEARCOAT_TINT: boolean;
  20231. CLEARCOAT_TINT_TEXTURE: boolean;
  20232. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20233. /** @hidden */
  20234. _areTexturesDirty: boolean;
  20235. }
  20236. /**
  20237. * Define the code related to the clear coat parameters of the pbr material.
  20238. */
  20239. export class PBRClearCoatConfiguration {
  20240. /**
  20241. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20242. * The default fits with a polyurethane material.
  20243. * @hidden
  20244. */
  20245. static readonly _DefaultIndexOfRefraction: number;
  20246. private _isEnabled;
  20247. /**
  20248. * Defines if the clear coat is enabled in the material.
  20249. */
  20250. isEnabled: boolean;
  20251. /**
  20252. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20253. */
  20254. intensity: number;
  20255. /**
  20256. * Defines the clear coat layer roughness.
  20257. */
  20258. roughness: number;
  20259. private _indexOfRefraction;
  20260. /**
  20261. * Defines the index of refraction of the clear coat.
  20262. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20263. * The default fits with a polyurethane material.
  20264. * Changing the default value is more performance intensive.
  20265. */
  20266. indexOfRefraction: number;
  20267. private _texture;
  20268. /**
  20269. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20270. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20271. * if textureRoughness is not empty, else no texture roughness is used
  20272. */
  20273. texture: Nullable<BaseTexture>;
  20274. private _useRoughnessFromMainTexture;
  20275. /**
  20276. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20277. * If false, the green channel from textureRoughness is used for roughness
  20278. */
  20279. useRoughnessFromMainTexture: boolean;
  20280. private _textureRoughness;
  20281. /**
  20282. * Stores the clear coat roughness in a texture (green channel)
  20283. * Not used if useRoughnessFromMainTexture is true
  20284. */
  20285. textureRoughness: Nullable<BaseTexture>;
  20286. private _remapF0OnInterfaceChange;
  20287. /**
  20288. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20289. */
  20290. remapF0OnInterfaceChange: boolean;
  20291. private _bumpTexture;
  20292. /**
  20293. * Define the clear coat specific bump texture.
  20294. */
  20295. bumpTexture: Nullable<BaseTexture>;
  20296. private _isTintEnabled;
  20297. /**
  20298. * Defines if the clear coat tint is enabled in the material.
  20299. */
  20300. isTintEnabled: boolean;
  20301. /**
  20302. * Defines the clear coat tint of the material.
  20303. * This is only use if tint is enabled
  20304. */
  20305. tintColor: Color3;
  20306. /**
  20307. * Defines the distance at which the tint color should be found in the
  20308. * clear coat media.
  20309. * This is only use if tint is enabled
  20310. */
  20311. tintColorAtDistance: number;
  20312. /**
  20313. * Defines the clear coat layer thickness.
  20314. * This is only use if tint is enabled
  20315. */
  20316. tintThickness: number;
  20317. private _tintTexture;
  20318. /**
  20319. * Stores the clear tint values in a texture.
  20320. * rgb is tint
  20321. * a is a thickness factor
  20322. */
  20323. tintTexture: Nullable<BaseTexture>;
  20324. /** @hidden */
  20325. private _internalMarkAllSubMeshesAsTexturesDirty;
  20326. /** @hidden */
  20327. _markAllSubMeshesAsTexturesDirty(): void;
  20328. /**
  20329. * Instantiate a new instance of clear coat configuration.
  20330. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20331. */
  20332. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20333. /**
  20334. * Gets whether the submesh is ready to be used or not.
  20335. * @param defines the list of "defines" to update.
  20336. * @param scene defines the scene the material belongs to.
  20337. * @param engine defines the engine the material belongs to.
  20338. * @param disableBumpMap defines whether the material disables bump or not.
  20339. * @returns - boolean indicating that the submesh is ready or not.
  20340. */
  20341. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20342. /**
  20343. * Checks to see if a texture is used in the material.
  20344. * @param defines the list of "defines" to update.
  20345. * @param scene defines the scene to the material belongs to.
  20346. */
  20347. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20348. /**
  20349. * Binds the material data.
  20350. * @param uniformBuffer defines the Uniform buffer to fill in.
  20351. * @param scene defines the scene the material belongs to.
  20352. * @param engine defines the engine the material belongs to.
  20353. * @param disableBumpMap defines whether the material disables bump or not.
  20354. * @param isFrozen defines whether the material is frozen or not.
  20355. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20356. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20357. * @param subMesh the submesh to bind data for
  20358. */
  20359. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20360. /**
  20361. * Checks to see if a texture is used in the material.
  20362. * @param texture - Base texture to use.
  20363. * @returns - Boolean specifying if a texture is used in the material.
  20364. */
  20365. hasTexture(texture: BaseTexture): boolean;
  20366. /**
  20367. * Returns an array of the actively used textures.
  20368. * @param activeTextures Array of BaseTextures
  20369. */
  20370. getActiveTextures(activeTextures: BaseTexture[]): void;
  20371. /**
  20372. * Returns the animatable textures.
  20373. * @param animatables Array of animatable textures.
  20374. */
  20375. getAnimatables(animatables: IAnimatable[]): void;
  20376. /**
  20377. * Disposes the resources of the material.
  20378. * @param forceDisposeTextures - Forces the disposal of all textures.
  20379. */
  20380. dispose(forceDisposeTextures?: boolean): void;
  20381. /**
  20382. * Get the current class name of the texture useful for serialization or dynamic coding.
  20383. * @returns "PBRClearCoatConfiguration"
  20384. */
  20385. getClassName(): string;
  20386. /**
  20387. * Add fallbacks to the effect fallbacks list.
  20388. * @param defines defines the Base texture to use.
  20389. * @param fallbacks defines the current fallback list.
  20390. * @param currentRank defines the current fallback rank.
  20391. * @returns the new fallback rank.
  20392. */
  20393. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20394. /**
  20395. * Add the required uniforms to the current list.
  20396. * @param uniforms defines the current uniform list.
  20397. */
  20398. static AddUniforms(uniforms: string[]): void;
  20399. /**
  20400. * Add the required samplers to the current list.
  20401. * @param samplers defines the current sampler list.
  20402. */
  20403. static AddSamplers(samplers: string[]): void;
  20404. /**
  20405. * Add the required uniforms to the current buffer.
  20406. * @param uniformBuffer defines the current uniform buffer.
  20407. */
  20408. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20409. /**
  20410. * Makes a duplicate of the current configuration into another one.
  20411. * @param clearCoatConfiguration define the config where to copy the info
  20412. */
  20413. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20414. /**
  20415. * Serializes this clear coat configuration.
  20416. * @returns - An object with the serialized config.
  20417. */
  20418. serialize(): any;
  20419. /**
  20420. * Parses a anisotropy Configuration from a serialized object.
  20421. * @param source - Serialized object.
  20422. * @param scene Defines the scene we are parsing for
  20423. * @param rootUrl Defines the rootUrl to load from
  20424. */
  20425. parse(source: any, scene: Scene, rootUrl: string): void;
  20426. }
  20427. }
  20428. declare module BABYLON {
  20429. /**
  20430. * @hidden
  20431. */
  20432. export interface IMaterialAnisotropicDefines {
  20433. ANISOTROPIC: boolean;
  20434. ANISOTROPIC_TEXTURE: boolean;
  20435. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20436. MAINUV1: boolean;
  20437. _areTexturesDirty: boolean;
  20438. _needUVs: boolean;
  20439. }
  20440. /**
  20441. * Define the code related to the anisotropic parameters of the pbr material.
  20442. */
  20443. export class PBRAnisotropicConfiguration {
  20444. private _isEnabled;
  20445. /**
  20446. * Defines if the anisotropy is enabled in the material.
  20447. */
  20448. isEnabled: boolean;
  20449. /**
  20450. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20451. */
  20452. intensity: number;
  20453. /**
  20454. * Defines if the effect is along the tangents, bitangents or in between.
  20455. * By default, the effect is "stretching" the highlights along the tangents.
  20456. */
  20457. direction: Vector2;
  20458. private _texture;
  20459. /**
  20460. * Stores the anisotropy values in a texture.
  20461. * rg is direction (like normal from -1 to 1)
  20462. * b is a intensity
  20463. */
  20464. texture: Nullable<BaseTexture>;
  20465. /** @hidden */
  20466. private _internalMarkAllSubMeshesAsTexturesDirty;
  20467. /** @hidden */
  20468. _markAllSubMeshesAsTexturesDirty(): void;
  20469. /**
  20470. * Instantiate a new instance of anisotropy configuration.
  20471. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20472. */
  20473. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20474. /**
  20475. * Specifies that the submesh is ready to be used.
  20476. * @param defines the list of "defines" to update.
  20477. * @param scene defines the scene the material belongs to.
  20478. * @returns - boolean indicating that the submesh is ready or not.
  20479. */
  20480. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20481. /**
  20482. * Checks to see if a texture is used in the material.
  20483. * @param defines the list of "defines" to update.
  20484. * @param mesh the mesh we are preparing the defines for.
  20485. * @param scene defines the scene the material belongs to.
  20486. */
  20487. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20488. /**
  20489. * Binds the material data.
  20490. * @param uniformBuffer defines the Uniform buffer to fill in.
  20491. * @param scene defines the scene the material belongs to.
  20492. * @param isFrozen defines whether the material is frozen or not.
  20493. */
  20494. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20495. /**
  20496. * Checks to see if a texture is used in the material.
  20497. * @param texture - Base texture to use.
  20498. * @returns - Boolean specifying if a texture is used in the material.
  20499. */
  20500. hasTexture(texture: BaseTexture): boolean;
  20501. /**
  20502. * Returns an array of the actively used textures.
  20503. * @param activeTextures Array of BaseTextures
  20504. */
  20505. getActiveTextures(activeTextures: BaseTexture[]): void;
  20506. /**
  20507. * Returns the animatable textures.
  20508. * @param animatables Array of animatable textures.
  20509. */
  20510. getAnimatables(animatables: IAnimatable[]): void;
  20511. /**
  20512. * Disposes the resources of the material.
  20513. * @param forceDisposeTextures - Forces the disposal of all textures.
  20514. */
  20515. dispose(forceDisposeTextures?: boolean): void;
  20516. /**
  20517. * Get the current class name of the texture useful for serialization or dynamic coding.
  20518. * @returns "PBRAnisotropicConfiguration"
  20519. */
  20520. getClassName(): string;
  20521. /**
  20522. * Add fallbacks to the effect fallbacks list.
  20523. * @param defines defines the Base texture to use.
  20524. * @param fallbacks defines the current fallback list.
  20525. * @param currentRank defines the current fallback rank.
  20526. * @returns the new fallback rank.
  20527. */
  20528. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20529. /**
  20530. * Add the required uniforms to the current list.
  20531. * @param uniforms defines the current uniform list.
  20532. */
  20533. static AddUniforms(uniforms: string[]): void;
  20534. /**
  20535. * Add the required uniforms to the current buffer.
  20536. * @param uniformBuffer defines the current uniform buffer.
  20537. */
  20538. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20539. /**
  20540. * Add the required samplers to the current list.
  20541. * @param samplers defines the current sampler list.
  20542. */
  20543. static AddSamplers(samplers: string[]): void;
  20544. /**
  20545. * Makes a duplicate of the current configuration into another one.
  20546. * @param anisotropicConfiguration define the config where to copy the info
  20547. */
  20548. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20549. /**
  20550. * Serializes this anisotropy configuration.
  20551. * @returns - An object with the serialized config.
  20552. */
  20553. serialize(): any;
  20554. /**
  20555. * Parses a anisotropy Configuration from a serialized object.
  20556. * @param source - Serialized object.
  20557. * @param scene Defines the scene we are parsing for
  20558. * @param rootUrl Defines the rootUrl to load from
  20559. */
  20560. parse(source: any, scene: Scene, rootUrl: string): void;
  20561. }
  20562. }
  20563. declare module BABYLON {
  20564. /**
  20565. * @hidden
  20566. */
  20567. export interface IMaterialBRDFDefines {
  20568. BRDF_V_HEIGHT_CORRELATED: boolean;
  20569. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20570. SPHERICAL_HARMONICS: boolean;
  20571. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20572. /** @hidden */
  20573. _areMiscDirty: boolean;
  20574. }
  20575. /**
  20576. * Define the code related to the BRDF parameters of the pbr material.
  20577. */
  20578. export class PBRBRDFConfiguration {
  20579. /**
  20580. * Default value used for the energy conservation.
  20581. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20582. */
  20583. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20584. /**
  20585. * Default value used for the Smith Visibility Height Correlated mode.
  20586. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20587. */
  20588. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20589. /**
  20590. * Default value used for the IBL diffuse part.
  20591. * This can help switching back to the polynomials mode globally which is a tiny bit
  20592. * less GPU intensive at the drawback of a lower quality.
  20593. */
  20594. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20595. /**
  20596. * Default value used for activating energy conservation for the specular workflow.
  20597. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20598. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20599. */
  20600. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20601. private _useEnergyConservation;
  20602. /**
  20603. * Defines if the material uses energy conservation.
  20604. */
  20605. useEnergyConservation: boolean;
  20606. private _useSmithVisibilityHeightCorrelated;
  20607. /**
  20608. * LEGACY Mode set to false
  20609. * Defines if the material uses height smith correlated visibility term.
  20610. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20611. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20612. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20613. * Not relying on height correlated will also disable energy conservation.
  20614. */
  20615. useSmithVisibilityHeightCorrelated: boolean;
  20616. private _useSphericalHarmonics;
  20617. /**
  20618. * LEGACY Mode set to false
  20619. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20620. * diffuse part of the IBL.
  20621. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20622. * to the ground truth.
  20623. */
  20624. useSphericalHarmonics: boolean;
  20625. private _useSpecularGlossinessInputEnergyConservation;
  20626. /**
  20627. * Defines if the material uses energy conservation, when the specular workflow is active.
  20628. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20629. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20630. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20631. */
  20632. useSpecularGlossinessInputEnergyConservation: boolean;
  20633. /** @hidden */
  20634. private _internalMarkAllSubMeshesAsMiscDirty;
  20635. /** @hidden */
  20636. _markAllSubMeshesAsMiscDirty(): void;
  20637. /**
  20638. * Instantiate a new instance of clear coat configuration.
  20639. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20640. */
  20641. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20642. /**
  20643. * Checks to see if a texture is used in the material.
  20644. * @param defines the list of "defines" to update.
  20645. */
  20646. prepareDefines(defines: IMaterialBRDFDefines): void;
  20647. /**
  20648. * Get the current class name of the texture useful for serialization or dynamic coding.
  20649. * @returns "PBRClearCoatConfiguration"
  20650. */
  20651. getClassName(): string;
  20652. /**
  20653. * Makes a duplicate of the current configuration into another one.
  20654. * @param brdfConfiguration define the config where to copy the info
  20655. */
  20656. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20657. /**
  20658. * Serializes this BRDF configuration.
  20659. * @returns - An object with the serialized config.
  20660. */
  20661. serialize(): any;
  20662. /**
  20663. * Parses a anisotropy Configuration from a serialized object.
  20664. * @param source - Serialized object.
  20665. * @param scene Defines the scene we are parsing for
  20666. * @param rootUrl Defines the rootUrl to load from
  20667. */
  20668. parse(source: any, scene: Scene, rootUrl: string): void;
  20669. }
  20670. }
  20671. declare module BABYLON {
  20672. /**
  20673. * @hidden
  20674. */
  20675. export interface IMaterialSheenDefines {
  20676. SHEEN: boolean;
  20677. SHEEN_TEXTURE: boolean;
  20678. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20679. SHEEN_TEXTUREDIRECTUV: number;
  20680. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20681. SHEEN_LINKWITHALBEDO: boolean;
  20682. SHEEN_ROUGHNESS: boolean;
  20683. SHEEN_ALBEDOSCALING: boolean;
  20684. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20685. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20686. /** @hidden */
  20687. _areTexturesDirty: boolean;
  20688. }
  20689. /**
  20690. * Define the code related to the Sheen parameters of the pbr material.
  20691. */
  20692. export class PBRSheenConfiguration {
  20693. private _isEnabled;
  20694. /**
  20695. * Defines if the material uses sheen.
  20696. */
  20697. isEnabled: boolean;
  20698. private _linkSheenWithAlbedo;
  20699. /**
  20700. * Defines if the sheen is linked to the sheen color.
  20701. */
  20702. linkSheenWithAlbedo: boolean;
  20703. /**
  20704. * Defines the sheen intensity.
  20705. */
  20706. intensity: number;
  20707. /**
  20708. * Defines the sheen color.
  20709. */
  20710. color: Color3;
  20711. private _texture;
  20712. /**
  20713. * Stores the sheen tint values in a texture.
  20714. * rgb is tint
  20715. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  20716. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20717. */
  20718. texture: Nullable<BaseTexture>;
  20719. private _useRoughnessFromMainTexture;
  20720. /**
  20721. * Indicates that the alpha channel of the texture property will be used for roughness.
  20722. * Has no effect if the roughness (and texture!) property is not defined
  20723. */
  20724. useRoughnessFromMainTexture: boolean;
  20725. private _roughness;
  20726. /**
  20727. * Defines the sheen roughness.
  20728. * It is not taken into account if linkSheenWithAlbedo is true.
  20729. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20730. */
  20731. roughness: Nullable<number>;
  20732. private _textureRoughness;
  20733. /**
  20734. * Stores the sheen roughness in a texture.
  20735. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20736. */
  20737. textureRoughness: Nullable<BaseTexture>;
  20738. private _albedoScaling;
  20739. /**
  20740. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20741. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20742. * making it easier to setup and tweak the effect
  20743. */
  20744. albedoScaling: boolean;
  20745. /** @hidden */
  20746. private _internalMarkAllSubMeshesAsTexturesDirty;
  20747. /** @hidden */
  20748. _markAllSubMeshesAsTexturesDirty(): void;
  20749. /**
  20750. * Instantiate a new instance of clear coat configuration.
  20751. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20752. */
  20753. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20754. /**
  20755. * Specifies that the submesh is ready to be used.
  20756. * @param defines the list of "defines" to update.
  20757. * @param scene defines the scene the material belongs to.
  20758. * @returns - boolean indicating that the submesh is ready or not.
  20759. */
  20760. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20761. /**
  20762. * Checks to see if a texture is used in the material.
  20763. * @param defines the list of "defines" to update.
  20764. * @param scene defines the scene the material belongs to.
  20765. */
  20766. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20767. /**
  20768. * Binds the material data.
  20769. * @param uniformBuffer defines the Uniform buffer to fill in.
  20770. * @param scene defines the scene the material belongs to.
  20771. * @param isFrozen defines whether the material is frozen or not.
  20772. * @param subMesh the submesh to bind data for
  20773. */
  20774. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20775. /**
  20776. * Checks to see if a texture is used in the material.
  20777. * @param texture - Base texture to use.
  20778. * @returns - Boolean specifying if a texture is used in the material.
  20779. */
  20780. hasTexture(texture: BaseTexture): boolean;
  20781. /**
  20782. * Returns an array of the actively used textures.
  20783. * @param activeTextures Array of BaseTextures
  20784. */
  20785. getActiveTextures(activeTextures: BaseTexture[]): void;
  20786. /**
  20787. * Returns the animatable textures.
  20788. * @param animatables Array of animatable textures.
  20789. */
  20790. getAnimatables(animatables: IAnimatable[]): void;
  20791. /**
  20792. * Disposes the resources of the material.
  20793. * @param forceDisposeTextures - Forces the disposal of all textures.
  20794. */
  20795. dispose(forceDisposeTextures?: boolean): void;
  20796. /**
  20797. * Get the current class name of the texture useful for serialization or dynamic coding.
  20798. * @returns "PBRSheenConfiguration"
  20799. */
  20800. getClassName(): string;
  20801. /**
  20802. * Add fallbacks to the effect fallbacks list.
  20803. * @param defines defines the Base texture to use.
  20804. * @param fallbacks defines the current fallback list.
  20805. * @param currentRank defines the current fallback rank.
  20806. * @returns the new fallback rank.
  20807. */
  20808. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20809. /**
  20810. * Add the required uniforms to the current list.
  20811. * @param uniforms defines the current uniform list.
  20812. */
  20813. static AddUniforms(uniforms: string[]): void;
  20814. /**
  20815. * Add the required uniforms to the current buffer.
  20816. * @param uniformBuffer defines the current uniform buffer.
  20817. */
  20818. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20819. /**
  20820. * Add the required samplers to the current list.
  20821. * @param samplers defines the current sampler list.
  20822. */
  20823. static AddSamplers(samplers: string[]): void;
  20824. /**
  20825. * Makes a duplicate of the current configuration into another one.
  20826. * @param sheenConfiguration define the config where to copy the info
  20827. */
  20828. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20829. /**
  20830. * Serializes this BRDF configuration.
  20831. * @returns - An object with the serialized config.
  20832. */
  20833. serialize(): any;
  20834. /**
  20835. * Parses a anisotropy Configuration from a serialized object.
  20836. * @param source - Serialized object.
  20837. * @param scene Defines the scene we are parsing for
  20838. * @param rootUrl Defines the rootUrl to load from
  20839. */
  20840. parse(source: any, scene: Scene, rootUrl: string): void;
  20841. }
  20842. }
  20843. declare module BABYLON {
  20844. /**
  20845. * @hidden
  20846. */
  20847. export interface IMaterialSubSurfaceDefines {
  20848. SUBSURFACE: boolean;
  20849. SS_REFRACTION: boolean;
  20850. SS_TRANSLUCENCY: boolean;
  20851. SS_SCATTERING: boolean;
  20852. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20853. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20854. SS_REFRACTIONMAP_3D: boolean;
  20855. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20856. SS_LODINREFRACTIONALPHA: boolean;
  20857. SS_GAMMAREFRACTION: boolean;
  20858. SS_RGBDREFRACTION: boolean;
  20859. SS_LINEARSPECULARREFRACTION: boolean;
  20860. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20861. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20862. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20863. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20864. /** @hidden */
  20865. _areTexturesDirty: boolean;
  20866. }
  20867. /**
  20868. * Define the code related to the sub surface parameters of the pbr material.
  20869. */
  20870. export class PBRSubSurfaceConfiguration {
  20871. private _isRefractionEnabled;
  20872. /**
  20873. * Defines if the refraction is enabled in the material.
  20874. */
  20875. isRefractionEnabled: boolean;
  20876. private _isTranslucencyEnabled;
  20877. /**
  20878. * Defines if the translucency is enabled in the material.
  20879. */
  20880. isTranslucencyEnabled: boolean;
  20881. private _isScatteringEnabled;
  20882. /**
  20883. * Defines if the sub surface scattering is enabled in the material.
  20884. */
  20885. isScatteringEnabled: boolean;
  20886. private _scatteringDiffusionProfileIndex;
  20887. /**
  20888. * Diffusion profile for subsurface scattering.
  20889. * Useful for better scattering in the skins or foliages.
  20890. */
  20891. get scatteringDiffusionProfile(): Nullable<Color3>;
  20892. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20893. /**
  20894. * Defines the refraction intensity of the material.
  20895. * The refraction when enabled replaces the Diffuse part of the material.
  20896. * The intensity helps transitioning between diffuse and refraction.
  20897. */
  20898. refractionIntensity: number;
  20899. /**
  20900. * Defines the translucency intensity of the material.
  20901. * When translucency has been enabled, this defines how much of the "translucency"
  20902. * is added to the diffuse part of the material.
  20903. */
  20904. translucencyIntensity: number;
  20905. /**
  20906. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20907. */
  20908. useAlbedoToTintRefraction: boolean;
  20909. private _thicknessTexture;
  20910. /**
  20911. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20912. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20913. * 0 would mean minimumThickness
  20914. * 1 would mean maximumThickness
  20915. * The other channels might be use as a mask to vary the different effects intensity.
  20916. */
  20917. thicknessTexture: Nullable<BaseTexture>;
  20918. private _refractionTexture;
  20919. /**
  20920. * Defines the texture to use for refraction.
  20921. */
  20922. refractionTexture: Nullable<BaseTexture>;
  20923. private _indexOfRefraction;
  20924. /**
  20925. * Index of refraction of the material base layer.
  20926. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20927. *
  20928. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20929. *
  20930. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20931. */
  20932. indexOfRefraction: number;
  20933. private _volumeIndexOfRefraction;
  20934. /**
  20935. * Index of refraction of the material's volume.
  20936. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20937. *
  20938. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20939. * the volume will use the same IOR as the surface.
  20940. */
  20941. get volumeIndexOfRefraction(): number;
  20942. set volumeIndexOfRefraction(value: number);
  20943. private _invertRefractionY;
  20944. /**
  20945. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20946. */
  20947. invertRefractionY: boolean;
  20948. private _linkRefractionWithTransparency;
  20949. /**
  20950. * This parameters will make the material used its opacity to control how much it is refracting against not.
  20951. * Materials half opaque for instance using refraction could benefit from this control.
  20952. */
  20953. linkRefractionWithTransparency: boolean;
  20954. /**
  20955. * Defines the minimum thickness stored in the thickness map.
  20956. * If no thickness map is defined, this value will be used to simulate thickness.
  20957. */
  20958. minimumThickness: number;
  20959. /**
  20960. * Defines the maximum thickness stored in the thickness map.
  20961. */
  20962. maximumThickness: number;
  20963. /**
  20964. * Defines the volume tint of the material.
  20965. * This is used for both translucency and scattering.
  20966. */
  20967. tintColor: Color3;
  20968. /**
  20969. * Defines the distance at which the tint color should be found in the media.
  20970. * This is used for refraction only.
  20971. */
  20972. tintColorAtDistance: number;
  20973. /**
  20974. * Defines how far each channel transmit through the media.
  20975. * It is defined as a color to simplify it selection.
  20976. */
  20977. diffusionDistance: Color3;
  20978. private _useMaskFromThicknessTexture;
  20979. /**
  20980. * Stores the intensity of the different subsurface effects in the thickness texture.
  20981. * * the green channel is the translucency intensity.
  20982. * * the blue channel is the scattering intensity.
  20983. * * the alpha channel is the refraction intensity.
  20984. */
  20985. useMaskFromThicknessTexture: boolean;
  20986. private _scene;
  20987. private _useMaskFromThicknessTextureGltf;
  20988. /**
  20989. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20990. * matches the channel-packing that is used by glTF.
  20991. * * the red channel is the transmission/translucency intensity.
  20992. * * the green channel is the thickness.
  20993. */
  20994. useMaskFromThicknessTextureGltf: boolean;
  20995. /** @hidden */
  20996. private _internalMarkAllSubMeshesAsTexturesDirty;
  20997. private _internalMarkScenePrePassDirty;
  20998. /** @hidden */
  20999. _markAllSubMeshesAsTexturesDirty(): void;
  21000. /** @hidden */
  21001. _markScenePrePassDirty(): void;
  21002. /**
  21003. * Instantiate a new instance of sub surface configuration.
  21004. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21005. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  21006. * @param scene The scene
  21007. */
  21008. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  21009. /**
  21010. * Gets whether the submesh is ready to be used or not.
  21011. * @param defines the list of "defines" to update.
  21012. * @param scene defines the scene the material belongs to.
  21013. * @returns - boolean indicating that the submesh is ready or not.
  21014. */
  21015. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  21016. /**
  21017. * Checks to see if a texture is used in the material.
  21018. * @param defines the list of "defines" to update.
  21019. * @param scene defines the scene to the material belongs to.
  21020. */
  21021. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  21022. /**
  21023. * Binds the material data.
  21024. * @param uniformBuffer defines the Uniform buffer to fill in.
  21025. * @param scene defines the scene the material belongs to.
  21026. * @param engine defines the engine the material belongs to.
  21027. * @param isFrozen defines whether the material is frozen or not.
  21028. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  21029. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  21030. */
  21031. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  21032. /**
  21033. * Unbinds the material from the mesh.
  21034. * @param activeEffect defines the effect that should be unbound from.
  21035. * @returns true if unbound, otherwise false
  21036. */
  21037. unbind(activeEffect: Effect): boolean;
  21038. /**
  21039. * Returns the texture used for refraction or null if none is used.
  21040. * @param scene defines the scene the material belongs to.
  21041. * @returns - Refraction texture if present. If no refraction texture and refraction
  21042. * is linked with transparency, returns environment texture. Otherwise, returns null.
  21043. */
  21044. private _getRefractionTexture;
  21045. /**
  21046. * Returns true if alpha blending should be disabled.
  21047. */
  21048. get disableAlphaBlending(): boolean;
  21049. /**
  21050. * Fills the list of render target textures.
  21051. * @param renderTargets the list of render targets to update
  21052. */
  21053. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  21054. /**
  21055. * Checks to see if a texture is used in the material.
  21056. * @param texture - Base texture to use.
  21057. * @returns - Boolean specifying if a texture is used in the material.
  21058. */
  21059. hasTexture(texture: BaseTexture): boolean;
  21060. /**
  21061. * Gets a boolean indicating that current material needs to register RTT
  21062. * @returns true if this uses a render target otherwise false.
  21063. */
  21064. hasRenderTargetTextures(): boolean;
  21065. /**
  21066. * Returns an array of the actively used textures.
  21067. * @param activeTextures Array of BaseTextures
  21068. */
  21069. getActiveTextures(activeTextures: BaseTexture[]): void;
  21070. /**
  21071. * Returns the animatable textures.
  21072. * @param animatables Array of animatable textures.
  21073. */
  21074. getAnimatables(animatables: IAnimatable[]): void;
  21075. /**
  21076. * Disposes the resources of the material.
  21077. * @param forceDisposeTextures - Forces the disposal of all textures.
  21078. */
  21079. dispose(forceDisposeTextures?: boolean): void;
  21080. /**
  21081. * Get the current class name of the texture useful for serialization or dynamic coding.
  21082. * @returns "PBRSubSurfaceConfiguration"
  21083. */
  21084. getClassName(): string;
  21085. /**
  21086. * Add fallbacks to the effect fallbacks list.
  21087. * @param defines defines the Base texture to use.
  21088. * @param fallbacks defines the current fallback list.
  21089. * @param currentRank defines the current fallback rank.
  21090. * @returns the new fallback rank.
  21091. */
  21092. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21093. /**
  21094. * Add the required uniforms to the current list.
  21095. * @param uniforms defines the current uniform list.
  21096. */
  21097. static AddUniforms(uniforms: string[]): void;
  21098. /**
  21099. * Add the required samplers to the current list.
  21100. * @param samplers defines the current sampler list.
  21101. */
  21102. static AddSamplers(samplers: string[]): void;
  21103. /**
  21104. * Add the required uniforms to the current buffer.
  21105. * @param uniformBuffer defines the current uniform buffer.
  21106. */
  21107. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21108. /**
  21109. * Makes a duplicate of the current configuration into another one.
  21110. * @param configuration define the config where to copy the info
  21111. */
  21112. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21113. /**
  21114. * Serializes this Sub Surface configuration.
  21115. * @returns - An object with the serialized config.
  21116. */
  21117. serialize(): any;
  21118. /**
  21119. * Parses a anisotropy Configuration from a serialized object.
  21120. * @param source - Serialized object.
  21121. * @param scene Defines the scene we are parsing for
  21122. * @param rootUrl Defines the rootUrl to load from
  21123. */
  21124. parse(source: any, scene: Scene, rootUrl: string): void;
  21125. }
  21126. }
  21127. declare module BABYLON {
  21128. /**
  21129. * Class representing spherical harmonics coefficients to the 3rd degree
  21130. */
  21131. export class SphericalHarmonics {
  21132. /**
  21133. * Defines whether or not the harmonics have been prescaled for rendering.
  21134. */
  21135. preScaled: boolean;
  21136. /**
  21137. * The l0,0 coefficients of the spherical harmonics
  21138. */
  21139. l00: Vector3;
  21140. /**
  21141. * The l1,-1 coefficients of the spherical harmonics
  21142. */
  21143. l1_1: Vector3;
  21144. /**
  21145. * The l1,0 coefficients of the spherical harmonics
  21146. */
  21147. l10: Vector3;
  21148. /**
  21149. * The l1,1 coefficients of the spherical harmonics
  21150. */
  21151. l11: Vector3;
  21152. /**
  21153. * The l2,-2 coefficients of the spherical harmonics
  21154. */
  21155. l2_2: Vector3;
  21156. /**
  21157. * The l2,-1 coefficients of the spherical harmonics
  21158. */
  21159. l2_1: Vector3;
  21160. /**
  21161. * The l2,0 coefficients of the spherical harmonics
  21162. */
  21163. l20: Vector3;
  21164. /**
  21165. * The l2,1 coefficients of the spherical harmonics
  21166. */
  21167. l21: Vector3;
  21168. /**
  21169. * The l2,2 coefficients of the spherical harmonics
  21170. */
  21171. l22: Vector3;
  21172. /**
  21173. * Adds a light to the spherical harmonics
  21174. * @param direction the direction of the light
  21175. * @param color the color of the light
  21176. * @param deltaSolidAngle the delta solid angle of the light
  21177. */
  21178. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21179. /**
  21180. * Scales the spherical harmonics by the given amount
  21181. * @param scale the amount to scale
  21182. */
  21183. scaleInPlace(scale: number): void;
  21184. /**
  21185. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21186. *
  21187. * ```
  21188. * E_lm = A_l * L_lm
  21189. * ```
  21190. *
  21191. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21192. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21193. * the scaling factors are given in equation 9.
  21194. */
  21195. convertIncidentRadianceToIrradiance(): void;
  21196. /**
  21197. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21198. *
  21199. * ```
  21200. * L = (1/pi) * E * rho
  21201. * ```
  21202. *
  21203. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21204. */
  21205. convertIrradianceToLambertianRadiance(): void;
  21206. /**
  21207. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21208. * required operations at run time.
  21209. *
  21210. * This is simply done by scaling back the SH with Ylm constants parameter.
  21211. * The trigonometric part being applied by the shader at run time.
  21212. */
  21213. preScaleForRendering(): void;
  21214. /**
  21215. * Constructs a spherical harmonics from an array.
  21216. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21217. * @returns the spherical harmonics
  21218. */
  21219. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21220. /**
  21221. * Gets the spherical harmonics from polynomial
  21222. * @param polynomial the spherical polynomial
  21223. * @returns the spherical harmonics
  21224. */
  21225. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21226. }
  21227. /**
  21228. * Class representing spherical polynomial coefficients to the 3rd degree
  21229. */
  21230. export class SphericalPolynomial {
  21231. private _harmonics;
  21232. /**
  21233. * The spherical harmonics used to create the polynomials.
  21234. */
  21235. get preScaledHarmonics(): SphericalHarmonics;
  21236. /**
  21237. * The x coefficients of the spherical polynomial
  21238. */
  21239. x: Vector3;
  21240. /**
  21241. * The y coefficients of the spherical polynomial
  21242. */
  21243. y: Vector3;
  21244. /**
  21245. * The z coefficients of the spherical polynomial
  21246. */
  21247. z: Vector3;
  21248. /**
  21249. * The xx coefficients of the spherical polynomial
  21250. */
  21251. xx: Vector3;
  21252. /**
  21253. * The yy coefficients of the spherical polynomial
  21254. */
  21255. yy: Vector3;
  21256. /**
  21257. * The zz coefficients of the spherical polynomial
  21258. */
  21259. zz: Vector3;
  21260. /**
  21261. * The xy coefficients of the spherical polynomial
  21262. */
  21263. xy: Vector3;
  21264. /**
  21265. * The yz coefficients of the spherical polynomial
  21266. */
  21267. yz: Vector3;
  21268. /**
  21269. * The zx coefficients of the spherical polynomial
  21270. */
  21271. zx: Vector3;
  21272. /**
  21273. * Adds an ambient color to the spherical polynomial
  21274. * @param color the color to add
  21275. */
  21276. addAmbient(color: Color3): void;
  21277. /**
  21278. * Scales the spherical polynomial by the given amount
  21279. * @param scale the amount to scale
  21280. */
  21281. scaleInPlace(scale: number): void;
  21282. /**
  21283. * Gets the spherical polynomial from harmonics
  21284. * @param harmonics the spherical harmonics
  21285. * @returns the spherical polynomial
  21286. */
  21287. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21288. /**
  21289. * Constructs a spherical polynomial from an array.
  21290. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21291. * @returns the spherical polynomial
  21292. */
  21293. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21294. }
  21295. }
  21296. declare module BABYLON {
  21297. /**
  21298. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21299. */
  21300. export interface CubeMapInfo {
  21301. /**
  21302. * The pixel array for the front face.
  21303. * This is stored in format, left to right, up to down format.
  21304. */
  21305. front: Nullable<ArrayBufferView>;
  21306. /**
  21307. * The pixel array for the back face.
  21308. * This is stored in format, left to right, up to down format.
  21309. */
  21310. back: Nullable<ArrayBufferView>;
  21311. /**
  21312. * The pixel array for the left face.
  21313. * This is stored in format, left to right, up to down format.
  21314. */
  21315. left: Nullable<ArrayBufferView>;
  21316. /**
  21317. * The pixel array for the right face.
  21318. * This is stored in format, left to right, up to down format.
  21319. */
  21320. right: Nullable<ArrayBufferView>;
  21321. /**
  21322. * The pixel array for the up face.
  21323. * This is stored in format, left to right, up to down format.
  21324. */
  21325. up: Nullable<ArrayBufferView>;
  21326. /**
  21327. * The pixel array for the down face.
  21328. * This is stored in format, left to right, up to down format.
  21329. */
  21330. down: Nullable<ArrayBufferView>;
  21331. /**
  21332. * The size of the cubemap stored.
  21333. *
  21334. * Each faces will be size * size pixels.
  21335. */
  21336. size: number;
  21337. /**
  21338. * The format of the texture.
  21339. *
  21340. * RGBA, RGB.
  21341. */
  21342. format: number;
  21343. /**
  21344. * The type of the texture data.
  21345. *
  21346. * UNSIGNED_INT, FLOAT.
  21347. */
  21348. type: number;
  21349. /**
  21350. * Specifies whether the texture is in gamma space.
  21351. */
  21352. gammaSpace: boolean;
  21353. }
  21354. /**
  21355. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21356. */
  21357. export class PanoramaToCubeMapTools {
  21358. private static FACE_LEFT;
  21359. private static FACE_RIGHT;
  21360. private static FACE_FRONT;
  21361. private static FACE_BACK;
  21362. private static FACE_DOWN;
  21363. private static FACE_UP;
  21364. /**
  21365. * Converts a panorama stored in RGB right to left up to down format into a cubemap (6 faces).
  21366. *
  21367. * @param float32Array The source data.
  21368. * @param inputWidth The width of the input panorama.
  21369. * @param inputHeight The height of the input panorama.
  21370. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21371. * @return The cubemap data
  21372. */
  21373. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21374. private static CreateCubemapTexture;
  21375. private static CalcProjectionSpherical;
  21376. }
  21377. }
  21378. declare module BABYLON {
  21379. /**
  21380. * Helper class dealing with the extraction of spherical polynomial dataArray
  21381. * from a cube map.
  21382. */
  21383. export class CubeMapToSphericalPolynomialTools {
  21384. private static FileFaces;
  21385. /**
  21386. * Converts a texture to the according Spherical Polynomial data.
  21387. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21388. *
  21389. * @param texture The texture to extract the information from.
  21390. * @return The Spherical Polynomial data.
  21391. */
  21392. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21393. /**
  21394. * Converts a cubemap to the according Spherical Polynomial data.
  21395. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21396. *
  21397. * @param cubeInfo The Cube map to extract the information from.
  21398. * @return The Spherical Polynomial data.
  21399. */
  21400. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21401. }
  21402. }
  21403. declare module BABYLON {
  21404. interface BaseTexture {
  21405. /**
  21406. * Get the polynomial representation of the texture data.
  21407. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21408. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21409. */
  21410. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21411. }
  21412. }
  21413. declare module BABYLON {
  21414. /** @hidden */
  21415. export var pbrFragmentDeclaration: {
  21416. name: string;
  21417. shader: string;
  21418. };
  21419. }
  21420. declare module BABYLON {
  21421. /** @hidden */
  21422. export var pbrUboDeclaration: {
  21423. name: string;
  21424. shader: string;
  21425. };
  21426. }
  21427. declare module BABYLON {
  21428. /** @hidden */
  21429. export var pbrFragmentExtraDeclaration: {
  21430. name: string;
  21431. shader: string;
  21432. };
  21433. }
  21434. declare module BABYLON {
  21435. /** @hidden */
  21436. export var pbrFragmentSamplersDeclaration: {
  21437. name: string;
  21438. shader: string;
  21439. };
  21440. }
  21441. declare module BABYLON {
  21442. /** @hidden */
  21443. export var subSurfaceScatteringFunctions: {
  21444. name: string;
  21445. shader: string;
  21446. };
  21447. }
  21448. declare module BABYLON {
  21449. /** @hidden */
  21450. export var importanceSampling: {
  21451. name: string;
  21452. shader: string;
  21453. };
  21454. }
  21455. declare module BABYLON {
  21456. /** @hidden */
  21457. export var pbrHelperFunctions: {
  21458. name: string;
  21459. shader: string;
  21460. };
  21461. }
  21462. declare module BABYLON {
  21463. /** @hidden */
  21464. export var harmonicsFunctions: {
  21465. name: string;
  21466. shader: string;
  21467. };
  21468. }
  21469. declare module BABYLON {
  21470. /** @hidden */
  21471. export var pbrDirectLightingSetupFunctions: {
  21472. name: string;
  21473. shader: string;
  21474. };
  21475. }
  21476. declare module BABYLON {
  21477. /** @hidden */
  21478. export var pbrDirectLightingFalloffFunctions: {
  21479. name: string;
  21480. shader: string;
  21481. };
  21482. }
  21483. declare module BABYLON {
  21484. /** @hidden */
  21485. export var pbrBRDFFunctions: {
  21486. name: string;
  21487. shader: string;
  21488. };
  21489. }
  21490. declare module BABYLON {
  21491. /** @hidden */
  21492. export var hdrFilteringFunctions: {
  21493. name: string;
  21494. shader: string;
  21495. };
  21496. }
  21497. declare module BABYLON {
  21498. /** @hidden */
  21499. export var pbrDirectLightingFunctions: {
  21500. name: string;
  21501. shader: string;
  21502. };
  21503. }
  21504. declare module BABYLON {
  21505. /** @hidden */
  21506. export var pbrIBLFunctions: {
  21507. name: string;
  21508. shader: string;
  21509. };
  21510. }
  21511. declare module BABYLON {
  21512. /** @hidden */
  21513. export var pbrBlockAlbedoOpacity: {
  21514. name: string;
  21515. shader: string;
  21516. };
  21517. }
  21518. declare module BABYLON {
  21519. /** @hidden */
  21520. export var pbrBlockReflectivity: {
  21521. name: string;
  21522. shader: string;
  21523. };
  21524. }
  21525. declare module BABYLON {
  21526. /** @hidden */
  21527. export var pbrBlockAmbientOcclusion: {
  21528. name: string;
  21529. shader: string;
  21530. };
  21531. }
  21532. declare module BABYLON {
  21533. /** @hidden */
  21534. export var pbrBlockAlphaFresnel: {
  21535. name: string;
  21536. shader: string;
  21537. };
  21538. }
  21539. declare module BABYLON {
  21540. /** @hidden */
  21541. export var pbrBlockAnisotropic: {
  21542. name: string;
  21543. shader: string;
  21544. };
  21545. }
  21546. declare module BABYLON {
  21547. /** @hidden */
  21548. export var pbrBlockReflection: {
  21549. name: string;
  21550. shader: string;
  21551. };
  21552. }
  21553. declare module BABYLON {
  21554. /** @hidden */
  21555. export var pbrBlockSheen: {
  21556. name: string;
  21557. shader: string;
  21558. };
  21559. }
  21560. declare module BABYLON {
  21561. /** @hidden */
  21562. export var pbrBlockClearcoat: {
  21563. name: string;
  21564. shader: string;
  21565. };
  21566. }
  21567. declare module BABYLON {
  21568. /** @hidden */
  21569. export var pbrBlockSubSurface: {
  21570. name: string;
  21571. shader: string;
  21572. };
  21573. }
  21574. declare module BABYLON {
  21575. /** @hidden */
  21576. export var pbrBlockNormalGeometric: {
  21577. name: string;
  21578. shader: string;
  21579. };
  21580. }
  21581. declare module BABYLON {
  21582. /** @hidden */
  21583. export var pbrBlockNormalFinal: {
  21584. name: string;
  21585. shader: string;
  21586. };
  21587. }
  21588. declare module BABYLON {
  21589. /** @hidden */
  21590. export var pbrBlockLightmapInit: {
  21591. name: string;
  21592. shader: string;
  21593. };
  21594. }
  21595. declare module BABYLON {
  21596. /** @hidden */
  21597. export var pbrBlockGeometryInfo: {
  21598. name: string;
  21599. shader: string;
  21600. };
  21601. }
  21602. declare module BABYLON {
  21603. /** @hidden */
  21604. export var pbrBlockReflectance0: {
  21605. name: string;
  21606. shader: string;
  21607. };
  21608. }
  21609. declare module BABYLON {
  21610. /** @hidden */
  21611. export var pbrBlockReflectance: {
  21612. name: string;
  21613. shader: string;
  21614. };
  21615. }
  21616. declare module BABYLON {
  21617. /** @hidden */
  21618. export var pbrBlockDirectLighting: {
  21619. name: string;
  21620. shader: string;
  21621. };
  21622. }
  21623. declare module BABYLON {
  21624. /** @hidden */
  21625. export var pbrBlockFinalLitComponents: {
  21626. name: string;
  21627. shader: string;
  21628. };
  21629. }
  21630. declare module BABYLON {
  21631. /** @hidden */
  21632. export var pbrBlockFinalUnlitComponents: {
  21633. name: string;
  21634. shader: string;
  21635. };
  21636. }
  21637. declare module BABYLON {
  21638. /** @hidden */
  21639. export var pbrBlockFinalColorComposition: {
  21640. name: string;
  21641. shader: string;
  21642. };
  21643. }
  21644. declare module BABYLON {
  21645. /** @hidden */
  21646. export var pbrBlockImageProcessing: {
  21647. name: string;
  21648. shader: string;
  21649. };
  21650. }
  21651. declare module BABYLON {
  21652. /** @hidden */
  21653. export var pbrDebug: {
  21654. name: string;
  21655. shader: string;
  21656. };
  21657. }
  21658. declare module BABYLON {
  21659. /** @hidden */
  21660. export var pbrPixelShader: {
  21661. name: string;
  21662. shader: string;
  21663. };
  21664. }
  21665. declare module BABYLON {
  21666. /** @hidden */
  21667. export var pbrVertexDeclaration: {
  21668. name: string;
  21669. shader: string;
  21670. };
  21671. }
  21672. declare module BABYLON {
  21673. /** @hidden */
  21674. export var pbrVertexShader: {
  21675. name: string;
  21676. shader: string;
  21677. };
  21678. }
  21679. declare module BABYLON {
  21680. /**
  21681. * Manages the defines for the PBR Material.
  21682. * @hidden
  21683. */
  21684. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21685. PBR: boolean;
  21686. NUM_SAMPLES: string;
  21687. REALTIME_FILTERING: boolean;
  21688. MAINUV1: boolean;
  21689. MAINUV2: boolean;
  21690. UV1: boolean;
  21691. UV2: boolean;
  21692. ALBEDO: boolean;
  21693. GAMMAALBEDO: boolean;
  21694. ALBEDODIRECTUV: number;
  21695. VERTEXCOLOR: boolean;
  21696. DETAIL: boolean;
  21697. DETAILDIRECTUV: number;
  21698. DETAIL_NORMALBLENDMETHOD: number;
  21699. AMBIENT: boolean;
  21700. AMBIENTDIRECTUV: number;
  21701. AMBIENTINGRAYSCALE: boolean;
  21702. OPACITY: boolean;
  21703. VERTEXALPHA: boolean;
  21704. OPACITYDIRECTUV: number;
  21705. OPACITYRGB: boolean;
  21706. ALPHATEST: boolean;
  21707. DEPTHPREPASS: boolean;
  21708. ALPHABLEND: boolean;
  21709. ALPHAFROMALBEDO: boolean;
  21710. ALPHATESTVALUE: string;
  21711. SPECULAROVERALPHA: boolean;
  21712. RADIANCEOVERALPHA: boolean;
  21713. ALPHAFRESNEL: boolean;
  21714. LINEARALPHAFRESNEL: boolean;
  21715. PREMULTIPLYALPHA: boolean;
  21716. EMISSIVE: boolean;
  21717. EMISSIVEDIRECTUV: number;
  21718. REFLECTIVITY: boolean;
  21719. REFLECTIVITYDIRECTUV: number;
  21720. SPECULARTERM: boolean;
  21721. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21722. MICROSURFACEAUTOMATIC: boolean;
  21723. LODBASEDMICROSFURACE: boolean;
  21724. MICROSURFACEMAP: boolean;
  21725. MICROSURFACEMAPDIRECTUV: number;
  21726. METALLICWORKFLOW: boolean;
  21727. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21728. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21729. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21730. AOSTOREINMETALMAPRED: boolean;
  21731. METALLIC_REFLECTANCE: boolean;
  21732. METALLIC_REFLECTANCEDIRECTUV: number;
  21733. ENVIRONMENTBRDF: boolean;
  21734. ENVIRONMENTBRDF_RGBD: boolean;
  21735. NORMAL: boolean;
  21736. TANGENT: boolean;
  21737. BUMP: boolean;
  21738. BUMPDIRECTUV: number;
  21739. OBJECTSPACE_NORMALMAP: boolean;
  21740. PARALLAX: boolean;
  21741. PARALLAXOCCLUSION: boolean;
  21742. NORMALXYSCALE: boolean;
  21743. LIGHTMAP: boolean;
  21744. LIGHTMAPDIRECTUV: number;
  21745. USELIGHTMAPASSHADOWMAP: boolean;
  21746. GAMMALIGHTMAP: boolean;
  21747. RGBDLIGHTMAP: boolean;
  21748. REFLECTION: boolean;
  21749. REFLECTIONMAP_3D: boolean;
  21750. REFLECTIONMAP_SPHERICAL: boolean;
  21751. REFLECTIONMAP_PLANAR: boolean;
  21752. REFLECTIONMAP_CUBIC: boolean;
  21753. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21754. REFLECTIONMAP_PROJECTION: boolean;
  21755. REFLECTIONMAP_SKYBOX: boolean;
  21756. REFLECTIONMAP_EXPLICIT: boolean;
  21757. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21758. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21759. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21760. INVERTCUBICMAP: boolean;
  21761. USESPHERICALFROMREFLECTIONMAP: boolean;
  21762. USEIRRADIANCEMAP: boolean;
  21763. SPHERICAL_HARMONICS: boolean;
  21764. USESPHERICALINVERTEX: boolean;
  21765. REFLECTIONMAP_OPPOSITEZ: boolean;
  21766. LODINREFLECTIONALPHA: boolean;
  21767. GAMMAREFLECTION: boolean;
  21768. RGBDREFLECTION: boolean;
  21769. LINEARSPECULARREFLECTION: boolean;
  21770. RADIANCEOCCLUSION: boolean;
  21771. HORIZONOCCLUSION: boolean;
  21772. INSTANCES: boolean;
  21773. THIN_INSTANCES: boolean;
  21774. PREPASS: boolean;
  21775. PREPASS_IRRADIANCE: boolean;
  21776. PREPASS_IRRADIANCE_INDEX: number;
  21777. PREPASS_ALBEDO: boolean;
  21778. PREPASS_ALBEDO_INDEX: number;
  21779. PREPASS_DEPTH: boolean;
  21780. PREPASS_DEPTH_INDEX: number;
  21781. PREPASS_NORMAL: boolean;
  21782. PREPASS_NORMAL_INDEX: number;
  21783. PREPASS_POSITION: boolean;
  21784. PREPASS_POSITION_INDEX: number;
  21785. PREPASS_VELOCITY: boolean;
  21786. PREPASS_VELOCITY_INDEX: number;
  21787. PREPASS_REFLECTIVITY: boolean;
  21788. PREPASS_REFLECTIVITY_INDEX: number;
  21789. SCENE_MRT_COUNT: number;
  21790. NUM_BONE_INFLUENCERS: number;
  21791. BonesPerMesh: number;
  21792. BONETEXTURE: boolean;
  21793. BONES_VELOCITY_ENABLED: boolean;
  21794. NONUNIFORMSCALING: boolean;
  21795. MORPHTARGETS: boolean;
  21796. MORPHTARGETS_NORMAL: boolean;
  21797. MORPHTARGETS_TANGENT: boolean;
  21798. MORPHTARGETS_UV: boolean;
  21799. NUM_MORPH_INFLUENCERS: number;
  21800. IMAGEPROCESSING: boolean;
  21801. VIGNETTE: boolean;
  21802. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21803. VIGNETTEBLENDMODEOPAQUE: boolean;
  21804. TONEMAPPING: boolean;
  21805. TONEMAPPING_ACES: boolean;
  21806. CONTRAST: boolean;
  21807. COLORCURVES: boolean;
  21808. COLORGRADING: boolean;
  21809. COLORGRADING3D: boolean;
  21810. SAMPLER3DGREENDEPTH: boolean;
  21811. SAMPLER3DBGRMAP: boolean;
  21812. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21813. EXPOSURE: boolean;
  21814. MULTIVIEW: boolean;
  21815. USEPHYSICALLIGHTFALLOFF: boolean;
  21816. USEGLTFLIGHTFALLOFF: boolean;
  21817. TWOSIDEDLIGHTING: boolean;
  21818. SHADOWFLOAT: boolean;
  21819. CLIPPLANE: boolean;
  21820. CLIPPLANE2: boolean;
  21821. CLIPPLANE3: boolean;
  21822. CLIPPLANE4: boolean;
  21823. CLIPPLANE5: boolean;
  21824. CLIPPLANE6: boolean;
  21825. POINTSIZE: boolean;
  21826. FOG: boolean;
  21827. LOGARITHMICDEPTH: boolean;
  21828. FORCENORMALFORWARD: boolean;
  21829. SPECULARAA: boolean;
  21830. CLEARCOAT: boolean;
  21831. CLEARCOAT_DEFAULTIOR: boolean;
  21832. CLEARCOAT_TEXTURE: boolean;
  21833. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21834. CLEARCOAT_TEXTUREDIRECTUV: number;
  21835. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21836. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21837. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21838. CLEARCOAT_BUMP: boolean;
  21839. CLEARCOAT_BUMPDIRECTUV: number;
  21840. CLEARCOAT_REMAP_F0: boolean;
  21841. CLEARCOAT_TINT: boolean;
  21842. CLEARCOAT_TINT_TEXTURE: boolean;
  21843. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21844. ANISOTROPIC: boolean;
  21845. ANISOTROPIC_TEXTURE: boolean;
  21846. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21847. BRDF_V_HEIGHT_CORRELATED: boolean;
  21848. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21849. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21850. SHEEN: boolean;
  21851. SHEEN_TEXTURE: boolean;
  21852. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21853. SHEEN_TEXTUREDIRECTUV: number;
  21854. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21855. SHEEN_LINKWITHALBEDO: boolean;
  21856. SHEEN_ROUGHNESS: boolean;
  21857. SHEEN_ALBEDOSCALING: boolean;
  21858. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21859. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21860. SUBSURFACE: boolean;
  21861. SS_REFRACTION: boolean;
  21862. SS_TRANSLUCENCY: boolean;
  21863. SS_SCATTERING: boolean;
  21864. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21865. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21866. SS_REFRACTIONMAP_3D: boolean;
  21867. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21868. SS_LODINREFRACTIONALPHA: boolean;
  21869. SS_GAMMAREFRACTION: boolean;
  21870. SS_RGBDREFRACTION: boolean;
  21871. SS_LINEARSPECULARREFRACTION: boolean;
  21872. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21873. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21874. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21875. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21876. UNLIT: boolean;
  21877. DEBUGMODE: number;
  21878. /**
  21879. * Initializes the PBR Material defines.
  21880. */
  21881. constructor();
  21882. /**
  21883. * Resets the PBR Material defines.
  21884. */
  21885. reset(): void;
  21886. }
  21887. /**
  21888. * The Physically based material base class of BJS.
  21889. *
  21890. * This offers the main features of a standard PBR material.
  21891. * For more information, please refer to the documentation :
  21892. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21893. */
  21894. export abstract class PBRBaseMaterial extends PushMaterial {
  21895. /**
  21896. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21897. */
  21898. static readonly PBRMATERIAL_OPAQUE: number;
  21899. /**
  21900. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21901. */
  21902. static readonly PBRMATERIAL_ALPHATEST: number;
  21903. /**
  21904. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21905. */
  21906. static readonly PBRMATERIAL_ALPHABLEND: number;
  21907. /**
  21908. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21909. * They are also discarded below the alpha cutoff threshold to improve performances.
  21910. */
  21911. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21912. /**
  21913. * Defines the default value of how much AO map is occluding the analytical lights
  21914. * (point spot...).
  21915. */
  21916. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21917. /**
  21918. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21919. */
  21920. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21921. /**
  21922. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21923. * to enhance interoperability with other engines.
  21924. */
  21925. static readonly LIGHTFALLOFF_GLTF: number;
  21926. /**
  21927. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21928. * to enhance interoperability with other materials.
  21929. */
  21930. static readonly LIGHTFALLOFF_STANDARD: number;
  21931. /**
  21932. * Intensity of the direct lights e.g. the four lights available in your scene.
  21933. * This impacts both the direct diffuse and specular highlights.
  21934. */
  21935. protected _directIntensity: number;
  21936. /**
  21937. * Intensity of the emissive part of the material.
  21938. * This helps controlling the emissive effect without modifying the emissive color.
  21939. */
  21940. protected _emissiveIntensity: number;
  21941. /**
  21942. * Intensity of the environment e.g. how much the environment will light the object
  21943. * either through harmonics for rough material or through the reflection for shiny ones.
  21944. */
  21945. protected _environmentIntensity: number;
  21946. /**
  21947. * This is a special control allowing the reduction of the specular highlights coming from the
  21948. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21949. */
  21950. protected _specularIntensity: number;
  21951. /**
  21952. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21953. */
  21954. private _lightingInfos;
  21955. /**
  21956. * Debug Control allowing disabling the bump map on this material.
  21957. */
  21958. protected _disableBumpMap: boolean;
  21959. /**
  21960. * AKA Diffuse Texture in standard nomenclature.
  21961. */
  21962. protected _albedoTexture: Nullable<BaseTexture>;
  21963. /**
  21964. * AKA Occlusion Texture in other nomenclature.
  21965. */
  21966. protected _ambientTexture: Nullable<BaseTexture>;
  21967. /**
  21968. * AKA Occlusion Texture Intensity in other nomenclature.
  21969. */
  21970. protected _ambientTextureStrength: number;
  21971. /**
  21972. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21973. * 1 means it completely occludes it
  21974. * 0 mean it has no impact
  21975. */
  21976. protected _ambientTextureImpactOnAnalyticalLights: number;
  21977. /**
  21978. * Stores the alpha values in a texture.
  21979. */
  21980. protected _opacityTexture: Nullable<BaseTexture>;
  21981. /**
  21982. * Stores the reflection values in a texture.
  21983. */
  21984. protected _reflectionTexture: Nullable<BaseTexture>;
  21985. /**
  21986. * Stores the emissive values in a texture.
  21987. */
  21988. protected _emissiveTexture: Nullable<BaseTexture>;
  21989. /**
  21990. * AKA Specular texture in other nomenclature.
  21991. */
  21992. protected _reflectivityTexture: Nullable<BaseTexture>;
  21993. /**
  21994. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21995. */
  21996. protected _metallicTexture: Nullable<BaseTexture>;
  21997. /**
  21998. * Specifies the metallic scalar of the metallic/roughness workflow.
  21999. * Can also be used to scale the metalness values of the metallic texture.
  22000. */
  22001. protected _metallic: Nullable<number>;
  22002. /**
  22003. * Specifies the roughness scalar of the metallic/roughness workflow.
  22004. * Can also be used to scale the roughness values of the metallic texture.
  22005. */
  22006. protected _roughness: Nullable<number>;
  22007. /**
  22008. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22009. * By default the indexOfrefraction is used to compute F0;
  22010. *
  22011. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22012. *
  22013. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22014. * F90 = metallicReflectanceColor;
  22015. */
  22016. protected _metallicF0Factor: number;
  22017. /**
  22018. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22019. * By default the F90 is always 1;
  22020. *
  22021. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22022. *
  22023. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22024. * F90 = metallicReflectanceColor;
  22025. */
  22026. protected _metallicReflectanceColor: Color3;
  22027. /**
  22028. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22029. * This is multiply against the scalar values defined in the material.
  22030. */
  22031. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  22032. /**
  22033. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22034. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22035. */
  22036. protected _microSurfaceTexture: Nullable<BaseTexture>;
  22037. /**
  22038. * Stores surface normal data used to displace a mesh in a texture.
  22039. */
  22040. protected _bumpTexture: Nullable<BaseTexture>;
  22041. /**
  22042. * Stores the pre-calculated light information of a mesh in a texture.
  22043. */
  22044. protected _lightmapTexture: Nullable<BaseTexture>;
  22045. /**
  22046. * The color of a material in ambient lighting.
  22047. */
  22048. protected _ambientColor: Color3;
  22049. /**
  22050. * AKA Diffuse Color in other nomenclature.
  22051. */
  22052. protected _albedoColor: Color3;
  22053. /**
  22054. * AKA Specular Color in other nomenclature.
  22055. */
  22056. protected _reflectivityColor: Color3;
  22057. /**
  22058. * The color applied when light is reflected from a material.
  22059. */
  22060. protected _reflectionColor: Color3;
  22061. /**
  22062. * The color applied when light is emitted from a material.
  22063. */
  22064. protected _emissiveColor: Color3;
  22065. /**
  22066. * AKA Glossiness in other nomenclature.
  22067. */
  22068. protected _microSurface: number;
  22069. /**
  22070. * Specifies that the material will use the light map as a show map.
  22071. */
  22072. protected _useLightmapAsShadowmap: boolean;
  22073. /**
  22074. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22075. * makes the reflect vector face the model (under horizon).
  22076. */
  22077. protected _useHorizonOcclusion: boolean;
  22078. /**
  22079. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22080. * too much the area relying on ambient texture to define their ambient occlusion.
  22081. */
  22082. protected _useRadianceOcclusion: boolean;
  22083. /**
  22084. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22085. */
  22086. protected _useAlphaFromAlbedoTexture: boolean;
  22087. /**
  22088. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  22089. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22090. */
  22091. protected _useSpecularOverAlpha: boolean;
  22092. /**
  22093. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22094. */
  22095. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22096. /**
  22097. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22098. */
  22099. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22100. /**
  22101. * Specifies if the metallic texture contains the roughness information in its green channel.
  22102. */
  22103. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22104. /**
  22105. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22106. */
  22107. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22108. /**
  22109. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22110. */
  22111. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22112. /**
  22113. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22114. */
  22115. protected _useAmbientInGrayScale: boolean;
  22116. /**
  22117. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22118. * The material will try to infer what glossiness each pixel should be.
  22119. */
  22120. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22121. /**
  22122. * Defines the falloff type used in this material.
  22123. * It by default is Physical.
  22124. */
  22125. protected _lightFalloff: number;
  22126. /**
  22127. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22128. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22129. */
  22130. protected _useRadianceOverAlpha: boolean;
  22131. /**
  22132. * Allows using an object space normal map (instead of tangent space).
  22133. */
  22134. protected _useObjectSpaceNormalMap: boolean;
  22135. /**
  22136. * Allows using the bump map in parallax mode.
  22137. */
  22138. protected _useParallax: boolean;
  22139. /**
  22140. * Allows using the bump map in parallax occlusion mode.
  22141. */
  22142. protected _useParallaxOcclusion: boolean;
  22143. /**
  22144. * Controls the scale bias of the parallax mode.
  22145. */
  22146. protected _parallaxScaleBias: number;
  22147. /**
  22148. * If sets to true, disables all the lights affecting the material.
  22149. */
  22150. protected _disableLighting: boolean;
  22151. /**
  22152. * Number of Simultaneous lights allowed on the material.
  22153. */
  22154. protected _maxSimultaneousLights: number;
  22155. /**
  22156. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22157. */
  22158. protected _invertNormalMapX: boolean;
  22159. /**
  22160. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22161. */
  22162. protected _invertNormalMapY: boolean;
  22163. /**
  22164. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22165. */
  22166. protected _twoSidedLighting: boolean;
  22167. /**
  22168. * Defines the alpha limits in alpha test mode.
  22169. */
  22170. protected _alphaCutOff: number;
  22171. /**
  22172. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22173. */
  22174. protected _forceAlphaTest: boolean;
  22175. /**
  22176. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22177. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22178. */
  22179. protected _useAlphaFresnel: boolean;
  22180. /**
  22181. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22182. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22183. */
  22184. protected _useLinearAlphaFresnel: boolean;
  22185. /**
  22186. * Specifies the environment BRDF texture used to compute the scale and offset roughness values
  22187. * from cos theta and roughness:
  22188. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22189. */
  22190. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22191. /**
  22192. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22193. */
  22194. protected _forceIrradianceInFragment: boolean;
  22195. private _realTimeFiltering;
  22196. /**
  22197. * Enables realtime filtering on the texture.
  22198. */
  22199. get realTimeFiltering(): boolean;
  22200. set realTimeFiltering(b: boolean);
  22201. private _realTimeFilteringQuality;
  22202. /**
  22203. * Quality switch for realtime filtering
  22204. */
  22205. get realTimeFilteringQuality(): number;
  22206. set realTimeFilteringQuality(n: number);
  22207. /**
  22208. * Can this material render to several textures at once
  22209. */
  22210. get canRenderToMRT(): boolean;
  22211. /**
  22212. * Force normal to face away from face.
  22213. */
  22214. protected _forceNormalForward: boolean;
  22215. /**
  22216. * Enables specular anti aliasing in the PBR shader.
  22217. * It will both interacts on the Geometry for analytical and IBL lighting.
  22218. * It also prefilter the roughness map based on the bump values.
  22219. */
  22220. protected _enableSpecularAntiAliasing: boolean;
  22221. /**
  22222. * Default configuration related to image processing available in the PBR Material.
  22223. */
  22224. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22225. /**
  22226. * Keep track of the image processing observer to allow dispose and replace.
  22227. */
  22228. private _imageProcessingObserver;
  22229. /**
  22230. * Attaches a new image processing configuration to the PBR Material.
  22231. * @param configuration
  22232. */
  22233. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22234. /**
  22235. * Stores the available render targets.
  22236. */
  22237. private _renderTargets;
  22238. /**
  22239. * Sets the global ambient color for the material used in lighting calculations.
  22240. */
  22241. private _globalAmbientColor;
  22242. /**
  22243. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22244. */
  22245. private _useLogarithmicDepth;
  22246. /**
  22247. * If set to true, no lighting calculations will be applied.
  22248. */
  22249. private _unlit;
  22250. private _debugMode;
  22251. /**
  22252. * @hidden
  22253. * This is reserved for the inspector.
  22254. * Defines the material debug mode.
  22255. * It helps seeing only some components of the material while troubleshooting.
  22256. */
  22257. debugMode: number;
  22258. /**
  22259. * @hidden
  22260. * This is reserved for the inspector.
  22261. * Specify from where on screen the debug mode should start.
  22262. * The value goes from -1 (full screen) to 1 (not visible)
  22263. * It helps with side by side comparison against the final render
  22264. * This defaults to -1
  22265. */
  22266. private debugLimit;
  22267. /**
  22268. * @hidden
  22269. * This is reserved for the inspector.
  22270. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22271. * You can use the factor to better multiply the final value.
  22272. */
  22273. private debugFactor;
  22274. /**
  22275. * Defines the clear coat layer parameters for the material.
  22276. */
  22277. readonly clearCoat: PBRClearCoatConfiguration;
  22278. /**
  22279. * Defines the anisotropic parameters for the material.
  22280. */
  22281. readonly anisotropy: PBRAnisotropicConfiguration;
  22282. /**
  22283. * Defines the BRDF parameters for the material.
  22284. */
  22285. readonly brdf: PBRBRDFConfiguration;
  22286. /**
  22287. * Defines the Sheen parameters for the material.
  22288. */
  22289. readonly sheen: PBRSheenConfiguration;
  22290. /**
  22291. * Defines the SubSurface parameters for the material.
  22292. */
  22293. readonly subSurface: PBRSubSurfaceConfiguration;
  22294. /**
  22295. * Defines additional PrePass parameters for the material.
  22296. */
  22297. readonly prePassConfiguration: PrePassConfiguration;
  22298. /**
  22299. * Defines the detail map parameters for the material.
  22300. */
  22301. readonly detailMap: DetailMapConfiguration;
  22302. protected _rebuildInParallel: boolean;
  22303. /**
  22304. * Instantiates a new PBRMaterial instance.
  22305. *
  22306. * @param name The material name
  22307. * @param scene The scene the material will be use in.
  22308. */
  22309. constructor(name: string, scene: Scene);
  22310. /**
  22311. * Gets a boolean indicating that current material needs to register RTT
  22312. */
  22313. get hasRenderTargetTextures(): boolean;
  22314. /**
  22315. * Can this material render to prepass
  22316. */
  22317. get isPrePassCapable(): boolean;
  22318. /**
  22319. * Gets the name of the material class.
  22320. */
  22321. getClassName(): string;
  22322. /**
  22323. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22324. */
  22325. get useLogarithmicDepth(): boolean;
  22326. /**
  22327. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22328. */
  22329. set useLogarithmicDepth(value: boolean);
  22330. /**
  22331. * Returns true if alpha blending should be disabled.
  22332. */
  22333. protected get _disableAlphaBlending(): boolean;
  22334. /**
  22335. * Specifies whether or not this material should be rendered in alpha blend mode.
  22336. */
  22337. needAlphaBlending(): boolean;
  22338. /**
  22339. * Specifies whether or not this material should be rendered in alpha test mode.
  22340. */
  22341. needAlphaTesting(): boolean;
  22342. /**
  22343. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22344. */
  22345. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22346. /**
  22347. * Specifies whether or not there is a usable alpha channel for transparency.
  22348. */
  22349. protected _hasAlphaChannel(): boolean;
  22350. /**
  22351. * Gets the texture used for the alpha test.
  22352. */
  22353. getAlphaTestTexture(): Nullable<BaseTexture>;
  22354. /**
  22355. * Specifies that the submesh is ready to be used.
  22356. * @param mesh - BJS mesh.
  22357. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22358. * @param useInstances - Specifies that instances should be used.
  22359. * @returns - boolean indicating that the submesh is ready or not.
  22360. */
  22361. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22362. /**
  22363. * Specifies if the material uses metallic roughness workflow.
  22364. * @returns boolean specifying if the material uses metallic roughness workflow.
  22365. */
  22366. isMetallicWorkflow(): boolean;
  22367. private _prepareEffect;
  22368. private _prepareDefines;
  22369. /**
  22370. * Force shader compilation
  22371. */
  22372. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22373. /**
  22374. * Initializes the uniform buffer layout for the shader.
  22375. */
  22376. buildUniformLayout(): void;
  22377. /**
  22378. * Unbinds the material from the mesh
  22379. */
  22380. unbind(): void;
  22381. /**
  22382. * Binds the submesh data.
  22383. * @param world - The world matrix.
  22384. * @param mesh - The BJS mesh.
  22385. * @param subMesh - A submesh of the BJS mesh.
  22386. */
  22387. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22388. /**
  22389. * Returns the animatable textures.
  22390. * @returns - Array of animatable textures.
  22391. */
  22392. getAnimatables(): IAnimatable[];
  22393. /**
  22394. * Returns the texture used for reflections.
  22395. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22396. */
  22397. private _getReflectionTexture;
  22398. /**
  22399. * Returns an array of the actively used textures.
  22400. * @returns - Array of BaseTextures
  22401. */
  22402. getActiveTextures(): BaseTexture[];
  22403. /**
  22404. * Checks to see if a texture is used in the material.
  22405. * @param texture - Base texture to use.
  22406. * @returns - Boolean specifying if a texture is used in the material.
  22407. */
  22408. hasTexture(texture: BaseTexture): boolean;
  22409. /**
  22410. * Sets the required values to the prepass renderer.
  22411. * @param prePassRenderer defines the prepass renderer to setup
  22412. */
  22413. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22414. /**
  22415. * Disposes the resources of the material.
  22416. * @param forceDisposeEffect - Forces the disposal of effects.
  22417. * @param forceDisposeTextures - Forces the disposal of all textures.
  22418. */
  22419. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22420. }
  22421. }
  22422. declare module BABYLON {
  22423. /**
  22424. * The Physically based material of BJS.
  22425. *
  22426. * This offers the main features of a standard PBR material.
  22427. * For more information, please refer to the documentation :
  22428. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22429. */
  22430. export class PBRMaterial extends PBRBaseMaterial {
  22431. /**
  22432. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22433. */
  22434. static readonly PBRMATERIAL_OPAQUE: number;
  22435. /**
  22436. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22437. */
  22438. static readonly PBRMATERIAL_ALPHATEST: number;
  22439. /**
  22440. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22441. */
  22442. static readonly PBRMATERIAL_ALPHABLEND: number;
  22443. /**
  22444. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22445. * They are also discarded below the alpha cutoff threshold to improve performances.
  22446. */
  22447. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22448. /**
  22449. * Defines the default value of how much AO map is occluding the analytical lights
  22450. * (point spot...).
  22451. */
  22452. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22453. /**
  22454. * Intensity of the direct lights e.g. the four lights available in your scene.
  22455. * This impacts both the direct diffuse and specular highlights.
  22456. */
  22457. directIntensity: number;
  22458. /**
  22459. * Intensity of the emissive part of the material.
  22460. * This helps controlling the emissive effect without modifying the emissive color.
  22461. */
  22462. emissiveIntensity: number;
  22463. /**
  22464. * Intensity of the environment e.g. how much the environment will light the object
  22465. * either through harmonics for rough material or through the reflection for shiny ones.
  22466. */
  22467. environmentIntensity: number;
  22468. /**
  22469. * This is a special control allowing the reduction of the specular highlights coming from the
  22470. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22471. */
  22472. specularIntensity: number;
  22473. /**
  22474. * Debug Control allowing disabling the bump map on this material.
  22475. */
  22476. disableBumpMap: boolean;
  22477. /**
  22478. * AKA Diffuse Texture in standard nomenclature.
  22479. */
  22480. albedoTexture: BaseTexture;
  22481. /**
  22482. * AKA Occlusion Texture in other nomenclature.
  22483. */
  22484. ambientTexture: BaseTexture;
  22485. /**
  22486. * AKA Occlusion Texture Intensity in other nomenclature.
  22487. */
  22488. ambientTextureStrength: number;
  22489. /**
  22490. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22491. * 1 means it completely occludes it
  22492. * 0 mean it has no impact
  22493. */
  22494. ambientTextureImpactOnAnalyticalLights: number;
  22495. /**
  22496. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22497. */
  22498. opacityTexture: BaseTexture;
  22499. /**
  22500. * Stores the reflection values in a texture.
  22501. */
  22502. reflectionTexture: Nullable<BaseTexture>;
  22503. /**
  22504. * Stores the emissive values in a texture.
  22505. */
  22506. emissiveTexture: BaseTexture;
  22507. /**
  22508. * AKA Specular texture in other nomenclature.
  22509. */
  22510. reflectivityTexture: BaseTexture;
  22511. /**
  22512. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22513. */
  22514. metallicTexture: BaseTexture;
  22515. /**
  22516. * Specifies the metallic scalar of the metallic/roughness workflow.
  22517. * Can also be used to scale the metalness values of the metallic texture.
  22518. */
  22519. metallic: Nullable<number>;
  22520. /**
  22521. * Specifies the roughness scalar of the metallic/roughness workflow.
  22522. * Can also be used to scale the roughness values of the metallic texture.
  22523. */
  22524. roughness: Nullable<number>;
  22525. /**
  22526. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22527. * By default the indexOfrefraction is used to compute F0;
  22528. *
  22529. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22530. *
  22531. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22532. * F90 = metallicReflectanceColor;
  22533. */
  22534. metallicF0Factor: number;
  22535. /**
  22536. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22537. * By default the F90 is always 1;
  22538. *
  22539. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22540. *
  22541. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22542. * F90 = metallicReflectanceColor;
  22543. */
  22544. metallicReflectanceColor: Color3;
  22545. /**
  22546. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22547. * This is multiply against the scalar values defined in the material.
  22548. */
  22549. metallicReflectanceTexture: Nullable<BaseTexture>;
  22550. /**
  22551. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22552. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22553. */
  22554. microSurfaceTexture: BaseTexture;
  22555. /**
  22556. * Stores surface normal data used to displace a mesh in a texture.
  22557. */
  22558. bumpTexture: BaseTexture;
  22559. /**
  22560. * Stores the pre-calculated light information of a mesh in a texture.
  22561. */
  22562. lightmapTexture: BaseTexture;
  22563. /**
  22564. * Stores the refracted light information in a texture.
  22565. */
  22566. get refractionTexture(): Nullable<BaseTexture>;
  22567. set refractionTexture(value: Nullable<BaseTexture>);
  22568. /**
  22569. * The color of a material in ambient lighting.
  22570. */
  22571. ambientColor: Color3;
  22572. /**
  22573. * AKA Diffuse Color in other nomenclature.
  22574. */
  22575. albedoColor: Color3;
  22576. /**
  22577. * AKA Specular Color in other nomenclature.
  22578. */
  22579. reflectivityColor: Color3;
  22580. /**
  22581. * The color reflected from the material.
  22582. */
  22583. reflectionColor: Color3;
  22584. /**
  22585. * The color emitted from the material.
  22586. */
  22587. emissiveColor: Color3;
  22588. /**
  22589. * AKA Glossiness in other nomenclature.
  22590. */
  22591. microSurface: number;
  22592. /**
  22593. * Index of refraction of the material base layer.
  22594. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22595. *
  22596. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22597. *
  22598. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22599. */
  22600. get indexOfRefraction(): number;
  22601. set indexOfRefraction(value: number);
  22602. /**
  22603. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22604. */
  22605. get invertRefractionY(): boolean;
  22606. set invertRefractionY(value: boolean);
  22607. /**
  22608. * This parameters will make the material used its opacity to control how much it is refracting against not.
  22609. * Materials half opaque for instance using refraction could benefit from this control.
  22610. */
  22611. get linkRefractionWithTransparency(): boolean;
  22612. set linkRefractionWithTransparency(value: boolean);
  22613. /**
  22614. * If true, the light map contains occlusion information instead of lighting info.
  22615. */
  22616. useLightmapAsShadowmap: boolean;
  22617. /**
  22618. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22619. */
  22620. useAlphaFromAlbedoTexture: boolean;
  22621. /**
  22622. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22623. */
  22624. forceAlphaTest: boolean;
  22625. /**
  22626. * Defines the alpha limits in alpha test mode.
  22627. */
  22628. alphaCutOff: number;
  22629. /**
  22630. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  22631. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22632. */
  22633. useSpecularOverAlpha: boolean;
  22634. /**
  22635. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22636. */
  22637. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22638. /**
  22639. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22640. */
  22641. useRoughnessFromMetallicTextureAlpha: boolean;
  22642. /**
  22643. * Specifies if the metallic texture contains the roughness information in its green channel.
  22644. */
  22645. useRoughnessFromMetallicTextureGreen: boolean;
  22646. /**
  22647. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22648. */
  22649. useMetallnessFromMetallicTextureBlue: boolean;
  22650. /**
  22651. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22652. */
  22653. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22654. /**
  22655. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22656. */
  22657. useAmbientInGrayScale: boolean;
  22658. /**
  22659. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22660. * The material will try to infer what glossiness each pixel should be.
  22661. */
  22662. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22663. /**
  22664. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22665. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22666. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22667. */
  22668. get usePhysicalLightFalloff(): boolean;
  22669. /**
  22670. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22671. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22672. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22673. */
  22674. set usePhysicalLightFalloff(value: boolean);
  22675. /**
  22676. * In order to support the falloff compatibility with gltf, a special mode has been added
  22677. * to reproduce the gltf light falloff.
  22678. */
  22679. get useGLTFLightFalloff(): boolean;
  22680. /**
  22681. * In order to support the falloff compatibility with gltf, a special mode has been added
  22682. * to reproduce the gltf light falloff.
  22683. */
  22684. set useGLTFLightFalloff(value: boolean);
  22685. /**
  22686. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22687. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22688. */
  22689. useRadianceOverAlpha: boolean;
  22690. /**
  22691. * Allows using an object space normal map (instead of tangent space).
  22692. */
  22693. useObjectSpaceNormalMap: boolean;
  22694. /**
  22695. * Allows using the bump map in parallax mode.
  22696. */
  22697. useParallax: boolean;
  22698. /**
  22699. * Allows using the bump map in parallax occlusion mode.
  22700. */
  22701. useParallaxOcclusion: boolean;
  22702. /**
  22703. * Controls the scale bias of the parallax mode.
  22704. */
  22705. parallaxScaleBias: number;
  22706. /**
  22707. * If sets to true, disables all the lights affecting the material.
  22708. */
  22709. disableLighting: boolean;
  22710. /**
  22711. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22712. */
  22713. forceIrradianceInFragment: boolean;
  22714. /**
  22715. * Number of Simultaneous lights allowed on the material.
  22716. */
  22717. maxSimultaneousLights: number;
  22718. /**
  22719. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22720. */
  22721. invertNormalMapX: boolean;
  22722. /**
  22723. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22724. */
  22725. invertNormalMapY: boolean;
  22726. /**
  22727. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22728. */
  22729. twoSidedLighting: boolean;
  22730. /**
  22731. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22732. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22733. */
  22734. useAlphaFresnel: boolean;
  22735. /**
  22736. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22737. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22738. */
  22739. useLinearAlphaFresnel: boolean;
  22740. /**
  22741. * Let user defines the brdf lookup texture used for IBL.
  22742. * A default 8bit version is embedded but you could point at :
  22743. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22744. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22745. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22746. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22747. */
  22748. environmentBRDFTexture: Nullable<BaseTexture>;
  22749. /**
  22750. * Force normal to face away from face.
  22751. */
  22752. forceNormalForward: boolean;
  22753. /**
  22754. * Enables specular anti aliasing in the PBR shader.
  22755. * It will both interacts on the Geometry for analytical and IBL lighting.
  22756. * It also prefilter the roughness map based on the bump values.
  22757. */
  22758. enableSpecularAntiAliasing: boolean;
  22759. /**
  22760. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22761. * makes the reflect vector face the model (under horizon).
  22762. */
  22763. useHorizonOcclusion: boolean;
  22764. /**
  22765. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22766. * too much the area relying on ambient texture to define their ambient occlusion.
  22767. */
  22768. useRadianceOcclusion: boolean;
  22769. /**
  22770. * If set to true, no lighting calculations will be applied.
  22771. */
  22772. unlit: boolean;
  22773. /**
  22774. * Gets the image processing configuration used either in this material.
  22775. */
  22776. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22777. /**
  22778. * Sets the Default image processing configuration used either in the this material.
  22779. *
  22780. * If sets to null, the scene one is in use.
  22781. */
  22782. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22783. /**
  22784. * Gets whether the color curves effect is enabled.
  22785. */
  22786. get cameraColorCurvesEnabled(): boolean;
  22787. /**
  22788. * Sets whether the color curves effect is enabled.
  22789. */
  22790. set cameraColorCurvesEnabled(value: boolean);
  22791. /**
  22792. * Gets whether the color grading effect is enabled.
  22793. */
  22794. get cameraColorGradingEnabled(): boolean;
  22795. /**
  22796. * Gets whether the color grading effect is enabled.
  22797. */
  22798. set cameraColorGradingEnabled(value: boolean);
  22799. /**
  22800. * Gets whether tonemapping is enabled or not.
  22801. */
  22802. get cameraToneMappingEnabled(): boolean;
  22803. /**
  22804. * Sets whether tonemapping is enabled or not
  22805. */
  22806. set cameraToneMappingEnabled(value: boolean);
  22807. /**
  22808. * The camera exposure used on this material.
  22809. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22810. * This corresponds to a photographic exposure.
  22811. */
  22812. get cameraExposure(): number;
  22813. /**
  22814. * The camera exposure used on this material.
  22815. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22816. * This corresponds to a photographic exposure.
  22817. */
  22818. set cameraExposure(value: number);
  22819. /**
  22820. * Gets The camera contrast used on this material.
  22821. */
  22822. get cameraContrast(): number;
  22823. /**
  22824. * Sets The camera contrast used on this material.
  22825. */
  22826. set cameraContrast(value: number);
  22827. /**
  22828. * Gets the Color Grading 2D Lookup Texture.
  22829. */
  22830. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22831. /**
  22832. * Sets the Color Grading 2D Lookup Texture.
  22833. */
  22834. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22835. /**
  22836. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  22837. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22838. * 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;
  22839. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22840. */
  22841. get cameraColorCurves(): Nullable<ColorCurves>;
  22842. /**
  22843. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  22844. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22845. * 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;
  22846. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22847. */
  22848. set cameraColorCurves(value: Nullable<ColorCurves>);
  22849. /**
  22850. * Instantiates a new PBRMaterial instance.
  22851. *
  22852. * @param name The material name
  22853. * @param scene The scene the material will be use in.
  22854. */
  22855. constructor(name: string, scene: Scene);
  22856. /**
  22857. * Returns the name of this material class.
  22858. */
  22859. getClassName(): string;
  22860. /**
  22861. * Makes a duplicate of the current material.
  22862. * @param name - name to use for the new material.
  22863. */
  22864. clone(name: string): PBRMaterial;
  22865. /**
  22866. * Serializes this PBR Material.
  22867. * @returns - An object with the serialized material.
  22868. */
  22869. serialize(): any;
  22870. /**
  22871. * Parses a PBR Material from a serialized object.
  22872. * @param source - Serialized object.
  22873. * @param scene - BJS scene instance.
  22874. * @param rootUrl - url for the scene object
  22875. * @returns - PBRMaterial
  22876. */
  22877. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22878. }
  22879. }
  22880. declare module BABYLON {
  22881. /** @hidden */
  22882. export var mrtFragmentDeclaration: {
  22883. name: string;
  22884. shader: string;
  22885. };
  22886. }
  22887. declare module BABYLON {
  22888. /** @hidden */
  22889. export var geometryPixelShader: {
  22890. name: string;
  22891. shader: string;
  22892. };
  22893. }
  22894. declare module BABYLON {
  22895. /** @hidden */
  22896. export var instancesDeclaration: {
  22897. name: string;
  22898. shader: string;
  22899. };
  22900. }
  22901. declare module BABYLON {
  22902. /** @hidden */
  22903. export var geometryVertexDeclaration: {
  22904. name: string;
  22905. shader: string;
  22906. };
  22907. }
  22908. declare module BABYLON {
  22909. /** @hidden */
  22910. export var geometryUboDeclaration: {
  22911. name: string;
  22912. shader: string;
  22913. };
  22914. }
  22915. declare module BABYLON {
  22916. /** @hidden */
  22917. export var geometryVertexShader: {
  22918. name: string;
  22919. shader: string;
  22920. };
  22921. }
  22922. declare module BABYLON {
  22923. /** @hidden */
  22924. interface ISavedTransformationMatrix {
  22925. world: Matrix;
  22926. viewProjection: Matrix;
  22927. }
  22928. /**
  22929. * This renderer is helpful to fill one of the render target with a geometry buffer.
  22930. */
  22931. export class GeometryBufferRenderer {
  22932. /**
  22933. * Constant used to retrieve the depth texture index in the G-Buffer textures array
  22934. * using getIndex(GeometryBufferRenderer.DEPTH_TEXTURE_INDEX)
  22935. */
  22936. static readonly DEPTH_TEXTURE_TYPE: number;
  22937. /**
  22938. * Constant used to retrieve the normal texture index in the G-Buffer textures array
  22939. * using getIndex(GeometryBufferRenderer.NORMAL_TEXTURE_INDEX)
  22940. */
  22941. static readonly NORMAL_TEXTURE_TYPE: number;
  22942. /**
  22943. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22944. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22945. */
  22946. static readonly POSITION_TEXTURE_TYPE: number;
  22947. /**
  22948. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22949. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22950. */
  22951. static readonly VELOCITY_TEXTURE_TYPE: number;
  22952. /**
  22953. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22954. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22955. */
  22956. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22957. /**
  22958. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22959. * in order to compute objects velocities when enableVelocity is set to "true"
  22960. * @hidden
  22961. */
  22962. _previousTransformationMatrices: {
  22963. [index: number]: ISavedTransformationMatrix;
  22964. };
  22965. /**
  22966. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22967. * in order to compute objects velocities when enableVelocity is set to "true"
  22968. * @hidden
  22969. */
  22970. _previousBonesTransformationMatrices: {
  22971. [index: number]: Float32Array;
  22972. };
  22973. /**
  22974. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22975. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22976. */
  22977. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22978. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22979. renderTransparentMeshes: boolean;
  22980. private _scene;
  22981. private _resizeObserver;
  22982. private _multiRenderTarget;
  22983. private _ratio;
  22984. private _enablePosition;
  22985. private _enableVelocity;
  22986. private _enableReflectivity;
  22987. private _positionIndex;
  22988. private _velocityIndex;
  22989. private _reflectivityIndex;
  22990. private _depthIndex;
  22991. private _normalIndex;
  22992. private _linkedWithPrePass;
  22993. private _prePassRenderer;
  22994. private _attachments;
  22995. private _useUbo;
  22996. protected _effect: Effect;
  22997. protected _cachedDefines: string;
  22998. /**
  22999. * @hidden
  23000. * Sets up internal structures to share outputs with PrePassRenderer
  23001. * This method should only be called by the PrePassRenderer itself
  23002. */
  23003. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  23004. /**
  23005. * @hidden
  23006. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  23007. * This method should only be called by the PrePassRenderer itself
  23008. */
  23009. _unlinkPrePassRenderer(): void;
  23010. /**
  23011. * @hidden
  23012. * Resets the geometry buffer layout
  23013. */
  23014. _resetLayout(): void;
  23015. /**
  23016. * @hidden
  23017. * Replaces a texture in the geometry buffer renderer
  23018. * Useful when linking textures of the prepass renderer
  23019. */
  23020. _forceTextureType(geometryBufferType: number, index: number): void;
  23021. /**
  23022. * @hidden
  23023. * Sets texture attachments
  23024. * Useful when linking textures of the prepass renderer
  23025. */
  23026. _setAttachments(attachments: number[]): void;
  23027. /**
  23028. * @hidden
  23029. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  23030. * Useful when linking textures of the prepass renderer
  23031. */
  23032. _linkInternalTexture(internalTexture: InternalTexture): void;
  23033. /**
  23034. * Gets the render list (meshes to be rendered) used in the G buffer.
  23035. */
  23036. get renderList(): Nullable<AbstractMesh[]>;
  23037. /**
  23038. * Set the render list (meshes to be rendered) used in the G buffer.
  23039. */
  23040. set renderList(meshes: Nullable<AbstractMesh[]>);
  23041. /**
  23042. * Gets whether or not G buffer are supported by the running hardware.
  23043. * This requires draw buffer supports
  23044. */
  23045. get isSupported(): boolean;
  23046. /**
  23047. * Returns the index of the given texture type in the G-Buffer textures array
  23048. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  23049. * @returns the index of the given texture type in the G-Buffer textures array
  23050. */
  23051. getTextureIndex(textureType: number): number;
  23052. /**
  23053. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  23054. */
  23055. get enablePosition(): boolean;
  23056. /**
  23057. * Sets whether or not objects positions are enabled for the G buffer.
  23058. */
  23059. set enablePosition(enable: boolean);
  23060. /**
  23061. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  23062. */
  23063. get enableVelocity(): boolean;
  23064. /**
  23065. * Sets whether or not objects velocities are enabled for the G buffer.
  23066. */
  23067. set enableVelocity(enable: boolean);
  23068. /**
  23069. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  23070. */
  23071. get enableReflectivity(): boolean;
  23072. /**
  23073. * Sets whether or not objects roughness are enabled for the G buffer.
  23074. */
  23075. set enableReflectivity(enable: boolean);
  23076. /**
  23077. * Gets the scene associated with the buffer.
  23078. */
  23079. get scene(): Scene;
  23080. /**
  23081. * Gets the ratio used by the buffer during its creation.
  23082. * How big is the buffer related to the main canvas.
  23083. */
  23084. get ratio(): number;
  23085. /** @hidden */
  23086. static _SceneComponentInitialization: (scene: Scene) => void;
  23087. /**
  23088. * Creates a new G Buffer for the scene
  23089. * @param scene The scene the buffer belongs to
  23090. * @param ratio How big is the buffer related to the main canvas.
  23091. */
  23092. constructor(scene: Scene, ratio?: number);
  23093. /**
  23094. * Checks whether everything is ready to render a submesh to the G buffer.
  23095. * @param subMesh the submesh to check readiness for
  23096. * @param useInstances is the mesh drawn using instance or not
  23097. * @returns true if ready otherwise false
  23098. */
  23099. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23100. /**
  23101. * Gets the current underlying G Buffer.
  23102. * @returns the buffer
  23103. */
  23104. getGBuffer(): MultiRenderTarget;
  23105. /**
  23106. * Gets the number of samples used to render the buffer (anti aliasing).
  23107. */
  23108. get samples(): number;
  23109. /**
  23110. * Sets the number of samples used to render the buffer (anti aliasing).
  23111. */
  23112. set samples(value: number);
  23113. /**
  23114. * Disposes the renderer and frees up associated resources.
  23115. */
  23116. dispose(): void;
  23117. private _assignRenderTargetIndices;
  23118. protected _createRenderTargets(): void;
  23119. private _copyBonesTransformationMatrices;
  23120. }
  23121. }
  23122. declare module BABYLON {
  23123. /**
  23124. * Renders a pre pass of the scene
  23125. * This means every mesh in the scene will be rendered to a render target texture
  23126. * And then this texture will be composited to the rendering canvas with post processes
  23127. * It is necessary for effects like subsurface scattering or deferred shading
  23128. */
  23129. export class PrePassRenderer {
  23130. /** @hidden */
  23131. static _SceneComponentInitialization: (scene: Scene) => void;
  23132. /**
  23133. * To save performance, we can excluded skinned meshes from the prepass
  23134. */
  23135. excludedSkinnedMesh: AbstractMesh[];
  23136. /**
  23137. * Force material to be excluded from the prepass
  23138. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23139. * and you don't want a material to show in the effect.
  23140. */
  23141. excludedMaterials: Material[];
  23142. private _scene;
  23143. private _engine;
  23144. /**
  23145. * Number of textures in the multi render target texture where the scene is directly rendered
  23146. */
  23147. mrtCount: number;
  23148. private _mrtFormats;
  23149. private _mrtLayout;
  23150. private _textureIndices;
  23151. private _multiRenderAttachments;
  23152. private _defaultAttachments;
  23153. private _clearAttachments;
  23154. /**
  23155. * Returns the index of a texture in the multi render target texture array.
  23156. * @param type Texture type
  23157. * @return The index
  23158. */
  23159. getIndex(type: number): number;
  23160. /**
  23161. * How many samples are used for MSAA of the scene render target
  23162. */
  23163. get samples(): number;
  23164. set samples(n: number);
  23165. private static _textureFormats;
  23166. private _isDirty;
  23167. /**
  23168. * The render target where the scene is directly rendered
  23169. */
  23170. defaultRT: PrePassRenderTarget;
  23171. /**
  23172. * Configuration for prepass effects
  23173. */
  23174. private _effectConfigurations;
  23175. /**
  23176. * @return the prepass render target for the rendering pass.
  23177. * If we are currently rendering a render target, it returns the PrePassRenderTarget
  23178. * associated with that render target. Otherwise, it returns the scene default PrePassRenderTarget
  23179. */
  23180. getRenderTarget(): PrePassRenderTarget;
  23181. /**
  23182. * @hidden
  23183. * Managed by the scene component
  23184. * @param prePassRenderTarget
  23185. */
  23186. _setRenderTarget(prePassRenderTarget: Nullable<PrePassRenderTarget>): void;
  23187. /**
  23188. * Returns true if the currently rendered prePassRenderTarget is the one
  23189. * associated with the scene.
  23190. */
  23191. get currentRTisSceneRT(): boolean;
  23192. private _geometryBuffer;
  23193. /**
  23194. * Prevents the PrePassRenderer from using the GeometryBufferRenderer as a fallback
  23195. */
  23196. doNotUseGeometryRendererFallback: boolean;
  23197. private _refreshGeometryBufferRendererLink;
  23198. private _currentTarget;
  23199. /**
  23200. * All the render targets generated by prepass
  23201. */
  23202. renderTargets: PrePassRenderTarget[];
  23203. private readonly _clearColor;
  23204. private _enabled;
  23205. private _needsCompositionForThisPass;
  23206. private _postProcessesSourceForThisPass;
  23207. /**
  23208. * Indicates if the prepass is enabled
  23209. */
  23210. get enabled(): boolean;
  23211. /**
  23212. * Set to true to disable gamma transform in PrePass.
  23213. * Can be useful in case you already proceed to gamma transform on a material level
  23214. * and your post processes don't need to be in linear color space.
  23215. */
  23216. disableGammaTransform: boolean;
  23217. /**
  23218. * Instanciates a prepass renderer
  23219. * @param scene The scene
  23220. */
  23221. constructor(scene: Scene);
  23222. /**
  23223. * Creates a new PrePassRenderTarget
  23224. * This should be the only way to instanciate a `PrePassRenderTarget`
  23225. * @param name Name of the `PrePassRenderTarget`
  23226. * @param renderTargetTexture RenderTarget the `PrePassRenderTarget` will be attached to.
  23227. * Can be `null` if the created `PrePassRenderTarget` is attached to the scene (default framebuffer).
  23228. * @hidden
  23229. */
  23230. _createRenderTarget(name: string, renderTargetTexture: Nullable<RenderTargetTexture>): PrePassRenderTarget;
  23231. /**
  23232. * Indicates if rendering a prepass is supported
  23233. */
  23234. get isSupported(): boolean;
  23235. /**
  23236. * Sets the proper output textures to draw in the engine.
  23237. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23238. * @param subMesh Submesh on which the effect is applied
  23239. */
  23240. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23241. private _reinitializeAttachments;
  23242. private _resetLayout;
  23243. private _updateGeometryBufferLayout;
  23244. /**
  23245. * Restores attachments for single texture draw.
  23246. */
  23247. restoreAttachments(): void;
  23248. /**
  23249. * @hidden
  23250. */
  23251. _beforeDraw(camera?: Camera, faceIndex?: number, layer?: number): void;
  23252. private _prepareFrame;
  23253. private _renderPostProcesses;
  23254. /**
  23255. * @hidden
  23256. */
  23257. _afterDraw(faceIndex?: number, layer?: number): void;
  23258. /**
  23259. * Clears the current prepass render target (in the sense of settings pixels to the scene clear color value)
  23260. * @hidden
  23261. */
  23262. _clear(): void;
  23263. private _bindFrameBuffer;
  23264. private _setEnabled;
  23265. private _setRenderTargetEnabled;
  23266. /**
  23267. * Adds an effect configuration to the prepass render target.
  23268. * If an effect has already been added, it won't add it twice and will return the configuration
  23269. * already present.
  23270. * @param cfg the effect configuration
  23271. * @return the effect configuration now used by the prepass
  23272. */
  23273. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23274. private _enable;
  23275. private _disable;
  23276. private _getPostProcessesSource;
  23277. private _setupOutputForThisPass;
  23278. private _linkInternalTexture;
  23279. private _needsImageProcessing;
  23280. private _hasImageProcessing;
  23281. /**
  23282. * Internal, gets the first post proces.
  23283. * @returns the first post process to be run on this camera.
  23284. */
  23285. private _getFirstPostProcess;
  23286. /**
  23287. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23288. */
  23289. markAsDirty(): void;
  23290. /**
  23291. * Enables a texture on the MultiRenderTarget for prepass
  23292. */
  23293. private _enableTextures;
  23294. private _update;
  23295. private _markAllMaterialsAsPrePassDirty;
  23296. /**
  23297. * Disposes the prepass renderer.
  23298. */
  23299. dispose(): void;
  23300. }
  23301. }
  23302. declare module BABYLON {
  23303. /**
  23304. * Size options for a post process
  23305. */
  23306. export type PostProcessOptions = {
  23307. width: number;
  23308. height: number;
  23309. };
  23310. /**
  23311. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23312. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23313. */
  23314. export class PostProcess {
  23315. /**
  23316. * Gets or sets the unique id of the post process
  23317. */
  23318. uniqueId: number;
  23319. /** Name of the PostProcess. */
  23320. name: string;
  23321. /**
  23322. * Width of the texture to apply the post process on
  23323. */
  23324. width: number;
  23325. /**
  23326. * Height of the texture to apply the post process on
  23327. */
  23328. height: number;
  23329. /**
  23330. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23331. */
  23332. nodeMaterialSource: Nullable<NodeMaterial>;
  23333. /**
  23334. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23335. * @hidden
  23336. */
  23337. _outputTexture: Nullable<InternalTexture>;
  23338. /**
  23339. * Sampling mode used by the shader
  23340. * See https://doc.babylonjs.com/classes/3.1/texture
  23341. */
  23342. renderTargetSamplingMode: number;
  23343. /**
  23344. * Clear color to use when screen clearing
  23345. */
  23346. clearColor: Color4;
  23347. /**
  23348. * If the buffer needs to be cleared before applying the post process. (default: true)
  23349. * Should be set to false if shader will overwrite all previous pixels.
  23350. */
  23351. autoClear: boolean;
  23352. /**
  23353. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23354. */
  23355. alphaMode: number;
  23356. /**
  23357. * Sets the setAlphaBlendConstants of the babylon engine
  23358. */
  23359. alphaConstants: Color4;
  23360. /**
  23361. * Animations to be used for the post processing
  23362. */
  23363. animations: Animation[];
  23364. /**
  23365. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23366. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23367. */
  23368. enablePixelPerfectMode: boolean;
  23369. /**
  23370. * Force the postprocess to be applied without taking in account viewport
  23371. */
  23372. forceFullscreenViewport: boolean;
  23373. /**
  23374. * List of inspectable custom properties (used by the Inspector)
  23375. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23376. */
  23377. inspectableCustomProperties: IInspectable[];
  23378. /**
  23379. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23380. *
  23381. * | Value | Type | Description |
  23382. * | ----- | ----------------------------------- | ----------- |
  23383. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23384. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23385. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23386. *
  23387. */
  23388. scaleMode: number;
  23389. /**
  23390. * Force textures to be a power of two (default: false)
  23391. */
  23392. alwaysForcePOT: boolean;
  23393. private _samples;
  23394. /**
  23395. * Number of sample textures (default: 1)
  23396. */
  23397. get samples(): number;
  23398. set samples(n: number);
  23399. /**
  23400. * Modify the scale of the post process to be the same as the viewport (default: false)
  23401. */
  23402. adaptScaleToCurrentViewport: boolean;
  23403. private _camera;
  23404. protected _scene: Scene;
  23405. private _engine;
  23406. private _options;
  23407. private _reusable;
  23408. private _renderId;
  23409. private _textureType;
  23410. private _textureFormat;
  23411. /**
  23412. * Smart array of input and output textures for the post process.
  23413. * @hidden
  23414. */
  23415. _textures: SmartArray<InternalTexture>;
  23416. /**
  23417. * Smart array of input and output textures for the post process.
  23418. * @hidden
  23419. */
  23420. private _textureCache;
  23421. /**
  23422. * The index in _textures that corresponds to the output texture.
  23423. * @hidden
  23424. */
  23425. _currentRenderTextureInd: number;
  23426. private _effect;
  23427. private _samplers;
  23428. private _fragmentUrl;
  23429. private _vertexUrl;
  23430. private _parameters;
  23431. protected _postProcessDefines: Nullable<string>;
  23432. private _scaleRatio;
  23433. protected _indexParameters: any;
  23434. private _shareOutputWithPostProcess;
  23435. private _texelSize;
  23436. /** @hidden */
  23437. _forcedOutputTexture: Nullable<InternalTexture>;
  23438. /**
  23439. * Prepass configuration in case this post process needs a texture from prepass
  23440. * @hidden
  23441. */
  23442. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23443. /**
  23444. * Returns the fragment url or shader name used in the post process.
  23445. * @returns the fragment url or name in the shader store.
  23446. */
  23447. getEffectName(): string;
  23448. /**
  23449. * An event triggered when the postprocess is activated.
  23450. */
  23451. onActivateObservable: Observable<Camera>;
  23452. private _onActivateObserver;
  23453. /**
  23454. * A function that is added to the onActivateObservable
  23455. */
  23456. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23457. /**
  23458. * An event triggered when the postprocess changes its size.
  23459. */
  23460. onSizeChangedObservable: Observable<PostProcess>;
  23461. private _onSizeChangedObserver;
  23462. /**
  23463. * A function that is added to the onSizeChangedObservable
  23464. */
  23465. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23466. /**
  23467. * An event triggered when the postprocess applies its effect.
  23468. */
  23469. onApplyObservable: Observable<Effect>;
  23470. private _onApplyObserver;
  23471. /**
  23472. * A function that is added to the onApplyObservable
  23473. */
  23474. set onApply(callback: (effect: Effect) => void);
  23475. /**
  23476. * An event triggered before rendering the postprocess
  23477. */
  23478. onBeforeRenderObservable: Observable<Effect>;
  23479. private _onBeforeRenderObserver;
  23480. /**
  23481. * A function that is added to the onBeforeRenderObservable
  23482. */
  23483. set onBeforeRender(callback: (effect: Effect) => void);
  23484. /**
  23485. * An event triggered after rendering the postprocess
  23486. */
  23487. onAfterRenderObservable: Observable<Effect>;
  23488. private _onAfterRenderObserver;
  23489. /**
  23490. * A function that is added to the onAfterRenderObservable
  23491. */
  23492. set onAfterRender(callback: (efect: Effect) => void);
  23493. /**
  23494. * 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
  23495. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23496. */
  23497. get inputTexture(): InternalTexture;
  23498. set inputTexture(value: InternalTexture);
  23499. /**
  23500. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23501. * the only way to unset it is to use this function to restore its internal state
  23502. */
  23503. restoreDefaultInputTexture(): void;
  23504. /**
  23505. * Gets the camera which post process is applied to.
  23506. * @returns The camera the post process is applied to.
  23507. */
  23508. getCamera(): Camera;
  23509. /**
  23510. * Gets the texel size of the postprocess.
  23511. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23512. */
  23513. get texelSize(): Vector2;
  23514. /**
  23515. * Creates a new instance PostProcess
  23516. * @param name The name of the PostProcess.
  23517. * @param fragmentUrl The url of the fragment shader to be used.
  23518. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23519. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23520. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23521. * @param camera The camera to apply the render pass to.
  23522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23523. * @param engine The engine which the post process will be applied. (default: current engine)
  23524. * @param reusable If the post process can be reused on the same frame. (default: false)
  23525. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23526. * @param textureType Type of textures used when performing the post process. (default: 0)
  23527. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23528. * @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
  23529. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23530. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23531. */
  23532. constructor(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, textureFormat?: number);
  23533. /**
  23534. * Gets a string identifying the name of the class
  23535. * @returns "PostProcess" string
  23536. */
  23537. getClassName(): string;
  23538. /**
  23539. * Gets the engine which this post process belongs to.
  23540. * @returns The engine the post process was enabled with.
  23541. */
  23542. getEngine(): Engine;
  23543. /**
  23544. * The effect that is created when initializing the post process.
  23545. * @returns The created effect corresponding the the postprocess.
  23546. */
  23547. getEffect(): Effect;
  23548. /**
  23549. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23550. * @param postProcess The post process to share the output with.
  23551. * @returns This post process.
  23552. */
  23553. shareOutputWith(postProcess: PostProcess): PostProcess;
  23554. /**
  23555. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23556. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23557. */
  23558. useOwnOutput(): void;
  23559. /**
  23560. * Updates the effect with the current post process compile time values and recompiles the shader.
  23561. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23562. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23563. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23564. * @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
  23565. * @param onCompiled Called when the shader has been compiled.
  23566. * @param onError Called if there is an error when compiling a shader.
  23567. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23568. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23569. */
  23570. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  23571. /**
  23572. * The post process is reusable if it can be used multiple times within one frame.
  23573. * @returns If the post process is reusable
  23574. */
  23575. isReusable(): boolean;
  23576. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23577. markTextureDirty(): void;
  23578. private _createRenderTargetTexture;
  23579. private _flushTextureCache;
  23580. private _resize;
  23581. /**
  23582. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23583. * 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.
  23584. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23585. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23586. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23587. * @returns The target texture that was bound to be written to.
  23588. */
  23589. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23590. /**
  23591. * If the post process is supported.
  23592. */
  23593. get isSupported(): boolean;
  23594. /**
  23595. * The aspect ratio of the output texture.
  23596. */
  23597. get aspectRatio(): number;
  23598. /**
  23599. * Get a value indicating if the post-process is ready to be used
  23600. * @returns true if the post-process is ready (shader is compiled)
  23601. */
  23602. isReady(): boolean;
  23603. /**
  23604. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23605. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23606. */
  23607. apply(): Nullable<Effect>;
  23608. private _disposeTextures;
  23609. private _disposeTextureCache;
  23610. /**
  23611. * Sets the required values to the prepass renderer.
  23612. * @param prePassRenderer defines the prepass renderer to setup.
  23613. * @returns true if the pre pass is needed.
  23614. */
  23615. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23616. /**
  23617. * Disposes the post process.
  23618. * @param camera The camera to dispose the post process on.
  23619. */
  23620. dispose(camera?: Camera): void;
  23621. /**
  23622. * Serializes the particle system to a JSON object
  23623. * @returns the JSON object
  23624. */
  23625. serialize(): any;
  23626. /**
  23627. * Clones this post process
  23628. * @returns a new post process similar to this one
  23629. */
  23630. clone(): Nullable<PostProcess>;
  23631. /**
  23632. * Creates a material from parsed material data
  23633. * @param parsedPostProcess defines parsed post process data
  23634. * @param scene defines the hosting scene
  23635. * @param rootUrl defines the root URL to use to load textures
  23636. * @returns a new post process
  23637. */
  23638. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23639. /** @hidden */
  23640. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23641. }
  23642. }
  23643. declare module BABYLON {
  23644. /** @hidden */
  23645. export var kernelBlurVaryingDeclaration: {
  23646. name: string;
  23647. shader: string;
  23648. };
  23649. }
  23650. declare module BABYLON {
  23651. /** @hidden */
  23652. export var packingFunctions: {
  23653. name: string;
  23654. shader: string;
  23655. };
  23656. }
  23657. declare module BABYLON {
  23658. /** @hidden */
  23659. export var kernelBlurFragment: {
  23660. name: string;
  23661. shader: string;
  23662. };
  23663. }
  23664. declare module BABYLON {
  23665. /** @hidden */
  23666. export var kernelBlurFragment2: {
  23667. name: string;
  23668. shader: string;
  23669. };
  23670. }
  23671. declare module BABYLON {
  23672. /** @hidden */
  23673. export var kernelBlurPixelShader: {
  23674. name: string;
  23675. shader: string;
  23676. };
  23677. }
  23678. declare module BABYLON {
  23679. /** @hidden */
  23680. export var kernelBlurVertex: {
  23681. name: string;
  23682. shader: string;
  23683. };
  23684. }
  23685. declare module BABYLON {
  23686. /** @hidden */
  23687. export var kernelBlurVertexShader: {
  23688. name: string;
  23689. shader: string;
  23690. };
  23691. }
  23692. declare module BABYLON {
  23693. /**
  23694. * The Blur Post Process which blurs an image based on a kernel and direction.
  23695. * Can be used twice in x and y directions to perform a gaussian blur in two passes.
  23696. */
  23697. export class BlurPostProcess extends PostProcess {
  23698. private blockCompilation;
  23699. protected _kernel: number;
  23700. protected _idealKernel: number;
  23701. protected _packedFloat: boolean;
  23702. private _staticDefines;
  23703. /** The direction in which to blur the image. */
  23704. direction: Vector2;
  23705. /**
  23706. * Sets the length in pixels of the blur sample region
  23707. */
  23708. set kernel(v: number);
  23709. /**
  23710. * Gets the length in pixels of the blur sample region
  23711. */
  23712. get kernel(): number;
  23713. /**
  23714. * Sets whether or not the blur needs to unpack/repack floats
  23715. */
  23716. set packedFloat(v: boolean);
  23717. /**
  23718. * Gets whether or not the blur is unpacking/repacking floats
  23719. */
  23720. get packedFloat(): boolean;
  23721. /**
  23722. * Gets a string identifying the name of the class
  23723. * @returns "BlurPostProcess" string
  23724. */
  23725. getClassName(): string;
  23726. /**
  23727. * Creates a new instance BlurPostProcess
  23728. * @param name The name of the effect.
  23729. * @param direction The direction in which to blur the image.
  23730. * @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.
  23731. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23732. * @param camera The camera to apply the render pass to.
  23733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23734. * @param engine The engine which the post process will be applied. (default: current engine)
  23735. * @param reusable If the post process can be reused on the same frame. (default: false)
  23736. * @param textureType Type of textures used when performing the post process. (default: 0)
  23737. * @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)
  23738. */
  23739. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23740. /**
  23741. * Updates the effect with the current post process compile time values and recompiles the shader.
  23742. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23743. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23744. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23745. * @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
  23746. * @param onCompiled Called when the shader has been compiled.
  23747. * @param onError Called if there is an error when compiling a shader.
  23748. */
  23749. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23750. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23751. /**
  23752. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23753. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23754. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23755. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23756. * The gaps between physical kernels are compensated for in the weighting of the samples
  23757. * @param idealKernel Ideal blur kernel.
  23758. * @return Nearest best kernel.
  23759. */
  23760. protected _nearestBestKernel(idealKernel: number): number;
  23761. /**
  23762. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23763. * @param x The point on the Gaussian distribution to sample.
  23764. * @return the value of the Gaussian function at x.
  23765. */
  23766. protected _gaussianWeight(x: number): number;
  23767. /**
  23768. * Generates a string that can be used as a floating point number in GLSL.
  23769. * @param x Value to print.
  23770. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23771. * @return GLSL float string.
  23772. */
  23773. protected _glslFloat(x: number, decimalFigures?: number): string;
  23774. /** @hidden */
  23775. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23776. }
  23777. }
  23778. declare module BABYLON {
  23779. /**
  23780. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23781. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23782. * You can then easily use it as a reflectionTexture on a flat surface.
  23783. * In case the surface is not a plane, please consider relying on reflection probes.
  23784. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23785. */
  23786. export class MirrorTexture extends RenderTargetTexture {
  23787. private scene;
  23788. /**
  23789. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23790. * It is possible to directly set the mirrorPlane by directly using a 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.
  23791. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23792. */
  23793. mirrorPlane: Plane;
  23794. /**
  23795. * Define the blur ratio used to blur the reflection if needed.
  23796. */
  23797. set blurRatio(value: number);
  23798. get blurRatio(): number;
  23799. /**
  23800. * Define the adaptive blur kernel used to blur the reflection if needed.
  23801. * This will autocompute the closest best match for the `blurKernel`
  23802. */
  23803. set adaptiveBlurKernel(value: number);
  23804. /**
  23805. * Define the blur kernel used to blur the reflection if needed.
  23806. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23807. */
  23808. set blurKernel(value: number);
  23809. /**
  23810. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23811. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23812. */
  23813. set blurKernelX(value: number);
  23814. get blurKernelX(): number;
  23815. /**
  23816. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23817. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23818. */
  23819. set blurKernelY(value: number);
  23820. get blurKernelY(): number;
  23821. private _autoComputeBlurKernel;
  23822. protected _onRatioRescale(): void;
  23823. private _updateGammaSpace;
  23824. private _imageProcessingConfigChangeObserver;
  23825. private _transformMatrix;
  23826. private _mirrorMatrix;
  23827. private _blurX;
  23828. private _blurY;
  23829. private _adaptiveBlurKernel;
  23830. private _blurKernelX;
  23831. private _blurKernelY;
  23832. private _blurRatio;
  23833. /**
  23834. * Instantiates a Mirror Texture.
  23835. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23836. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23837. * You can then easily use it as a reflectionTexture on a flat surface.
  23838. * In case the surface is not a plane, please consider relying on reflection probes.
  23839. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23840. * @param name
  23841. * @param size
  23842. * @param scene
  23843. * @param generateMipMaps
  23844. * @param type
  23845. * @param samplingMode
  23846. * @param generateDepthBuffer
  23847. */
  23848. constructor(name: string, size: number | {
  23849. width: number;
  23850. height: number;
  23851. } | {
  23852. ratio: number;
  23853. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23854. private _preparePostProcesses;
  23855. /**
  23856. * Clone the mirror texture.
  23857. * @returns the cloned texture
  23858. */
  23859. clone(): MirrorTexture;
  23860. /**
  23861. * Serialize the texture to a JSON representation you could use in Parse later on
  23862. * @returns the serialized JSON representation
  23863. */
  23864. serialize(): any;
  23865. /**
  23866. * Dispose the texture and release its associated resources.
  23867. */
  23868. dispose(): void;
  23869. }
  23870. }
  23871. declare module BABYLON {
  23872. /**
  23873. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23874. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23875. */
  23876. export class Texture extends BaseTexture {
  23877. /**
  23878. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23879. */
  23880. static SerializeBuffers: boolean;
  23881. /**
  23882. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23883. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23884. */
  23885. static ForceSerializeBuffers: boolean;
  23886. /** @hidden */
  23887. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23888. /** @hidden */
  23889. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23890. /** @hidden */
  23891. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23892. /** nearest is mag = nearest and min = nearest and mip = linear */
  23893. static readonly NEAREST_SAMPLINGMODE: number;
  23894. /** nearest is mag = nearest and min = nearest and mip = linear */
  23895. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23896. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23897. static readonly BILINEAR_SAMPLINGMODE: number;
  23898. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23899. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23900. /** Trilinear is mag = linear and min = linear and mip = linear */
  23901. static readonly TRILINEAR_SAMPLINGMODE: number;
  23902. /** Trilinear is mag = linear and min = linear and mip = linear */
  23903. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23904. /** mag = nearest and min = nearest and mip = nearest */
  23905. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23906. /** mag = nearest and min = linear and mip = nearest */
  23907. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23908. /** mag = nearest and min = linear and mip = linear */
  23909. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23910. /** mag = nearest and min = linear and mip = none */
  23911. static readonly NEAREST_LINEAR: number;
  23912. /** mag = nearest and min = nearest and mip = none */
  23913. static readonly NEAREST_NEAREST: number;
  23914. /** mag = linear and min = nearest and mip = nearest */
  23915. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23916. /** mag = linear and min = nearest and mip = linear */
  23917. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23918. /** mag = linear and min = linear and mip = none */
  23919. static readonly LINEAR_LINEAR: number;
  23920. /** mag = linear and min = nearest and mip = none */
  23921. static readonly LINEAR_NEAREST: number;
  23922. /** Explicit coordinates mode */
  23923. static readonly EXPLICIT_MODE: number;
  23924. /** Spherical coordinates mode */
  23925. static readonly SPHERICAL_MODE: number;
  23926. /** Planar coordinates mode */
  23927. static readonly PLANAR_MODE: number;
  23928. /** Cubic coordinates mode */
  23929. static readonly CUBIC_MODE: number;
  23930. /** Projection coordinates mode */
  23931. static readonly PROJECTION_MODE: number;
  23932. /** Inverse Cubic coordinates mode */
  23933. static readonly SKYBOX_MODE: number;
  23934. /** Inverse Cubic coordinates mode */
  23935. static readonly INVCUBIC_MODE: number;
  23936. /** Equirectangular coordinates mode */
  23937. static readonly EQUIRECTANGULAR_MODE: number;
  23938. /** Equirectangular Fixed coordinates mode */
  23939. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23940. /** Equirectangular Fixed Mirrored coordinates mode */
  23941. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23942. /** Texture is not repeating outside of 0..1 UVs */
  23943. static readonly CLAMP_ADDRESSMODE: number;
  23944. /** Texture is repeating outside of 0..1 UVs */
  23945. static readonly WRAP_ADDRESSMODE: number;
  23946. /** Texture is repeating and mirrored */
  23947. static readonly MIRROR_ADDRESSMODE: number;
  23948. /**
  23949. * 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
  23950. */
  23951. static UseSerializedUrlIfAny: boolean;
  23952. /**
  23953. * Define the url of the texture.
  23954. */
  23955. url: Nullable<string>;
  23956. /**
  23957. * Define an offset on the texture to offset the u coordinates of the UVs
  23958. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23959. */
  23960. uOffset: number;
  23961. /**
  23962. * Define an offset on the texture to offset the v coordinates of the UVs
  23963. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23964. */
  23965. vOffset: number;
  23966. /**
  23967. * Define an offset on the texture to scale the u coordinates of the UVs
  23968. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23969. */
  23970. uScale: number;
  23971. /**
  23972. * Define an offset on the texture to scale the v coordinates of the UVs
  23973. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23974. */
  23975. vScale: number;
  23976. /**
  23977. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23978. * @see https://doc.babylonjs.com/how_to/more_materials
  23979. */
  23980. uAng: number;
  23981. /**
  23982. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23983. * @see https://doc.babylonjs.com/how_to/more_materials
  23984. */
  23985. vAng: number;
  23986. /**
  23987. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23988. * @see https://doc.babylonjs.com/how_to/more_materials
  23989. */
  23990. wAng: number;
  23991. /**
  23992. * Defines the center of rotation (U)
  23993. */
  23994. uRotationCenter: number;
  23995. /**
  23996. * Defines the center of rotation (V)
  23997. */
  23998. vRotationCenter: number;
  23999. /**
  24000. * Defines the center of rotation (W)
  24001. */
  24002. wRotationCenter: number;
  24003. /**
  24004. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  24005. */
  24006. homogeneousRotationInUVTransform: boolean;
  24007. /**
  24008. * Are mip maps generated for this texture or not.
  24009. */
  24010. get noMipmap(): boolean;
  24011. /**
  24012. * List of inspectable custom properties (used by the Inspector)
  24013. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24014. */
  24015. inspectableCustomProperties: Nullable<IInspectable[]>;
  24016. private _noMipmap;
  24017. /** @hidden */
  24018. _invertY: boolean;
  24019. private _rowGenerationMatrix;
  24020. private _cachedTextureMatrix;
  24021. private _projectionModeMatrix;
  24022. private _t0;
  24023. private _t1;
  24024. private _t2;
  24025. private _cachedUOffset;
  24026. private _cachedVOffset;
  24027. private _cachedUScale;
  24028. private _cachedVScale;
  24029. private _cachedUAng;
  24030. private _cachedVAng;
  24031. private _cachedWAng;
  24032. private _cachedProjectionMatrixId;
  24033. private _cachedURotationCenter;
  24034. private _cachedVRotationCenter;
  24035. private _cachedWRotationCenter;
  24036. private _cachedHomogeneousRotationInUVTransform;
  24037. private _cachedCoordinatesMode;
  24038. /** @hidden */
  24039. protected _initialSamplingMode: number;
  24040. /** @hidden */
  24041. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24042. private _deleteBuffer;
  24043. protected _format: Nullable<number>;
  24044. private _delayedOnLoad;
  24045. private _delayedOnError;
  24046. private _mimeType?;
  24047. private _loaderOptions?;
  24048. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24049. get mimeType(): string | undefined;
  24050. /**
  24051. * Observable triggered once the texture has been loaded.
  24052. */
  24053. onLoadObservable: Observable<Texture>;
  24054. protected _isBlocking: boolean;
  24055. /**
  24056. * Is the texture preventing material to render while loading.
  24057. * If false, a default texture will be used instead of the loading one during the preparation step.
  24058. */
  24059. set isBlocking(value: boolean);
  24060. get isBlocking(): boolean;
  24061. /**
  24062. * Get the current sampling mode associated with the texture.
  24063. */
  24064. get samplingMode(): number;
  24065. /**
  24066. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24067. */
  24068. get invertY(): boolean;
  24069. /**
  24070. * Instantiates a new texture.
  24071. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24072. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24073. * @param url defines the url of the picture to load as a texture
  24074. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24075. * @param noMipmap defines if the texture will require mip maps or not
  24076. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24077. * @param samplingMode defines the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24078. * @param onLoad defines a callback triggered when the texture has been loaded
  24079. * @param onError defines a callback triggered when an error occurred during the loading session
  24080. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24081. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24082. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24083. * @param mimeType defines an optional mime type information
  24084. * @param loaderOptions options to be passed to the loader
  24085. */
  24086. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  24087. /**
  24088. * Update the url (and optional buffer) of this texture if url was null during construction.
  24089. * @param url the url of the texture
  24090. * @param buffer the buffer of the texture (defaults to null)
  24091. * @param onLoad callback called when the texture is loaded (defaults to null)
  24092. */
  24093. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24094. /**
  24095. * Finish the loading sequence of a texture flagged as delayed load.
  24096. * @hidden
  24097. */
  24098. delayLoad(): void;
  24099. private _prepareRowForTextureGeneration;
  24100. /**
  24101. * Checks if the texture has the same transform matrix than another texture
  24102. * @param texture texture to check against
  24103. * @returns true if the transforms are the same, else false
  24104. */
  24105. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  24106. /**
  24107. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24108. * @returns the transform matrix of the texture.
  24109. */
  24110. getTextureMatrix(uBase?: number): Matrix;
  24111. /**
  24112. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24113. * @returns The reflection texture transform
  24114. */
  24115. getReflectionTextureMatrix(): Matrix;
  24116. /**
  24117. * Clones the texture.
  24118. * @returns the cloned texture
  24119. */
  24120. clone(): Texture;
  24121. /**
  24122. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  24123. * @returns The JSON representation of the texture
  24124. */
  24125. serialize(): any;
  24126. /**
  24127. * Get the current class name of the texture useful for serialization or dynamic coding.
  24128. * @returns "Texture"
  24129. */
  24130. getClassName(): string;
  24131. /**
  24132. * Dispose the texture and release its associated resources.
  24133. */
  24134. dispose(): void;
  24135. /**
  24136. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24137. * @param parsedTexture Define the JSON representation of the texture
  24138. * @param scene Define the scene the parsed texture should be instantiated in
  24139. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24140. * @returns The parsed texture if successful
  24141. */
  24142. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24143. /**
  24144. * Creates a texture from its base 64 representation.
  24145. * @param data Define the base64 payload without the data: prefix
  24146. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24147. * @param scene Define the scene the texture should belong to
  24148. * @param noMipmap Forces the texture to not create mip map information if true
  24149. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24150. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24151. * @param onLoad define a callback triggered when the texture has been loaded
  24152. * @param onError define a callback triggered when an error occurred during the loading session
  24153. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24154. * @returns the created texture
  24155. */
  24156. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24157. /**
  24158. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24159. * @param data Define the base64 payload without the data: prefix
  24160. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24161. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24162. * @param scene Define the scene the texture should belong to
  24163. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24164. * @param noMipmap Forces the texture to not create mip map information if true
  24165. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24166. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24167. * @param onLoad define a callback triggered when the texture has been loaded
  24168. * @param onError define a callback triggered when an error occurred during the loading session
  24169. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24170. * @returns the created texture
  24171. */
  24172. 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;
  24173. }
  24174. }
  24175. declare module BABYLON {
  24176. /**
  24177. * ThinSprite Class used to represent a thin sprite
  24178. * This is the base class for sprites but can also directly be used with ThinEngine
  24179. * @see https://doc.babylonjs.com/babylon101/sprites
  24180. */
  24181. export class ThinSprite {
  24182. /** Gets or sets the cell index in the sprite sheet */
  24183. cellIndex: number;
  24184. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24185. cellRef: string;
  24186. /** Gets or sets the current world position */
  24187. position: IVector3Like;
  24188. /** Gets or sets the main color */
  24189. color: IColor4Like;
  24190. /** Gets or sets the width */
  24191. width: number;
  24192. /** Gets or sets the height */
  24193. height: number;
  24194. /** Gets or sets rotation angle */
  24195. angle: number;
  24196. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24197. invertU: boolean;
  24198. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24199. invertV: boolean;
  24200. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24201. isVisible: boolean;
  24202. /**
  24203. * Returns a boolean indicating if the animation is started
  24204. */
  24205. get animationStarted(): boolean;
  24206. /** Gets the initial key for the animation (setting it will restart the animation) */
  24207. get fromIndex(): number;
  24208. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24209. get toIndex(): number;
  24210. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24211. get loopAnimation(): boolean;
  24212. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24213. get delay(): number;
  24214. /** @hidden */
  24215. _xOffset: number;
  24216. /** @hidden */
  24217. _yOffset: number;
  24218. /** @hidden */
  24219. _xSize: number;
  24220. /** @hidden */
  24221. _ySize: number;
  24222. private _animationStarted;
  24223. protected _loopAnimation: boolean;
  24224. protected _fromIndex: number;
  24225. protected _toIndex: number;
  24226. protected _delay: number;
  24227. private _direction;
  24228. private _time;
  24229. private _onBaseAnimationEnd;
  24230. /**
  24231. * Creates a new Thin Sprite
  24232. */
  24233. constructor();
  24234. /**
  24235. * Starts an animation
  24236. * @param from defines the initial key
  24237. * @param to defines the end key
  24238. * @param loop defines if the animation must loop
  24239. * @param delay defines the start delay (in ms)
  24240. * @param onAnimationEnd defines a callback for when the animation ends
  24241. */
  24242. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24243. /** Stops current animation (if any) */
  24244. stopAnimation(): void;
  24245. /** @hidden */
  24246. _animate(deltaTime: number): void;
  24247. }
  24248. }
  24249. declare module BABYLON {
  24250. /** @hidden */
  24251. export var imageProcessingCompatibility: {
  24252. name: string;
  24253. shader: string;
  24254. };
  24255. }
  24256. declare module BABYLON {
  24257. /** @hidden */
  24258. export var spritesPixelShader: {
  24259. name: string;
  24260. shader: string;
  24261. };
  24262. }
  24263. declare module BABYLON {
  24264. /** @hidden */
  24265. export var spritesVertexShader: {
  24266. name: string;
  24267. shader: string;
  24268. };
  24269. }
  24270. declare module BABYLON {
  24271. /**
  24272. * Class used to render sprites.
  24273. *
  24274. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24275. */
  24276. export class SpriteRenderer {
  24277. /**
  24278. * Defines the texture of the spritesheet
  24279. */
  24280. texture: Nullable<ThinTexture>;
  24281. /**
  24282. * Defines the default width of a cell in the spritesheet
  24283. */
  24284. cellWidth: number;
  24285. /**
  24286. * Defines the default height of a cell in the spritesheet
  24287. */
  24288. cellHeight: number;
  24289. /**
  24290. * Blend mode use to render the particle, it can be any of
  24291. * the static Constants.ALPHA_x properties provided in this class.
  24292. * Default value is Constants.ALPHA_COMBINE
  24293. */
  24294. blendMode: number;
  24295. /**
  24296. * Gets or sets a boolean indicating if alpha mode is automatically
  24297. * reset.
  24298. */
  24299. autoResetAlpha: boolean;
  24300. /**
  24301. * Disables writing to the depth buffer when rendering the sprites.
  24302. * It can be handy to disable depth writing when using textures without alpha channel
  24303. * and setting some specific blend modes.
  24304. */
  24305. disableDepthWrite: boolean;
  24306. /**
  24307. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24308. */
  24309. fogEnabled: boolean;
  24310. /**
  24311. * Gets the capacity of the manager
  24312. */
  24313. get capacity(): number;
  24314. private readonly _engine;
  24315. private readonly _useVAO;
  24316. private readonly _useInstancing;
  24317. private readonly _scene;
  24318. private readonly _capacity;
  24319. private readonly _epsilon;
  24320. private _vertexBufferSize;
  24321. private _vertexData;
  24322. private _buffer;
  24323. private _vertexBuffers;
  24324. private _spriteBuffer;
  24325. private _indexBuffer;
  24326. private _effectBase;
  24327. private _effectFog;
  24328. private _vertexArrayObject;
  24329. /**
  24330. * Creates a new sprite Renderer
  24331. * @param engine defines the engine the renderer works with
  24332. * @param capacity defines the maximum allowed number of sprites
  24333. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24334. * @param scene defines the hosting scene
  24335. */
  24336. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24337. /**
  24338. * Render all child sprites
  24339. * @param sprites defines the list of sprites to render
  24340. * @param deltaTime defines the time since last frame
  24341. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24342. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24343. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24344. */
  24345. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24346. private _appendSpriteVertex;
  24347. /**
  24348. * Release associated resources
  24349. */
  24350. dispose(): void;
  24351. }
  24352. }
  24353. declare module BABYLON {
  24354. /**
  24355. * Defines the minimum interface to fulfill in order to be a sprite manager.
  24356. */
  24357. export interface ISpriteManager extends IDisposable {
  24358. /**
  24359. * Gets manager's name
  24360. */
  24361. name: string;
  24362. /**
  24363. * Restricts the camera to viewing objects with the same layerMask.
  24364. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24365. */
  24366. layerMask: number;
  24367. /**
  24368. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24369. */
  24370. isPickable: boolean;
  24371. /**
  24372. * Gets the hosting scene
  24373. */
  24374. scene: Scene;
  24375. /**
  24376. * Specifies the rendering group id for this mesh (0 by default)
  24377. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24378. */
  24379. renderingGroupId: number;
  24380. /**
  24381. * Defines the list of sprites managed by the manager.
  24382. */
  24383. sprites: Array<Sprite>;
  24384. /**
  24385. * Gets or sets the spritesheet texture
  24386. */
  24387. texture: Texture;
  24388. /** Defines the default width of a cell in the spritesheet */
  24389. cellWidth: number;
  24390. /** Defines the default height of a cell in the spritesheet */
  24391. cellHeight: number;
  24392. /**
  24393. * Tests the intersection of a sprite with a specific ray.
  24394. * @param ray The ray we are sending to test the collision
  24395. * @param camera The camera space we are sending rays in
  24396. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24397. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24398. * @returns picking info or null.
  24399. */
  24400. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24401. /**
  24402. * Intersects the sprites with a ray
  24403. * @param ray defines the ray to intersect with
  24404. * @param camera defines the current active camera
  24405. * @param predicate defines a predicate used to select candidate sprites
  24406. * @returns null if no hit or a PickingInfo array
  24407. */
  24408. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24409. /**
  24410. * Renders the list of sprites on screen.
  24411. */
  24412. render(): void;
  24413. }
  24414. /**
  24415. * Class used to manage multiple sprites on the same spritesheet
  24416. * @see https://doc.babylonjs.com/babylon101/sprites
  24417. */
  24418. export class SpriteManager implements ISpriteManager {
  24419. /** defines the manager's name */
  24420. name: string;
  24421. /** Define the Url to load snippets */
  24422. static SnippetUrl: string;
  24423. /** Snippet ID if the manager was created from the snippet server */
  24424. snippetId: string;
  24425. /** Gets the list of sprites */
  24426. sprites: Sprite[];
  24427. /** Gets or sets the rendering group id (0 by default) */
  24428. renderingGroupId: number;
  24429. /** Gets or sets camera layer mask */
  24430. layerMask: number;
  24431. /** Gets or sets a boolean indicating if the sprites are pickable */
  24432. isPickable: boolean;
  24433. /**
  24434. * An event triggered when the manager is disposed.
  24435. */
  24436. onDisposeObservable: Observable<SpriteManager>;
  24437. /**
  24438. * Callback called when the manager is disposed
  24439. */
  24440. set onDispose(callback: () => void);
  24441. /**
  24442. * Gets or sets the unique id of the sprite
  24443. */
  24444. uniqueId: number;
  24445. /**
  24446. * Gets the array of sprites
  24447. */
  24448. get children(): Sprite[];
  24449. /**
  24450. * Gets the hosting scene
  24451. */
  24452. get scene(): Scene;
  24453. /**
  24454. * Gets the capacity of the manager
  24455. */
  24456. get capacity(): number;
  24457. /**
  24458. * Gets or sets the spritesheet texture
  24459. */
  24460. get texture(): Texture;
  24461. set texture(value: Texture);
  24462. /** Defines the default width of a cell in the spritesheet */
  24463. get cellWidth(): number;
  24464. set cellWidth(value: number);
  24465. /** Defines the default height of a cell in the spritesheet */
  24466. get cellHeight(): number;
  24467. set cellHeight(value: number);
  24468. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24469. get fogEnabled(): boolean;
  24470. set fogEnabled(value: boolean);
  24471. /**
  24472. * Blend mode use to render the particle, it can be any of
  24473. * the static Constants.ALPHA_x properties provided in this class.
  24474. * Default value is Constants.ALPHA_COMBINE
  24475. */
  24476. get blendMode(): number;
  24477. set blendMode(blendMode: number);
  24478. /** Disables writing to the depth buffer when rendering the sprites.
  24479. * It can be handy to disable depth writing when using textures without alpha channel
  24480. * and setting some specific blend modes.
  24481. */
  24482. disableDepthWrite: boolean;
  24483. private _spriteRenderer;
  24484. /** Associative array from JSON sprite data file */
  24485. private _cellData;
  24486. /** Array of sprite names from JSON sprite data file */
  24487. private _spriteMap;
  24488. /** True when packed cell data from JSON file is ready*/
  24489. private _packedAndReady;
  24490. private _textureContent;
  24491. private _onDisposeObserver;
  24492. private _fromPacked;
  24493. private _scene;
  24494. /**
  24495. * Creates a new sprite manager
  24496. * @param name defines the manager's name
  24497. * @param imgUrl defines the sprite sheet url
  24498. * @param capacity defines the maximum allowed number of sprites
  24499. * @param cellSize defines the size of a sprite cell
  24500. * @param scene defines the hosting scene
  24501. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24502. * @param samplingMode defines the sampling mode to use with spritesheet
  24503. * @param fromPacked set to false; do not alter
  24504. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24505. */
  24506. constructor(
  24507. /** defines the manager's name */
  24508. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24509. /**
  24510. * Returns the string "SpriteManager"
  24511. * @returns "SpriteManager"
  24512. */
  24513. getClassName(): string;
  24514. private _makePacked;
  24515. private _checkTextureAlpha;
  24516. /**
  24517. * Intersects the sprites with a ray
  24518. * @param ray defines the ray to intersect with
  24519. * @param camera defines the current active camera
  24520. * @param predicate defines a predicate used to select candidate sprites
  24521. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24522. * @returns null if no hit or a PickingInfo
  24523. */
  24524. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24525. /**
  24526. * Intersects the sprites with a ray
  24527. * @param ray defines the ray to intersect with
  24528. * @param camera defines the current active camera
  24529. * @param predicate defines a predicate used to select candidate sprites
  24530. * @returns null if no hit or a PickingInfo array
  24531. */
  24532. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24533. /**
  24534. * Render all child sprites
  24535. */
  24536. render(): void;
  24537. private _customUpdate;
  24538. /**
  24539. * Release associated resources
  24540. */
  24541. dispose(): void;
  24542. /**
  24543. * Serializes the sprite manager to a JSON object
  24544. * @param serializeTexture defines if the texture must be serialized as well
  24545. * @returns the JSON object
  24546. */
  24547. serialize(serializeTexture?: boolean): any;
  24548. /**
  24549. * Parses a JSON object to create a new sprite manager.
  24550. * @param parsedManager The JSON object to parse
  24551. * @param scene The scene to create the sprite manager
  24552. * @param rootUrl The root url to use to load external dependencies like texture
  24553. * @returns the new sprite manager
  24554. */
  24555. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24556. /**
  24557. * Creates a sprite manager from a snippet saved in a remote file
  24558. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24559. * @param url defines the url to load from
  24560. * @param scene defines the hosting scene
  24561. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24562. * @returns a promise that will resolve to the new sprite manager
  24563. */
  24564. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24565. /**
  24566. * Creates a sprite manager from a snippet saved by the sprite editor
  24567. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24568. * @param scene defines the hosting scene
  24569. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24570. * @returns a promise that will resolve to the new sprite manager
  24571. */
  24572. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24573. }
  24574. }
  24575. declare module BABYLON {
  24576. /**
  24577. * Class used to represent a sprite
  24578. * @see https://doc.babylonjs.com/babylon101/sprites
  24579. */
  24580. export class Sprite extends ThinSprite implements IAnimatable {
  24581. /** defines the name */
  24582. name: string;
  24583. /** Gets or sets the current world position */
  24584. position: Vector3;
  24585. /** Gets or sets the main color */
  24586. color: Color4;
  24587. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24588. disposeWhenFinishedAnimating: boolean;
  24589. /** Gets the list of attached animations */
  24590. animations: Nullable<Array<Animation>>;
  24591. /** Gets or sets a boolean indicating if the sprite can be picked */
  24592. isPickable: boolean;
  24593. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24594. useAlphaForPicking: boolean;
  24595. /**
  24596. * Gets or sets the associated action manager
  24597. */
  24598. actionManager: Nullable<ActionManager>;
  24599. /**
  24600. * An event triggered when the control has been disposed
  24601. */
  24602. onDisposeObservable: Observable<Sprite>;
  24603. private _manager;
  24604. private _onAnimationEnd;
  24605. /**
  24606. * Gets or sets the sprite size
  24607. */
  24608. get size(): number;
  24609. set size(value: number);
  24610. /**
  24611. * Gets or sets the unique id of the sprite
  24612. */
  24613. uniqueId: number;
  24614. /**
  24615. * Gets the manager of this sprite
  24616. */
  24617. get manager(): ISpriteManager;
  24618. /**
  24619. * Creates a new Sprite
  24620. * @param name defines the name
  24621. * @param manager defines the manager
  24622. */
  24623. constructor(
  24624. /** defines the name */
  24625. name: string, manager: ISpriteManager);
  24626. /**
  24627. * Returns the string "Sprite"
  24628. * @returns "Sprite"
  24629. */
  24630. getClassName(): string;
  24631. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24632. get fromIndex(): number;
  24633. set fromIndex(value: number);
  24634. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24635. get toIndex(): number;
  24636. set toIndex(value: number);
  24637. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24638. get loopAnimation(): boolean;
  24639. set loopAnimation(value: boolean);
  24640. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24641. get delay(): number;
  24642. set delay(value: number);
  24643. /**
  24644. * Starts an animation
  24645. * @param from defines the initial key
  24646. * @param to defines the end key
  24647. * @param loop defines if the animation must loop
  24648. * @param delay defines the start delay (in ms)
  24649. * @param onAnimationEnd defines a callback to call when animation ends
  24650. */
  24651. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24652. private _endAnimation;
  24653. /** Release associated resources */
  24654. dispose(): void;
  24655. /**
  24656. * Serializes the sprite to a JSON object
  24657. * @returns the JSON object
  24658. */
  24659. serialize(): any;
  24660. /**
  24661. * Parses a JSON object to create a new sprite
  24662. * @param parsedSprite The JSON object to parse
  24663. * @param manager defines the hosting manager
  24664. * @returns the new sprite
  24665. */
  24666. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24667. }
  24668. }
  24669. declare module BABYLON {
  24670. /**
  24671. * Information about the result of picking within a scene
  24672. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24673. */
  24674. export class PickingInfo {
  24675. /** @hidden */
  24676. _pickingUnavailable: boolean;
  24677. /**
  24678. * If the pick collided with an object
  24679. */
  24680. hit: boolean;
  24681. /**
  24682. * Distance away where the pick collided
  24683. */
  24684. distance: number;
  24685. /**
  24686. * The location of pick collision
  24687. */
  24688. pickedPoint: Nullable<Vector3>;
  24689. /**
  24690. * The mesh corresponding the the pick collision
  24691. */
  24692. pickedMesh: Nullable<AbstractMesh>;
  24693. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24694. bu: number;
  24695. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24696. bv: number;
  24697. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24698. faceId: number;
  24699. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24700. subMeshFaceId: number;
  24701. /** Id of the the submesh that was picked */
  24702. subMeshId: number;
  24703. /** If a sprite was picked, this will be the sprite the pick collided with */
  24704. pickedSprite: Nullable<Sprite>;
  24705. /** If we are picking a mesh with thin instance, this will give you the picked thin instance */
  24706. thinInstanceIndex: number;
  24707. /**
  24708. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24709. */
  24710. originMesh: Nullable<AbstractMesh>;
  24711. /**
  24712. * The ray that was used to perform the picking.
  24713. */
  24714. ray: Nullable<Ray>;
  24715. /**
  24716. * Gets the normal corresponding to the face the pick collided with
  24717. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24718. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24719. * @returns The normal corresponding to the face the pick collided with
  24720. */
  24721. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24722. /**
  24723. * Gets the texture coordinates of where the pick occurred
  24724. * @returns the vector containing the coordinates of the texture
  24725. */
  24726. getTextureCoordinates(): Nullable<Vector2>;
  24727. }
  24728. }
  24729. declare module BABYLON {
  24730. /**
  24731. * Gather the list of pointer event types as constants.
  24732. */
  24733. export class PointerEventTypes {
  24734. /**
  24735. * 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.
  24736. */
  24737. static readonly POINTERDOWN: number;
  24738. /**
  24739. * The pointerup event is fired when a pointer is no longer active.
  24740. */
  24741. static readonly POINTERUP: number;
  24742. /**
  24743. * The pointermove event is fired when a pointer changes coordinates.
  24744. */
  24745. static readonly POINTERMOVE: number;
  24746. /**
  24747. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24748. */
  24749. static readonly POINTERWHEEL: number;
  24750. /**
  24751. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24752. */
  24753. static readonly POINTERPICK: number;
  24754. /**
  24755. * The pointertap event is fired when a the object has been touched and released without drag.
  24756. */
  24757. static readonly POINTERTAP: number;
  24758. /**
  24759. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24760. */
  24761. static readonly POINTERDOUBLETAP: number;
  24762. }
  24763. /**
  24764. * Base class of pointer info types.
  24765. */
  24766. export class PointerInfoBase {
  24767. /**
  24768. * Defines the type of event (PointerEventTypes)
  24769. */
  24770. type: number;
  24771. /**
  24772. * Defines the related dom event
  24773. */
  24774. event: PointerEvent | MouseWheelEvent;
  24775. /**
  24776. * Instantiates the base class of pointers info.
  24777. * @param type Defines the type of event (PointerEventTypes)
  24778. * @param event Defines the related dom event
  24779. */
  24780. constructor(
  24781. /**
  24782. * Defines the type of event (PointerEventTypes)
  24783. */
  24784. type: number,
  24785. /**
  24786. * Defines the related dom event
  24787. */
  24788. event: PointerEvent | MouseWheelEvent);
  24789. }
  24790. /**
  24791. * This class is used to store pointer related info for the onPrePointerObservable event.
  24792. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24793. */
  24794. export class PointerInfoPre extends PointerInfoBase {
  24795. /**
  24796. * Ray from a pointer if availible (eg. 6dof controller)
  24797. */
  24798. ray: Nullable<Ray>;
  24799. /**
  24800. * Defines the local position of the pointer on the canvas.
  24801. */
  24802. localPosition: Vector2;
  24803. /**
  24804. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24805. */
  24806. skipOnPointerObservable: boolean;
  24807. /**
  24808. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24809. * @param type Defines the type of event (PointerEventTypes)
  24810. * @param event Defines the related dom event
  24811. * @param localX Defines the local x coordinates of the pointer when the event occured
  24812. * @param localY Defines the local y coordinates of the pointer when the event occured
  24813. */
  24814. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24815. }
  24816. /**
  24817. * This type contains all the data related to a pointer event in Babylon.js.
  24818. * 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.
  24819. */
  24820. export class PointerInfo extends PointerInfoBase {
  24821. /**
  24822. * Defines the picking info associated to the info (if any)\
  24823. */
  24824. pickInfo: Nullable<PickingInfo>;
  24825. /**
  24826. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24827. * @param type Defines the type of event (PointerEventTypes)
  24828. * @param event Defines the related dom event
  24829. * @param pickInfo Defines the picking info associated to the info (if any)\
  24830. */
  24831. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24832. /**
  24833. * Defines the picking info associated to the info (if any)\
  24834. */
  24835. pickInfo: Nullable<PickingInfo>);
  24836. }
  24837. /**
  24838. * Data relating to a touch event on the screen.
  24839. */
  24840. export interface PointerTouch {
  24841. /**
  24842. * X coordinate of touch.
  24843. */
  24844. x: number;
  24845. /**
  24846. * Y coordinate of touch.
  24847. */
  24848. y: number;
  24849. /**
  24850. * Id of touch. Unique for each finger.
  24851. */
  24852. pointerId: number;
  24853. /**
  24854. * Event type passed from DOM.
  24855. */
  24856. type: any;
  24857. }
  24858. }
  24859. declare module BABYLON {
  24860. /**
  24861. * Manage the mouse inputs to control the movement of a free camera.
  24862. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24863. */
  24864. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24865. /**
  24866. * Define if touch is enabled in the mouse input
  24867. */
  24868. touchEnabled: boolean;
  24869. /**
  24870. * Defines the camera the input is attached to.
  24871. */
  24872. camera: FreeCamera;
  24873. /**
  24874. * Defines the buttons associated with the input to handle camera move.
  24875. */
  24876. buttons: number[];
  24877. /**
  24878. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24879. */
  24880. angularSensibility: number;
  24881. private _pointerInput;
  24882. private _onMouseMove;
  24883. private _observer;
  24884. private previousPosition;
  24885. /**
  24886. * Observable for when a pointer move event occurs containing the move offset
  24887. */
  24888. onPointerMovedObservable: Observable<{
  24889. offsetX: number;
  24890. offsetY: number;
  24891. }>;
  24892. /**
  24893. * @hidden
  24894. * If the camera should be rotated automatically based on pointer movement
  24895. */
  24896. _allowCameraRotation: boolean;
  24897. /**
  24898. * Manage the mouse inputs to control the movement of a free camera.
  24899. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24900. * @param touchEnabled Defines if touch is enabled or not
  24901. */
  24902. constructor(
  24903. /**
  24904. * Define if touch is enabled in the mouse input
  24905. */
  24906. touchEnabled?: boolean);
  24907. /**
  24908. * Attach the input controls to a specific dom element to get the input from.
  24909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24910. */
  24911. attachControl(noPreventDefault?: boolean): void;
  24912. /**
  24913. * Called on JS contextmenu event.
  24914. * Override this method to provide functionality.
  24915. */
  24916. protected onContextMenu(evt: PointerEvent): void;
  24917. /**
  24918. * Detach the current controls from the specified dom element.
  24919. */
  24920. detachControl(): void;
  24921. /**
  24922. * Gets the class name of the current input.
  24923. * @returns the class name
  24924. */
  24925. getClassName(): string;
  24926. /**
  24927. * Get the friendly name associated with the input class.
  24928. * @returns the input friendly name
  24929. */
  24930. getSimpleName(): string;
  24931. }
  24932. }
  24933. declare module BABYLON {
  24934. /**
  24935. * Base class for mouse wheel input..
  24936. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24937. * for example usage.
  24938. */
  24939. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24940. /**
  24941. * Defines the camera the input is attached to.
  24942. */
  24943. abstract camera: Camera;
  24944. /**
  24945. * How fast is the camera moves in relation to X axis mouseWheel events.
  24946. * Use negative value to reverse direction.
  24947. */
  24948. wheelPrecisionX: number;
  24949. /**
  24950. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24951. * Use negative value to reverse direction.
  24952. */
  24953. wheelPrecisionY: number;
  24954. /**
  24955. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24956. * Use negative value to reverse direction.
  24957. */
  24958. wheelPrecisionZ: number;
  24959. /**
  24960. * Observable for when a mouse wheel move event occurs.
  24961. */
  24962. onChangedObservable: Observable<{
  24963. wheelDeltaX: number;
  24964. wheelDeltaY: number;
  24965. wheelDeltaZ: number;
  24966. }>;
  24967. private _wheel;
  24968. private _observer;
  24969. /**
  24970. * Attach the input controls to a specific dom element to get the input from.
  24971. * @param noPreventDefault Defines whether event caught by the controls
  24972. * should call preventdefault().
  24973. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24974. */
  24975. attachControl(noPreventDefault?: boolean): void;
  24976. /**
  24977. * Detach the current controls from the specified dom element.
  24978. */
  24979. detachControl(): void;
  24980. /**
  24981. * Called for each rendered frame.
  24982. */
  24983. checkInputs(): void;
  24984. /**
  24985. * Gets the class name of the current input.
  24986. * @returns the class name
  24987. */
  24988. getClassName(): string;
  24989. /**
  24990. * Get the friendly name associated with the input class.
  24991. * @returns the input friendly name
  24992. */
  24993. getSimpleName(): string;
  24994. /**
  24995. * Incremental value of multiple mouse wheel movements of the X axis.
  24996. * Should be zero-ed when read.
  24997. */
  24998. protected _wheelDeltaX: number;
  24999. /**
  25000. * Incremental value of multiple mouse wheel movements of the Y axis.
  25001. * Should be zero-ed when read.
  25002. */
  25003. protected _wheelDeltaY: number;
  25004. /**
  25005. * Incremental value of multiple mouse wheel movements of the Z axis.
  25006. * Should be zero-ed when read.
  25007. */
  25008. protected _wheelDeltaZ: number;
  25009. /**
  25010. * Firefox uses a different scheme to report scroll distances to other
  25011. * browsers. Rather than use complicated methods to calculate the exact
  25012. * multiple we need to apply, let's just cheat and use a constant.
  25013. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  25014. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  25015. */
  25016. private readonly _ffMultiplier;
  25017. /**
  25018. * Different event attributes for wheel data fall into a few set ranges.
  25019. * Some relevant but dated date here:
  25020. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  25021. */
  25022. private readonly _normalize;
  25023. }
  25024. }
  25025. declare module BABYLON {
  25026. /**
  25027. * Manage the mouse wheel inputs to control a free camera.
  25028. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25029. */
  25030. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  25031. /**
  25032. * Defines the camera the input is attached to.
  25033. */
  25034. camera: FreeCamera;
  25035. /**
  25036. * Gets the class name of the current input.
  25037. * @returns the class name
  25038. */
  25039. getClassName(): string;
  25040. /**
  25041. * Set which movement axis (relative to camera's orientation) the mouse
  25042. * wheel's X axis controls.
  25043. * @param axis The axis to be moved. Set null to clear.
  25044. */
  25045. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  25046. /**
  25047. * Get the configured movement axis (relative to camera's orientation) the
  25048. * mouse wheel's X axis controls.
  25049. * @returns The configured axis or null if none.
  25050. */
  25051. get wheelXMoveRelative(): Nullable<Coordinate>;
  25052. /**
  25053. * Set which movement axis (relative to camera's orientation) the mouse
  25054. * wheel's Y axis controls.
  25055. * @param axis The axis to be moved. Set null to clear.
  25056. */
  25057. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  25058. /**
  25059. * Get the configured movement axis (relative to camera's orientation) the
  25060. * mouse wheel's Y axis controls.
  25061. * @returns The configured axis or null if none.
  25062. */
  25063. get wheelYMoveRelative(): Nullable<Coordinate>;
  25064. /**
  25065. * Set which movement axis (relative to camera's orientation) the mouse
  25066. * wheel's Z axis controls.
  25067. * @param axis The axis to be moved. Set null to clear.
  25068. */
  25069. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  25070. /**
  25071. * Get the configured movement axis (relative to camera's orientation) the
  25072. * mouse wheel's Z axis controls.
  25073. * @returns The configured axis or null if none.
  25074. */
  25075. get wheelZMoveRelative(): Nullable<Coordinate>;
  25076. /**
  25077. * Set which rotation axis (relative to camera's orientation) the mouse
  25078. * wheel's X axis controls.
  25079. * @param axis The axis to be moved. Set null to clear.
  25080. */
  25081. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25082. /**
  25083. * Get the configured rotation axis (relative to camera's orientation) the
  25084. * mouse wheel's X axis controls.
  25085. * @returns The configured axis or null if none.
  25086. */
  25087. get wheelXRotateRelative(): Nullable<Coordinate>;
  25088. /**
  25089. * Set which rotation axis (relative to camera's orientation) the mouse
  25090. * wheel's Y axis controls.
  25091. * @param axis The axis to be moved. Set null to clear.
  25092. */
  25093. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25094. /**
  25095. * Get the configured rotation axis (relative to camera's orientation) the
  25096. * mouse wheel's Y axis controls.
  25097. * @returns The configured axis or null if none.
  25098. */
  25099. get wheelYRotateRelative(): Nullable<Coordinate>;
  25100. /**
  25101. * Set which rotation axis (relative to camera's orientation) the mouse
  25102. * wheel's Z axis controls.
  25103. * @param axis The axis to be moved. Set null to clear.
  25104. */
  25105. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25106. /**
  25107. * Get the configured rotation axis (relative to camera's orientation) the
  25108. * mouse wheel's Z axis controls.
  25109. * @returns The configured axis or null if none.
  25110. */
  25111. get wheelZRotateRelative(): Nullable<Coordinate>;
  25112. /**
  25113. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25114. * controls.
  25115. * @param axis The axis to be moved. Set null to clear.
  25116. */
  25117. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25118. /**
  25119. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25120. * X axis controls.
  25121. * @returns The configured axis or null if none.
  25122. */
  25123. get wheelXMoveScene(): Nullable<Coordinate>;
  25124. /**
  25125. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25126. * controls.
  25127. * @param axis The axis to be moved. Set null to clear.
  25128. */
  25129. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25130. /**
  25131. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25132. * Y axis controls.
  25133. * @returns The configured axis or null if none.
  25134. */
  25135. get wheelYMoveScene(): Nullable<Coordinate>;
  25136. /**
  25137. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25138. * controls.
  25139. * @param axis The axis to be moved. Set null to clear.
  25140. */
  25141. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25142. /**
  25143. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25144. * Z axis controls.
  25145. * @returns The configured axis or null if none.
  25146. */
  25147. get wheelZMoveScene(): Nullable<Coordinate>;
  25148. /**
  25149. * Called for each rendered frame.
  25150. */
  25151. checkInputs(): void;
  25152. private _moveRelative;
  25153. private _rotateRelative;
  25154. private _moveScene;
  25155. /**
  25156. * These are set to the desired default behaviour.
  25157. */
  25158. private _wheelXAction;
  25159. private _wheelXActionCoordinate;
  25160. private _wheelYAction;
  25161. private _wheelYActionCoordinate;
  25162. private _wheelZAction;
  25163. private _wheelZActionCoordinate;
  25164. /**
  25165. * Update the camera according to any configured properties for the 3
  25166. * mouse-wheel axis.
  25167. */
  25168. private _updateCamera;
  25169. /**
  25170. * Update one property of the camera.
  25171. */
  25172. private _updateCameraProperty;
  25173. }
  25174. }
  25175. declare module BABYLON {
  25176. /**
  25177. * Manage the touch inputs to control the movement of a free camera.
  25178. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25179. */
  25180. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25181. /**
  25182. * Define if mouse events can be treated as touch events
  25183. */
  25184. allowMouse: boolean;
  25185. /**
  25186. * Defines the camera the input is attached to.
  25187. */
  25188. camera: FreeCamera;
  25189. /**
  25190. * Defines the touch sensibility for rotation.
  25191. * The higher the faster.
  25192. */
  25193. touchAngularSensibility: number;
  25194. /**
  25195. * Defines the touch sensibility for move.
  25196. * The higher the faster.
  25197. */
  25198. touchMoveSensibility: number;
  25199. private _offsetX;
  25200. private _offsetY;
  25201. private _pointerPressed;
  25202. private _pointerInput?;
  25203. private _observer;
  25204. private _onLostFocus;
  25205. /**
  25206. * Manage the touch inputs to control the movement of a free camera.
  25207. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25208. * @param allowMouse Defines if mouse events can be treated as touch events
  25209. */
  25210. constructor(
  25211. /**
  25212. * Define if mouse events can be treated as touch events
  25213. */
  25214. allowMouse?: boolean);
  25215. /**
  25216. * Attach the input controls to a specific dom element to get the input from.
  25217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25218. */
  25219. attachControl(noPreventDefault?: boolean): void;
  25220. /**
  25221. * Detach the current controls from the specified dom element.
  25222. */
  25223. detachControl(): void;
  25224. /**
  25225. * Update the current camera state depending on the inputs that have been used this frame.
  25226. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25227. */
  25228. checkInputs(): void;
  25229. /**
  25230. * Gets the class name of the current input.
  25231. * @returns the class name
  25232. */
  25233. getClassName(): string;
  25234. /**
  25235. * Get the friendly name associated with the input class.
  25236. * @returns the input friendly name
  25237. */
  25238. getSimpleName(): string;
  25239. }
  25240. }
  25241. declare module BABYLON {
  25242. /**
  25243. * Default Inputs manager for the FreeCamera.
  25244. * It groups all the default supported inputs for ease of use.
  25245. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25246. */
  25247. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25248. /**
  25249. * @hidden
  25250. */
  25251. _mouseInput: Nullable<FreeCameraMouseInput>;
  25252. /**
  25253. * @hidden
  25254. */
  25255. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25256. /**
  25257. * Instantiates a new FreeCameraInputsManager.
  25258. * @param camera Defines the camera the inputs belong to
  25259. */
  25260. constructor(camera: FreeCamera);
  25261. /**
  25262. * Add keyboard input support to the input manager.
  25263. * @returns the current input manager
  25264. */
  25265. addKeyboard(): FreeCameraInputsManager;
  25266. /**
  25267. * Add mouse input support to the input manager.
  25268. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25269. * @returns the current input manager
  25270. */
  25271. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25272. /**
  25273. * Removes the mouse input support from the manager
  25274. * @returns the current input manager
  25275. */
  25276. removeMouse(): FreeCameraInputsManager;
  25277. /**
  25278. * Add mouse wheel input support to the input manager.
  25279. * @returns the current input manager
  25280. */
  25281. addMouseWheel(): FreeCameraInputsManager;
  25282. /**
  25283. * Removes the mouse wheel input support from the manager
  25284. * @returns the current input manager
  25285. */
  25286. removeMouseWheel(): FreeCameraInputsManager;
  25287. /**
  25288. * Add touch input support to the input manager.
  25289. * @returns the current input manager
  25290. */
  25291. addTouch(): FreeCameraInputsManager;
  25292. /**
  25293. * Remove all attached input methods from a camera
  25294. */
  25295. clear(): void;
  25296. }
  25297. }
  25298. declare module BABYLON {
  25299. /**
  25300. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25301. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25302. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25303. */
  25304. export class FreeCamera extends TargetCamera {
  25305. /**
  25306. * Define the collision ellipsoid of the camera.
  25307. * This is helpful to simulate a camera body like the player body around the camera
  25308. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25309. */
  25310. ellipsoid: Vector3;
  25311. /**
  25312. * Define an offset for the position of the ellipsoid around the camera.
  25313. * This can be helpful to determine the center of the body near the gravity center of the body
  25314. * instead of its head.
  25315. */
  25316. ellipsoidOffset: Vector3;
  25317. /**
  25318. * Enable or disable collisions of the camera with the rest of the scene objects.
  25319. */
  25320. checkCollisions: boolean;
  25321. /**
  25322. * Enable or disable gravity on the camera.
  25323. */
  25324. applyGravity: boolean;
  25325. /**
  25326. * Define the input manager associated to the camera.
  25327. */
  25328. inputs: FreeCameraInputsManager;
  25329. /**
  25330. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25331. * Higher values reduce sensitivity.
  25332. */
  25333. get angularSensibility(): number;
  25334. /**
  25335. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25336. * Higher values reduce sensitivity.
  25337. */
  25338. set angularSensibility(value: number);
  25339. /**
  25340. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25341. */
  25342. get keysUp(): number[];
  25343. set keysUp(value: number[]);
  25344. /**
  25345. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25346. */
  25347. get keysUpward(): number[];
  25348. set keysUpward(value: number[]);
  25349. /**
  25350. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25351. */
  25352. get keysDown(): number[];
  25353. set keysDown(value: number[]);
  25354. /**
  25355. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25356. */
  25357. get keysDownward(): number[];
  25358. set keysDownward(value: number[]);
  25359. /**
  25360. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25361. */
  25362. get keysLeft(): number[];
  25363. set keysLeft(value: number[]);
  25364. /**
  25365. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25366. */
  25367. get keysRight(): number[];
  25368. set keysRight(value: number[]);
  25369. /**
  25370. * Event raised when the camera collide with a mesh in the scene.
  25371. */
  25372. onCollide: (collidedMesh: AbstractMesh) => void;
  25373. private _collider;
  25374. private _needMoveForGravity;
  25375. private _oldPosition;
  25376. private _diffPosition;
  25377. private _newPosition;
  25378. /** @hidden */
  25379. _localDirection: Vector3;
  25380. /** @hidden */
  25381. _transformedDirection: Vector3;
  25382. /**
  25383. * Instantiates a Free Camera.
  25384. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25385. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25386. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25387. * @param name Define the name of the camera in the scene
  25388. * @param position Define the start position of the camera in the scene
  25389. * @param scene Define the scene the camera belongs to
  25390. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  25391. */
  25392. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25393. /**
  25394. * Attach the input controls to a specific dom element to get the input from.
  25395. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25396. */
  25397. attachControl(noPreventDefault?: boolean): void;
  25398. /**
  25399. * Attach the input controls to a specific dom element to get the input from.
  25400. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25402. * BACK COMPAT SIGNATURE ONLY.
  25403. */
  25404. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25405. /**
  25406. * Detach the current controls from the specified dom element.
  25407. */
  25408. detachControl(): void;
  25409. /**
  25410. * Detach the current controls from the specified dom element.
  25411. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25412. */
  25413. detachControl(ignored: any): void;
  25414. private _collisionMask;
  25415. /**
  25416. * Define a collision mask to limit the list of object the camera can collide with
  25417. */
  25418. get collisionMask(): number;
  25419. set collisionMask(mask: number);
  25420. /** @hidden */
  25421. _collideWithWorld(displacement: Vector3): void;
  25422. private _onCollisionPositionChange;
  25423. /** @hidden */
  25424. _checkInputs(): void;
  25425. /** @hidden */
  25426. _decideIfNeedsToMove(): boolean;
  25427. /** @hidden */
  25428. _updatePosition(): void;
  25429. /**
  25430. * Destroy the camera and release the current resources hold by it.
  25431. */
  25432. dispose(): void;
  25433. /**
  25434. * Gets the current object class name.
  25435. * @return the class name
  25436. */
  25437. getClassName(): string;
  25438. }
  25439. }
  25440. declare module BABYLON {
  25441. /**
  25442. * Represents a gamepad control stick position
  25443. */
  25444. export class StickValues {
  25445. /**
  25446. * The x component of the control stick
  25447. */
  25448. x: number;
  25449. /**
  25450. * The y component of the control stick
  25451. */
  25452. y: number;
  25453. /**
  25454. * Initializes the gamepad x and y control stick values
  25455. * @param x The x component of the gamepad control stick value
  25456. * @param y The y component of the gamepad control stick value
  25457. */
  25458. constructor(
  25459. /**
  25460. * The x component of the control stick
  25461. */
  25462. x: number,
  25463. /**
  25464. * The y component of the control stick
  25465. */
  25466. y: number);
  25467. }
  25468. /**
  25469. * An interface which manages callbacks for gamepad button changes
  25470. */
  25471. export interface GamepadButtonChanges {
  25472. /**
  25473. * Called when a gamepad has been changed
  25474. */
  25475. changed: boolean;
  25476. /**
  25477. * Called when a gamepad press event has been triggered
  25478. */
  25479. pressChanged: boolean;
  25480. /**
  25481. * Called when a touch event has been triggered
  25482. */
  25483. touchChanged: boolean;
  25484. /**
  25485. * Called when a value has changed
  25486. */
  25487. valueChanged: boolean;
  25488. }
  25489. /**
  25490. * Represents a gamepad
  25491. */
  25492. export class Gamepad {
  25493. /**
  25494. * The id of the gamepad
  25495. */
  25496. id: string;
  25497. /**
  25498. * The index of the gamepad
  25499. */
  25500. index: number;
  25501. /**
  25502. * The browser gamepad
  25503. */
  25504. browserGamepad: any;
  25505. /**
  25506. * Specifies what type of gamepad this represents
  25507. */
  25508. type: number;
  25509. private _leftStick;
  25510. private _rightStick;
  25511. /** @hidden */
  25512. _isConnected: boolean;
  25513. private _leftStickAxisX;
  25514. private _leftStickAxisY;
  25515. private _rightStickAxisX;
  25516. private _rightStickAxisY;
  25517. /**
  25518. * Triggered when the left control stick has been changed
  25519. */
  25520. private _onleftstickchanged;
  25521. /**
  25522. * Triggered when the right control stick has been changed
  25523. */
  25524. private _onrightstickchanged;
  25525. /**
  25526. * Represents a gamepad controller
  25527. */
  25528. static GAMEPAD: number;
  25529. /**
  25530. * Represents a generic controller
  25531. */
  25532. static GENERIC: number;
  25533. /**
  25534. * Represents an XBox controller
  25535. */
  25536. static XBOX: number;
  25537. /**
  25538. * Represents a pose-enabled controller
  25539. */
  25540. static POSE_ENABLED: number;
  25541. /**
  25542. * Represents an Dual Shock controller
  25543. */
  25544. static DUALSHOCK: number;
  25545. /**
  25546. * Specifies whether the left control stick should be Y-inverted
  25547. */
  25548. protected _invertLeftStickY: boolean;
  25549. /**
  25550. * Specifies if the gamepad has been connected
  25551. */
  25552. get isConnected(): boolean;
  25553. /**
  25554. * Initializes the gamepad
  25555. * @param id The id of the gamepad
  25556. * @param index The index of the gamepad
  25557. * @param browserGamepad The browser gamepad
  25558. * @param leftStickX The x component of the left joystick
  25559. * @param leftStickY The y component of the left joystick
  25560. * @param rightStickX The x component of the right joystick
  25561. * @param rightStickY The y component of the right joystick
  25562. */
  25563. constructor(
  25564. /**
  25565. * The id of the gamepad
  25566. */
  25567. id: string,
  25568. /**
  25569. * The index of the gamepad
  25570. */
  25571. index: number,
  25572. /**
  25573. * The browser gamepad
  25574. */
  25575. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25576. /**
  25577. * Callback triggered when the left joystick has changed
  25578. * @param callback
  25579. */
  25580. onleftstickchanged(callback: (values: StickValues) => void): void;
  25581. /**
  25582. * Callback triggered when the right joystick has changed
  25583. * @param callback
  25584. */
  25585. onrightstickchanged(callback: (values: StickValues) => void): void;
  25586. /**
  25587. * Gets the left joystick
  25588. */
  25589. get leftStick(): StickValues;
  25590. /**
  25591. * Sets the left joystick values
  25592. */
  25593. set leftStick(newValues: StickValues);
  25594. /**
  25595. * Gets the right joystick
  25596. */
  25597. get rightStick(): StickValues;
  25598. /**
  25599. * Sets the right joystick value
  25600. */
  25601. set rightStick(newValues: StickValues);
  25602. /**
  25603. * Updates the gamepad joystick positions
  25604. */
  25605. update(): void;
  25606. /**
  25607. * Disposes the gamepad
  25608. */
  25609. dispose(): void;
  25610. }
  25611. /**
  25612. * Represents a generic gamepad
  25613. */
  25614. export class GenericPad extends Gamepad {
  25615. private _buttons;
  25616. private _onbuttondown;
  25617. private _onbuttonup;
  25618. /**
  25619. * Observable triggered when a button has been pressed
  25620. */
  25621. onButtonDownObservable: Observable<number>;
  25622. /**
  25623. * Observable triggered when a button has been released
  25624. */
  25625. onButtonUpObservable: Observable<number>;
  25626. /**
  25627. * Callback triggered when a button has been pressed
  25628. * @param callback Called when a button has been pressed
  25629. */
  25630. onbuttondown(callback: (buttonPressed: number) => void): void;
  25631. /**
  25632. * Callback triggered when a button has been released
  25633. * @param callback Called when a button has been released
  25634. */
  25635. onbuttonup(callback: (buttonReleased: number) => void): void;
  25636. /**
  25637. * Initializes the generic gamepad
  25638. * @param id The id of the generic gamepad
  25639. * @param index The index of the generic gamepad
  25640. * @param browserGamepad The browser gamepad
  25641. */
  25642. constructor(id: string, index: number, browserGamepad: any);
  25643. private _setButtonValue;
  25644. /**
  25645. * Updates the generic gamepad
  25646. */
  25647. update(): void;
  25648. /**
  25649. * Disposes the generic gamepad
  25650. */
  25651. dispose(): void;
  25652. }
  25653. }
  25654. declare module BABYLON {
  25655. /**
  25656. * Defines a runtime animation
  25657. */
  25658. export class RuntimeAnimation {
  25659. private _events;
  25660. /**
  25661. * The current frame of the runtime animation
  25662. */
  25663. private _currentFrame;
  25664. /**
  25665. * The animation used by the runtime animation
  25666. */
  25667. private _animation;
  25668. /**
  25669. * The target of the runtime animation
  25670. */
  25671. private _target;
  25672. /**
  25673. * The initiating animatable
  25674. */
  25675. private _host;
  25676. /**
  25677. * The original value of the runtime animation
  25678. */
  25679. private _originalValue;
  25680. /**
  25681. * The original blend value of the runtime animation
  25682. */
  25683. private _originalBlendValue;
  25684. /**
  25685. * The offsets cache of the runtime animation
  25686. */
  25687. private _offsetsCache;
  25688. /**
  25689. * The high limits cache of the runtime animation
  25690. */
  25691. private _highLimitsCache;
  25692. /**
  25693. * Specifies if the runtime animation has been stopped
  25694. */
  25695. private _stopped;
  25696. /**
  25697. * The blending factor of the runtime animation
  25698. */
  25699. private _blendingFactor;
  25700. /**
  25701. * The BabylonJS scene
  25702. */
  25703. private _scene;
  25704. /**
  25705. * The current value of the runtime animation
  25706. */
  25707. private _currentValue;
  25708. /** @hidden */
  25709. _animationState: _IAnimationState;
  25710. /**
  25711. * The active target of the runtime animation
  25712. */
  25713. private _activeTargets;
  25714. private _currentActiveTarget;
  25715. private _directTarget;
  25716. /**
  25717. * The target path of the runtime animation
  25718. */
  25719. private _targetPath;
  25720. /**
  25721. * The weight of the runtime animation
  25722. */
  25723. private _weight;
  25724. /**
  25725. * The ratio offset of the runtime animation
  25726. */
  25727. private _ratioOffset;
  25728. /**
  25729. * The previous delay of the runtime animation
  25730. */
  25731. private _previousDelay;
  25732. /**
  25733. * The previous ratio of the runtime animation
  25734. */
  25735. private _previousRatio;
  25736. private _enableBlending;
  25737. private _keys;
  25738. private _minFrame;
  25739. private _maxFrame;
  25740. private _minValue;
  25741. private _maxValue;
  25742. private _targetIsArray;
  25743. /**
  25744. * Gets the current frame of the runtime animation
  25745. */
  25746. get currentFrame(): number;
  25747. /**
  25748. * Gets the weight of the runtime animation
  25749. */
  25750. get weight(): number;
  25751. /**
  25752. * Gets the current value of the runtime animation
  25753. */
  25754. get currentValue(): any;
  25755. /**
  25756. * Gets the target path of the runtime animation
  25757. */
  25758. get targetPath(): string;
  25759. /**
  25760. * Gets the actual target of the runtime animation
  25761. */
  25762. get target(): any;
  25763. /**
  25764. * Gets the additive state of the runtime animation
  25765. */
  25766. get isAdditive(): boolean;
  25767. /** @hidden */
  25768. _onLoop: () => void;
  25769. /**
  25770. * Create a new RuntimeAnimation object
  25771. * @param target defines the target of the animation
  25772. * @param animation defines the source animation object
  25773. * @param scene defines the hosting scene
  25774. * @param host defines the initiating Animatable
  25775. */
  25776. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25777. private _preparePath;
  25778. /**
  25779. * Gets the animation from the runtime animation
  25780. */
  25781. get animation(): Animation;
  25782. /**
  25783. * Resets the runtime animation to the beginning
  25784. * @param restoreOriginal defines whether to restore the target property to the original value
  25785. */
  25786. reset(restoreOriginal?: boolean): void;
  25787. /**
  25788. * Specifies if the runtime animation is stopped
  25789. * @returns Boolean specifying if the runtime animation is stopped
  25790. */
  25791. isStopped(): boolean;
  25792. /**
  25793. * Disposes of the runtime animation
  25794. */
  25795. dispose(): void;
  25796. /**
  25797. * Apply the interpolated value to the target
  25798. * @param currentValue defines the value computed by the animation
  25799. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25800. */
  25801. setValue(currentValue: any, weight: number): void;
  25802. private _getOriginalValues;
  25803. private _setValue;
  25804. /**
  25805. * Gets the loop pmode of the runtime animation
  25806. * @returns Loop Mode
  25807. */
  25808. private _getCorrectLoopMode;
  25809. /**
  25810. * Move the current animation to a given frame
  25811. * @param frame defines the frame to move to
  25812. */
  25813. goToFrame(frame: number): void;
  25814. /**
  25815. * @hidden Internal use only
  25816. */
  25817. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25818. /**
  25819. * Execute the current animation
  25820. * @param delay defines the delay to add to the current frame
  25821. * @param from defines the lower bound of the animation range
  25822. * @param to defines the upper bound of the animation range
  25823. * @param loop defines if the current animation must loop
  25824. * @param speedRatio defines the current speed ratio
  25825. * @param weight defines the weight of the animation (default is -1 so no weight)
  25826. * @param onLoop optional callback called when animation loops
  25827. * @returns a boolean indicating if the animation is running
  25828. */
  25829. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25830. }
  25831. }
  25832. declare module BABYLON {
  25833. /**
  25834. * Class used to store an actual running animation
  25835. */
  25836. export class Animatable {
  25837. /** defines the target object */
  25838. target: any;
  25839. /** defines the starting frame number (default is 0) */
  25840. fromFrame: number;
  25841. /** defines the ending frame number (default is 100) */
  25842. toFrame: number;
  25843. /** defines if the animation must loop (default is false) */
  25844. loopAnimation: boolean;
  25845. /** defines a callback to call when animation ends if it is not looping */
  25846. onAnimationEnd?: (() => void) | null | undefined;
  25847. /** defines a callback to call when animation loops */
  25848. onAnimationLoop?: (() => void) | null | undefined;
  25849. /** defines whether the animation should be evaluated additively */
  25850. isAdditive: boolean;
  25851. private _localDelayOffset;
  25852. private _pausedDelay;
  25853. private _runtimeAnimations;
  25854. private _paused;
  25855. private _scene;
  25856. private _speedRatio;
  25857. private _weight;
  25858. private _syncRoot;
  25859. /**
  25860. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25861. * This will only apply for non looping animation (default is true)
  25862. */
  25863. disposeOnEnd: boolean;
  25864. /**
  25865. * Gets a boolean indicating if the animation has started
  25866. */
  25867. animationStarted: boolean;
  25868. /**
  25869. * Observer raised when the animation ends
  25870. */
  25871. onAnimationEndObservable: Observable<Animatable>;
  25872. /**
  25873. * Observer raised when the animation loops
  25874. */
  25875. onAnimationLoopObservable: Observable<Animatable>;
  25876. /**
  25877. * Gets the root Animatable used to synchronize and normalize animations
  25878. */
  25879. get syncRoot(): Nullable<Animatable>;
  25880. /**
  25881. * Gets the current frame of the first RuntimeAnimation
  25882. * Used to synchronize Animatables
  25883. */
  25884. get masterFrame(): number;
  25885. /**
  25886. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25887. */
  25888. get weight(): number;
  25889. set weight(value: number);
  25890. /**
  25891. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25892. */
  25893. get speedRatio(): number;
  25894. set speedRatio(value: number);
  25895. /**
  25896. * Creates a new Animatable
  25897. * @param scene defines the hosting scene
  25898. * @param target defines the target object
  25899. * @param fromFrame defines the starting frame number (default is 0)
  25900. * @param toFrame defines the ending frame number (default is 100)
  25901. * @param loopAnimation defines if the animation must loop (default is false)
  25902. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25903. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25904. * @param animations defines a group of animation to add to the new Animatable
  25905. * @param onAnimationLoop defines a callback to call when animation loops
  25906. * @param isAdditive defines whether the animation should be evaluated additively
  25907. */
  25908. constructor(scene: Scene,
  25909. /** defines the target object */
  25910. target: any,
  25911. /** defines the starting frame number (default is 0) */
  25912. fromFrame?: number,
  25913. /** defines the ending frame number (default is 100) */
  25914. toFrame?: number,
  25915. /** defines if the animation must loop (default is false) */
  25916. loopAnimation?: boolean, speedRatio?: number,
  25917. /** defines a callback to call when animation ends if it is not looping */
  25918. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25919. /** defines a callback to call when animation loops */
  25920. onAnimationLoop?: (() => void) | null | undefined,
  25921. /** defines whether the animation should be evaluated additively */
  25922. isAdditive?: boolean);
  25923. /**
  25924. * Synchronize and normalize current Animatable with a source Animatable
  25925. * This is useful when using animation weights and when animations are not of the same length
  25926. * @param root defines the root Animatable to synchronize with
  25927. * @returns the current Animatable
  25928. */
  25929. syncWith(root: Animatable): Animatable;
  25930. /**
  25931. * Gets the list of runtime animations
  25932. * @returns an array of RuntimeAnimation
  25933. */
  25934. getAnimations(): RuntimeAnimation[];
  25935. /**
  25936. * Adds more animations to the current animatable
  25937. * @param target defines the target of the animations
  25938. * @param animations defines the new animations to add
  25939. */
  25940. appendAnimations(target: any, animations: Animation[]): void;
  25941. /**
  25942. * Gets the source animation for a specific property
  25943. * @param property defines the property to look for
  25944. * @returns null or the source animation for the given property
  25945. */
  25946. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25947. /**
  25948. * Gets the runtime animation for a specific property
  25949. * @param property defines the property to look for
  25950. * @returns null or the runtime animation for the given property
  25951. */
  25952. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25953. /**
  25954. * Resets the animatable to its original state
  25955. */
  25956. reset(): void;
  25957. /**
  25958. * Allows the animatable to blend with current running animations
  25959. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25960. * @param blendingSpeed defines the blending speed to use
  25961. */
  25962. enableBlending(blendingSpeed: number): void;
  25963. /**
  25964. * Disable animation blending
  25965. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25966. */
  25967. disableBlending(): void;
  25968. /**
  25969. * Jump directly to a given frame
  25970. * @param frame defines the frame to jump to
  25971. */
  25972. goToFrame(frame: number): void;
  25973. /**
  25974. * Pause the animation
  25975. */
  25976. pause(): void;
  25977. /**
  25978. * Restart the animation
  25979. */
  25980. restart(): void;
  25981. private _raiseOnAnimationEnd;
  25982. /**
  25983. * Stop and delete the current animation
  25984. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25985. * @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)
  25986. */
  25987. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25988. /**
  25989. * Wait asynchronously for the animation to end
  25990. * @returns a promise which will be fulfilled when the animation ends
  25991. */
  25992. waitAsync(): Promise<Animatable>;
  25993. /** @hidden */
  25994. _animate(delay: number): boolean;
  25995. }
  25996. interface Scene {
  25997. /** @hidden */
  25998. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25999. /** @hidden */
  26000. _processLateAnimationBindingsForMatrices(holder: {
  26001. totalWeight: number;
  26002. totalAdditiveWeight: number;
  26003. animations: RuntimeAnimation[];
  26004. additiveAnimations: RuntimeAnimation[];
  26005. originalValue: Matrix;
  26006. }): any;
  26007. /** @hidden */
  26008. _processLateAnimationBindingsForQuaternions(holder: {
  26009. totalWeight: number;
  26010. totalAdditiveWeight: number;
  26011. animations: RuntimeAnimation[];
  26012. additiveAnimations: RuntimeAnimation[];
  26013. originalValue: Quaternion;
  26014. }, refQuaternion: Quaternion): Quaternion;
  26015. /** @hidden */
  26016. _processLateAnimationBindings(): void;
  26017. /**
  26018. * Will start the animation sequence of a given target
  26019. * @param target defines the target
  26020. * @param from defines from which frame should animation start
  26021. * @param to defines until which frame should animation run.
  26022. * @param weight defines the weight to apply to the animation (1.0 by default)
  26023. * @param loop defines if the animation loops
  26024. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26025. * @param onAnimationEnd defines the function to be executed when the animation ends
  26026. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26027. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26028. * @param onAnimationLoop defines the callback to call when an animation loops
  26029. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26030. * @returns the animatable object created for this animation
  26031. */
  26032. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26033. /**
  26034. * Will start the animation sequence of a given target
  26035. * @param target defines the target
  26036. * @param from defines from which frame should animation start
  26037. * @param to defines until which frame should animation run.
  26038. * @param loop defines if the animation loops
  26039. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26040. * @param onAnimationEnd defines the function to be executed when the animation ends
  26041. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26042. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26043. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  26044. * @param onAnimationLoop defines the callback to call when an animation loops
  26045. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26046. * @returns the animatable object created for this animation
  26047. */
  26048. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26049. /**
  26050. * Will start the animation sequence of a given target and its hierarchy
  26051. * @param target defines the target
  26052. * @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.
  26053. * @param from defines from which frame should animation start
  26054. * @param to defines until which frame should animation run.
  26055. * @param loop defines if the animation loops
  26056. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26057. * @param onAnimationEnd defines the function to be executed when the animation ends
  26058. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26059. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26060. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26061. * @param onAnimationLoop defines the callback to call when an animation loops
  26062. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26063. * @returns the list of created animatables
  26064. */
  26065. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26066. /**
  26067. * Begin a new animation on a given node
  26068. * @param target defines the target where the animation will take place
  26069. * @param animations defines the list of animations to start
  26070. * @param from defines the initial value
  26071. * @param to defines the final value
  26072. * @param loop defines if you want animation to loop (off by default)
  26073. * @param speedRatio defines the speed ratio to apply to all animations
  26074. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26075. * @param onAnimationLoop defines the callback to call when an animation loops
  26076. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26077. * @returns the list of created animatables
  26078. */
  26079. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26080. /**
  26081. * Begin a new animation on a given node and its hierarchy
  26082. * @param target defines the root node where the animation will take place
  26083. * @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.
  26084. * @param animations defines the list of animations to start
  26085. * @param from defines the initial value
  26086. * @param to defines the final value
  26087. * @param loop defines if you want animation to loop (off by default)
  26088. * @param speedRatio defines the speed ratio to apply to all animations
  26089. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26090. * @param onAnimationLoop defines the callback to call when an animation loops
  26091. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26092. * @returns the list of animatables created for all nodes
  26093. */
  26094. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26095. /**
  26096. * Gets the animatable associated with a specific target
  26097. * @param target defines the target of the animatable
  26098. * @returns the required animatable if found
  26099. */
  26100. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26101. /**
  26102. * Gets all animatables associated with a given target
  26103. * @param target defines the target to look animatables for
  26104. * @returns an array of Animatables
  26105. */
  26106. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26107. /**
  26108. * Stops and removes all animations that have been applied to the scene
  26109. */
  26110. stopAllAnimations(): void;
  26111. /**
  26112. * Gets the current delta time used by animation engine
  26113. */
  26114. deltaTime: number;
  26115. }
  26116. interface Bone {
  26117. /**
  26118. * Copy an animation range from another bone
  26119. * @param source defines the source bone
  26120. * @param rangeName defines the range name to copy
  26121. * @param frameOffset defines the frame offset
  26122. * @param rescaleAsRequired defines if rescaling must be applied if required
  26123. * @param skelDimensionsRatio defines the scaling ratio
  26124. * @returns true if operation was successful
  26125. */
  26126. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26127. }
  26128. }
  26129. declare module BABYLON {
  26130. /**
  26131. * Class used to override all child animations of a given target
  26132. */
  26133. export class AnimationPropertiesOverride {
  26134. /**
  26135. * Gets or sets a value indicating if animation blending must be used
  26136. */
  26137. enableBlending: boolean;
  26138. /**
  26139. * Gets or sets the blending speed to use when enableBlending is true
  26140. */
  26141. blendingSpeed: number;
  26142. /**
  26143. * Gets or sets the default loop mode to use
  26144. */
  26145. loopMode: number;
  26146. }
  26147. }
  26148. declare module BABYLON {
  26149. /**
  26150. * Class used to handle skinning animations
  26151. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26152. */
  26153. export class Skeleton implements IAnimatable {
  26154. /** defines the skeleton name */
  26155. name: string;
  26156. /** defines the skeleton Id */
  26157. id: string;
  26158. /**
  26159. * Defines the list of child bones
  26160. */
  26161. bones: Bone[];
  26162. /**
  26163. * Defines an estimate of the dimension of the skeleton at rest
  26164. */
  26165. dimensionsAtRest: Vector3;
  26166. /**
  26167. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26168. */
  26169. needInitialSkinMatrix: boolean;
  26170. /**
  26171. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26172. */
  26173. overrideMesh: Nullable<AbstractMesh>;
  26174. /**
  26175. * Gets the list of animations attached to this skeleton
  26176. */
  26177. animations: Array<Animation>;
  26178. private _scene;
  26179. private _isDirty;
  26180. private _transformMatrices;
  26181. private _transformMatrixTexture;
  26182. private _meshesWithPoseMatrix;
  26183. private _animatables;
  26184. private _identity;
  26185. private _synchronizedWithMesh;
  26186. private _ranges;
  26187. private _lastAbsoluteTransformsUpdateId;
  26188. private _canUseTextureForBones;
  26189. private _uniqueId;
  26190. /** @hidden */
  26191. _numBonesWithLinkedTransformNode: number;
  26192. /** @hidden */
  26193. _hasWaitingData: Nullable<boolean>;
  26194. /** @hidden */
  26195. _waitingOverrideMeshId: Nullable<string>;
  26196. /**
  26197. * Specifies if the skeleton should be serialized
  26198. */
  26199. doNotSerialize: boolean;
  26200. private _useTextureToStoreBoneMatrices;
  26201. /**
  26202. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26203. * Please note that this option is not available if the hardware does not support it
  26204. */
  26205. get useTextureToStoreBoneMatrices(): boolean;
  26206. set useTextureToStoreBoneMatrices(value: boolean);
  26207. private _animationPropertiesOverride;
  26208. /**
  26209. * Gets or sets the animation properties override
  26210. */
  26211. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26212. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26213. /**
  26214. * List of inspectable custom properties (used by the Inspector)
  26215. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26216. */
  26217. inspectableCustomProperties: IInspectable[];
  26218. /**
  26219. * An observable triggered before computing the skeleton's matrices
  26220. */
  26221. onBeforeComputeObservable: Observable<Skeleton>;
  26222. /**
  26223. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26224. */
  26225. get isUsingTextureForMatrices(): boolean;
  26226. /**
  26227. * Gets the unique ID of this skeleton
  26228. */
  26229. get uniqueId(): number;
  26230. /**
  26231. * Creates a new skeleton
  26232. * @param name defines the skeleton name
  26233. * @param id defines the skeleton Id
  26234. * @param scene defines the hosting scene
  26235. */
  26236. constructor(
  26237. /** defines the skeleton name */
  26238. name: string,
  26239. /** defines the skeleton Id */
  26240. id: string, scene: Scene);
  26241. /**
  26242. * Gets the current object class name.
  26243. * @return the class name
  26244. */
  26245. getClassName(): string;
  26246. /**
  26247. * Returns an array containing the root bones
  26248. * @returns an array containing the root bones
  26249. */
  26250. getChildren(): Array<Bone>;
  26251. /**
  26252. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26253. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26254. * @returns a Float32Array containing matrices data
  26255. */
  26256. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26257. /**
  26258. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26259. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26260. * @returns a raw texture containing the data
  26261. */
  26262. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26263. /**
  26264. * Gets the current hosting scene
  26265. * @returns a scene object
  26266. */
  26267. getScene(): Scene;
  26268. /**
  26269. * Gets a string representing the current skeleton data
  26270. * @param fullDetails defines a boolean indicating if we want a verbose version
  26271. * @returns a string representing the current skeleton data
  26272. */
  26273. toString(fullDetails?: boolean): string;
  26274. /**
  26275. * Get bone's index searching by name
  26276. * @param name defines bone's name to search for
  26277. * @return the indice of the bone. Returns -1 if not found
  26278. */
  26279. getBoneIndexByName(name: string): number;
  26280. /**
  26281. * Create a new animation range
  26282. * @param name defines the name of the range
  26283. * @param from defines the start key
  26284. * @param to defines the end key
  26285. */
  26286. createAnimationRange(name: string, from: number, to: number): void;
  26287. /**
  26288. * Delete a specific animation range
  26289. * @param name defines the name of the range
  26290. * @param deleteFrames defines if frames must be removed as well
  26291. */
  26292. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26293. /**
  26294. * Gets a specific animation range
  26295. * @param name defines the name of the range to look for
  26296. * @returns the requested animation range or null if not found
  26297. */
  26298. getAnimationRange(name: string): Nullable<AnimationRange>;
  26299. /**
  26300. * Gets the list of all animation ranges defined on this skeleton
  26301. * @returns an array
  26302. */
  26303. getAnimationRanges(): Nullable<AnimationRange>[];
  26304. /**
  26305. * Copy animation range from a source skeleton.
  26306. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26307. * @param source defines the source skeleton
  26308. * @param name defines the name of the range to copy
  26309. * @param rescaleAsRequired defines if rescaling must be applied if required
  26310. * @returns true if operation was successful
  26311. */
  26312. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26313. /**
  26314. * Forces the skeleton to go to rest pose
  26315. */
  26316. returnToRest(): void;
  26317. private _getHighestAnimationFrame;
  26318. /**
  26319. * Begin a specific animation range
  26320. * @param name defines the name of the range to start
  26321. * @param loop defines if looping must be turned on (false by default)
  26322. * @param speedRatio defines the speed ratio to apply (1 by default)
  26323. * @param onAnimationEnd defines a callback which will be called when animation will end
  26324. * @returns a new animatable
  26325. */
  26326. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26327. /**
  26328. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26329. * @param skeleton defines the Skeleton containing the animation range to convert
  26330. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26331. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26332. * @returns the original skeleton
  26333. */
  26334. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26335. /** @hidden */
  26336. _markAsDirty(): void;
  26337. /** @hidden */
  26338. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26339. /** @hidden */
  26340. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26341. private _computeTransformMatrices;
  26342. /**
  26343. * Build all resources required to render a skeleton
  26344. */
  26345. prepare(): void;
  26346. /**
  26347. * Gets the list of animatables currently running for this skeleton
  26348. * @returns an array of animatables
  26349. */
  26350. getAnimatables(): IAnimatable[];
  26351. /**
  26352. * Clone the current skeleton
  26353. * @param name defines the name of the new skeleton
  26354. * @param id defines the id of the new skeleton
  26355. * @returns the new skeleton
  26356. */
  26357. clone(name: string, id?: string): Skeleton;
  26358. /**
  26359. * Enable animation blending for this skeleton
  26360. * @param blendingSpeed defines the blending speed to apply
  26361. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26362. */
  26363. enableBlending(blendingSpeed?: number): void;
  26364. /**
  26365. * Releases all resources associated with the current skeleton
  26366. */
  26367. dispose(): void;
  26368. /**
  26369. * Serialize the skeleton in a JSON object
  26370. * @returns a JSON object
  26371. */
  26372. serialize(): any;
  26373. /**
  26374. * Creates a new skeleton from serialized data
  26375. * @param parsedSkeleton defines the serialized data
  26376. * @param scene defines the hosting scene
  26377. * @returns a new skeleton
  26378. */
  26379. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26380. /**
  26381. * Compute all node absolute transforms
  26382. * @param forceUpdate defines if computation must be done even if cache is up to date
  26383. */
  26384. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26385. /**
  26386. * Gets the root pose matrix
  26387. * @returns a matrix
  26388. */
  26389. getPoseMatrix(): Nullable<Matrix>;
  26390. /**
  26391. * Sorts bones per internal index
  26392. */
  26393. sortBones(): void;
  26394. private _sortBones;
  26395. /**
  26396. * Set the current local matrix as the restPose for all bones in the skeleton.
  26397. */
  26398. setCurrentPoseAsRest(): void;
  26399. }
  26400. }
  26401. declare module BABYLON {
  26402. /**
  26403. * Class used to store bone information
  26404. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26405. */
  26406. export class Bone extends Node {
  26407. /**
  26408. * defines the bone name
  26409. */
  26410. name: string;
  26411. private static _tmpVecs;
  26412. private static _tmpQuat;
  26413. private static _tmpMats;
  26414. /**
  26415. * Gets the list of child bones
  26416. */
  26417. children: Bone[];
  26418. /** Gets the animations associated with this bone */
  26419. animations: Animation[];
  26420. /**
  26421. * Gets or sets bone length
  26422. */
  26423. length: number;
  26424. /**
  26425. * @hidden Internal only
  26426. * Set this value to map this bone to a different index in the transform matrices
  26427. * Set this value to -1 to exclude the bone from the transform matrices
  26428. */
  26429. _index: Nullable<number>;
  26430. private _skeleton;
  26431. private _localMatrix;
  26432. private _restPose;
  26433. private _bindPose;
  26434. private _baseMatrix;
  26435. private _absoluteTransform;
  26436. private _invertedAbsoluteTransform;
  26437. private _parent;
  26438. private _scalingDeterminant;
  26439. private _worldTransform;
  26440. private _localScaling;
  26441. private _localRotation;
  26442. private _localPosition;
  26443. private _needToDecompose;
  26444. private _needToCompose;
  26445. /** @hidden */
  26446. _linkedTransformNode: Nullable<TransformNode>;
  26447. /** @hidden */
  26448. _waitingTransformNodeId: Nullable<string>;
  26449. /** @hidden */
  26450. get _matrix(): Matrix;
  26451. /** @hidden */
  26452. set _matrix(value: Matrix);
  26453. /**
  26454. * Create a new bone
  26455. * @param name defines the bone name
  26456. * @param skeleton defines the parent skeleton
  26457. * @param parentBone defines the parent (can be null if the bone is the root)
  26458. * @param localMatrix defines the local matrix
  26459. * @param restPose defines the rest pose matrix
  26460. * @param baseMatrix defines the base matrix
  26461. * @param index defines index of the bone in the hierarchy
  26462. */
  26463. constructor(
  26464. /**
  26465. * defines the bone name
  26466. */
  26467. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26468. /**
  26469. * Gets the current object class name.
  26470. * @return the class name
  26471. */
  26472. getClassName(): string;
  26473. /**
  26474. * Gets the parent skeleton
  26475. * @returns a skeleton
  26476. */
  26477. getSkeleton(): Skeleton;
  26478. /**
  26479. * Gets parent bone
  26480. * @returns a bone or null if the bone is the root of the bone hierarchy
  26481. */
  26482. getParent(): Nullable<Bone>;
  26483. /**
  26484. * Returns an array containing the root bones
  26485. * @returns an array containing the root bones
  26486. */
  26487. getChildren(): Array<Bone>;
  26488. /**
  26489. * Gets the node index in matrix array generated for rendering
  26490. * @returns the node index
  26491. */
  26492. getIndex(): number;
  26493. /**
  26494. * Sets the parent bone
  26495. * @param parent defines the parent (can be null if the bone is the root)
  26496. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26497. */
  26498. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26499. /**
  26500. * Gets the local matrix
  26501. * @returns a matrix
  26502. */
  26503. getLocalMatrix(): Matrix;
  26504. /**
  26505. * Gets the base matrix (initial matrix which remains unchanged)
  26506. * @returns a matrix
  26507. */
  26508. getBaseMatrix(): Matrix;
  26509. /**
  26510. * Gets the rest pose matrix
  26511. * @returns a matrix
  26512. */
  26513. getRestPose(): Matrix;
  26514. /**
  26515. * Sets the rest pose matrix
  26516. * @param matrix the local-space rest pose to set for this bone
  26517. */
  26518. setRestPose(matrix: Matrix): void;
  26519. /**
  26520. * Gets the bind pose matrix
  26521. * @returns the bind pose matrix
  26522. */
  26523. getBindPose(): Matrix;
  26524. /**
  26525. * Sets the bind pose matrix
  26526. * @param matrix the local-space bind pose to set for this bone
  26527. */
  26528. setBindPose(matrix: Matrix): void;
  26529. /**
  26530. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26531. */
  26532. getWorldMatrix(): Matrix;
  26533. /**
  26534. * Sets the local matrix to rest pose matrix
  26535. */
  26536. returnToRest(): void;
  26537. /**
  26538. * Gets the inverse of the absolute transform matrix.
  26539. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26540. * @returns a matrix
  26541. */
  26542. getInvertedAbsoluteTransform(): Matrix;
  26543. /**
  26544. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26545. * @returns a matrix
  26546. */
  26547. getAbsoluteTransform(): Matrix;
  26548. /**
  26549. * Links with the given transform node.
  26550. * The local matrix of this bone is copied from the transform node every frame.
  26551. * @param transformNode defines the transform node to link to
  26552. */
  26553. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26554. /**
  26555. * Gets the node used to drive the bone's transformation
  26556. * @returns a transform node or null
  26557. */
  26558. getTransformNode(): Nullable<TransformNode>;
  26559. /** Gets or sets current position (in local space) */
  26560. get position(): Vector3;
  26561. set position(newPosition: Vector3);
  26562. /** Gets or sets current rotation (in local space) */
  26563. get rotation(): Vector3;
  26564. set rotation(newRotation: Vector3);
  26565. /** Gets or sets current rotation quaternion (in local space) */
  26566. get rotationQuaternion(): Quaternion;
  26567. set rotationQuaternion(newRotation: Quaternion);
  26568. /** Gets or sets current scaling (in local space) */
  26569. get scaling(): Vector3;
  26570. set scaling(newScaling: Vector3);
  26571. /**
  26572. * Gets the animation properties override
  26573. */
  26574. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26575. private _decompose;
  26576. private _compose;
  26577. /**
  26578. * Update the base and local matrices
  26579. * @param matrix defines the new base or local matrix
  26580. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26581. * @param updateLocalMatrix defines if the local matrix should be updated
  26582. */
  26583. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26584. /** @hidden */
  26585. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26586. /**
  26587. * Flag the bone as dirty (Forcing it to update everything)
  26588. */
  26589. markAsDirty(): void;
  26590. /** @hidden */
  26591. _markAsDirtyAndCompose(): void;
  26592. private _markAsDirtyAndDecompose;
  26593. /**
  26594. * Translate the bone in local or world space
  26595. * @param vec The amount to translate the bone
  26596. * @param space The space that the translation is in
  26597. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26598. */
  26599. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26600. /**
  26601. * Set the position of the bone in local or world space
  26602. * @param position The position to set the bone
  26603. * @param space The space that the position is in
  26604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26605. */
  26606. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26607. /**
  26608. * Set the absolute position of the bone (world space)
  26609. * @param position The position to set the bone
  26610. * @param mesh The mesh that this bone is attached to
  26611. */
  26612. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26613. /**
  26614. * Scale the bone on the x, y and z axes (in local space)
  26615. * @param x The amount to scale the bone on the x axis
  26616. * @param y The amount to scale the bone on the y axis
  26617. * @param z The amount to scale the bone on the z axis
  26618. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26619. */
  26620. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26621. /**
  26622. * Set the bone scaling in local space
  26623. * @param scale defines the scaling vector
  26624. */
  26625. setScale(scale: Vector3): void;
  26626. /**
  26627. * Gets the current scaling in local space
  26628. * @returns the current scaling vector
  26629. */
  26630. getScale(): Vector3;
  26631. /**
  26632. * Gets the current scaling in local space and stores it in a target vector
  26633. * @param result defines the target vector
  26634. */
  26635. getScaleToRef(result: Vector3): void;
  26636. /**
  26637. * Set the yaw, pitch, and roll of the bone in local or world space
  26638. * @param yaw The rotation of the bone on the y axis
  26639. * @param pitch The rotation of the bone on the x axis
  26640. * @param roll The rotation of the bone on the z axis
  26641. * @param space The space that the axes of rotation are in
  26642. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26643. */
  26644. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26645. /**
  26646. * Add a rotation to the bone on an axis in local or world space
  26647. * @param axis The axis to rotate the bone on
  26648. * @param amount The amount to rotate the bone
  26649. * @param space The space that the axis is in
  26650. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26651. */
  26652. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26653. /**
  26654. * Set the rotation of the bone to a particular axis angle in local or world space
  26655. * @param axis The axis to rotate the bone on
  26656. * @param angle The angle that the bone should be rotated to
  26657. * @param space The space that the axis is in
  26658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26659. */
  26660. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26661. /**
  26662. * Set the euler rotation of the bone in local or world space
  26663. * @param rotation The euler rotation that the bone should be set to
  26664. * @param space The space that the rotation is in
  26665. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26666. */
  26667. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26668. /**
  26669. * Set the quaternion rotation of the bone in local or world space
  26670. * @param quat The quaternion rotation that the bone should be set to
  26671. * @param space The space that the rotation is in
  26672. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26673. */
  26674. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26675. /**
  26676. * Set the rotation matrix of the bone in local or world space
  26677. * @param rotMat The rotation matrix that the bone should be set to
  26678. * @param space The space that the rotation is in
  26679. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26680. */
  26681. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26682. private _rotateWithMatrix;
  26683. private _getNegativeRotationToRef;
  26684. /**
  26685. * Get the position of the bone in local or world space
  26686. * @param space The space that the returned position is in
  26687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26688. * @returns The position of the bone
  26689. */
  26690. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26691. /**
  26692. * Copy the position of the bone to a vector3 in local or world space
  26693. * @param space The space that the returned position is in
  26694. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26695. * @param result The vector3 to copy the position to
  26696. */
  26697. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26698. /**
  26699. * Get the absolute position of the bone (world space)
  26700. * @param mesh The mesh that this bone is attached to
  26701. * @returns The absolute position of the bone
  26702. */
  26703. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26704. /**
  26705. * Copy the absolute position of the bone (world space) to the result param
  26706. * @param mesh The mesh that this bone is attached to
  26707. * @param result The vector3 to copy the absolute position to
  26708. */
  26709. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26710. /**
  26711. * Compute the absolute transforms of this bone and its children
  26712. */
  26713. computeAbsoluteTransforms(): void;
  26714. /**
  26715. * Get the world direction from an axis that is in the local space of the bone
  26716. * @param localAxis The local direction that is used to compute the world direction
  26717. * @param mesh The mesh that this bone is attached to
  26718. * @returns The world direction
  26719. */
  26720. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26721. /**
  26722. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26723. * @param localAxis The local direction that is used to compute the world direction
  26724. * @param mesh The mesh that this bone is attached to
  26725. * @param result The vector3 that the world direction will be copied to
  26726. */
  26727. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26728. /**
  26729. * Get the euler rotation of the bone in local or world space
  26730. * @param space The space that the rotation should be in
  26731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26732. * @returns The euler rotation
  26733. */
  26734. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26735. /**
  26736. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26737. * @param space The space that the rotation should be in
  26738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26739. * @param result The vector3 that the rotation should be copied to
  26740. */
  26741. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26742. /**
  26743. * Get the quaternion rotation of the bone in either local or world space
  26744. * @param space The space that the rotation should be in
  26745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26746. * @returns The quaternion rotation
  26747. */
  26748. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26749. /**
  26750. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26751. * @param space The space that the rotation should be in
  26752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26753. * @param result The quaternion that the rotation should be copied to
  26754. */
  26755. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26756. /**
  26757. * Get the rotation matrix of the bone in local or world space
  26758. * @param space The space that the rotation should be in
  26759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26760. * @returns The rotation matrix
  26761. */
  26762. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26763. /**
  26764. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26765. * @param space The space that the rotation should be in
  26766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26767. * @param result The quaternion that the rotation should be copied to
  26768. */
  26769. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26770. /**
  26771. * Get the world position of a point that is in the local space of the bone
  26772. * @param position The local position
  26773. * @param mesh The mesh that this bone is attached to
  26774. * @returns The world position
  26775. */
  26776. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26777. /**
  26778. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26779. * @param position The local position
  26780. * @param mesh The mesh that this bone is attached to
  26781. * @param result The vector3 that the world position should be copied to
  26782. */
  26783. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26784. /**
  26785. * Get the local position of a point that is in world space
  26786. * @param position The world position
  26787. * @param mesh The mesh that this bone is attached to
  26788. * @returns The local position
  26789. */
  26790. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26791. /**
  26792. * Get the local position of a point that is in world space and copy it to the result param
  26793. * @param position The world position
  26794. * @param mesh The mesh that this bone is attached to
  26795. * @param result The vector3 that the local position should be copied to
  26796. */
  26797. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26798. /**
  26799. * Set the current local matrix as the restPose for this bone.
  26800. */
  26801. setCurrentPoseAsRest(): void;
  26802. }
  26803. }
  26804. declare module BABYLON {
  26805. /**
  26806. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  26807. * @see https://doc.babylonjs.com/how_to/transformnode
  26808. */
  26809. export class TransformNode extends Node {
  26810. /**
  26811. * Object will not rotate to face the camera
  26812. */
  26813. static BILLBOARDMODE_NONE: number;
  26814. /**
  26815. * Object will rotate to face the camera but only on the x axis
  26816. */
  26817. static BILLBOARDMODE_X: number;
  26818. /**
  26819. * Object will rotate to face the camera but only on the y axis
  26820. */
  26821. static BILLBOARDMODE_Y: number;
  26822. /**
  26823. * Object will rotate to face the camera but only on the z axis
  26824. */
  26825. static BILLBOARDMODE_Z: number;
  26826. /**
  26827. * Object will rotate to face the camera
  26828. */
  26829. static BILLBOARDMODE_ALL: number;
  26830. /**
  26831. * Object will rotate to face the camera's position instead of orientation
  26832. */
  26833. static BILLBOARDMODE_USE_POSITION: number;
  26834. private static _TmpRotation;
  26835. private static _TmpScaling;
  26836. private static _TmpTranslation;
  26837. private _forward;
  26838. private _forwardInverted;
  26839. private _up;
  26840. private _right;
  26841. private _rightInverted;
  26842. private _position;
  26843. private _rotation;
  26844. private _rotationQuaternion;
  26845. protected _scaling: Vector3;
  26846. protected _isDirty: boolean;
  26847. private _transformToBoneReferal;
  26848. private _isAbsoluteSynced;
  26849. private _billboardMode;
  26850. /**
  26851. * Gets or sets the billboard mode. Default is 0.
  26852. *
  26853. * | Value | Type | Description |
  26854. * | --- | --- | --- |
  26855. * | 0 | BILLBOARDMODE_NONE | |
  26856. * | 1 | BILLBOARDMODE_X | |
  26857. * | 2 | BILLBOARDMODE_Y | |
  26858. * | 4 | BILLBOARDMODE_Z | |
  26859. * | 7 | BILLBOARDMODE_ALL | |
  26860. *
  26861. */
  26862. get billboardMode(): number;
  26863. set billboardMode(value: number);
  26864. private _preserveParentRotationForBillboard;
  26865. /**
  26866. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26867. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26868. */
  26869. get preserveParentRotationForBillboard(): boolean;
  26870. set preserveParentRotationForBillboard(value: boolean);
  26871. /**
  26872. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  26873. */
  26874. scalingDeterminant: number;
  26875. private _infiniteDistance;
  26876. /**
  26877. * Gets or sets the distance of the object to max, often used by skybox
  26878. */
  26879. get infiniteDistance(): boolean;
  26880. set infiniteDistance(value: boolean);
  26881. /**
  26882. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26883. * By default the system will update normals to compensate
  26884. */
  26885. ignoreNonUniformScaling: boolean;
  26886. /**
  26887. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  26888. */
  26889. reIntegrateRotationIntoRotationQuaternion: boolean;
  26890. /** @hidden */
  26891. _poseMatrix: Nullable<Matrix>;
  26892. /** @hidden */
  26893. _localMatrix: Matrix;
  26894. private _usePivotMatrix;
  26895. private _absolutePosition;
  26896. private _absoluteScaling;
  26897. private _absoluteRotationQuaternion;
  26898. private _pivotMatrix;
  26899. private _pivotMatrixInverse;
  26900. /** @hidden */
  26901. _postMultiplyPivotMatrix: boolean;
  26902. protected _isWorldMatrixFrozen: boolean;
  26903. /** @hidden */
  26904. _indexInSceneTransformNodesArray: number;
  26905. /**
  26906. * An event triggered after the world matrix is updated
  26907. */
  26908. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26909. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26910. /**
  26911. * Gets a string identifying the name of the class
  26912. * @returns "TransformNode" string
  26913. */
  26914. getClassName(): string;
  26915. /**
  26916. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26917. */
  26918. get position(): Vector3;
  26919. set position(newPosition: Vector3);
  26920. /**
  26921. * 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)).
  26922. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26923. */
  26924. get rotation(): Vector3;
  26925. set rotation(newRotation: Vector3);
  26926. /**
  26927. * 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)).
  26928. */
  26929. get scaling(): Vector3;
  26930. set scaling(newScaling: Vector3);
  26931. /**
  26932. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  26933. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26934. */
  26935. get rotationQuaternion(): Nullable<Quaternion>;
  26936. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26937. /**
  26938. * The forward direction of that transform in world space.
  26939. */
  26940. get forward(): Vector3;
  26941. /**
  26942. * The up direction of that transform in world space.
  26943. */
  26944. get up(): Vector3;
  26945. /**
  26946. * The right direction of that transform in world space.
  26947. */
  26948. get right(): Vector3;
  26949. /**
  26950. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26951. * @param matrix the matrix to copy the pose from
  26952. * @returns this TransformNode.
  26953. */
  26954. updatePoseMatrix(matrix: Matrix): TransformNode;
  26955. /**
  26956. * Returns the mesh Pose matrix.
  26957. * @returns the pose matrix
  26958. */
  26959. getPoseMatrix(): Matrix;
  26960. /** @hidden */
  26961. _isSynchronized(): boolean;
  26962. /** @hidden */
  26963. _initCache(): void;
  26964. /**
  26965. * Flag the transform node as dirty (Forcing it to update everything)
  26966. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26967. * @returns this transform node
  26968. */
  26969. markAsDirty(property: string): TransformNode;
  26970. /**
  26971. * Returns the current mesh absolute position.
  26972. * Returns a Vector3.
  26973. */
  26974. get absolutePosition(): Vector3;
  26975. /**
  26976. * Returns the current mesh absolute scaling.
  26977. * Returns a Vector3.
  26978. */
  26979. get absoluteScaling(): Vector3;
  26980. /**
  26981. * Returns the current mesh absolute rotation.
  26982. * Returns a Quaternion.
  26983. */
  26984. get absoluteRotationQuaternion(): Quaternion;
  26985. /**
  26986. * Sets a new matrix to apply before all other transformation
  26987. * @param matrix defines the transform matrix
  26988. * @returns the current TransformNode
  26989. */
  26990. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26991. /**
  26992. * Sets a new pivot matrix to the current node
  26993. * @param matrix defines the new pivot matrix to use
  26994. * @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
  26995. * @returns the current TransformNode
  26996. */
  26997. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26998. /**
  26999. * Returns the mesh pivot matrix.
  27000. * Default : Identity.
  27001. * @returns the matrix
  27002. */
  27003. getPivotMatrix(): Matrix;
  27004. /**
  27005. * Instantiate (when possible) or clone that node with its hierarchy
  27006. * @param newParent defines the new parent to use for the instance (or clone)
  27007. * @param options defines options to configure how copy is done
  27008. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  27009. * @returns an instance (or a clone) of the current node with its hiearchy
  27010. */
  27011. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27012. doNotInstantiate: boolean;
  27013. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27014. /**
  27015. * Prevents the World matrix to be computed any longer
  27016. * @param newWorldMatrix defines an optional matrix to use as world matrix
  27017. * @returns the TransformNode.
  27018. */
  27019. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27020. /**
  27021. * Allows back the World matrix computation.
  27022. * @returns the TransformNode.
  27023. */
  27024. unfreezeWorldMatrix(): this;
  27025. /**
  27026. * True if the World matrix has been frozen.
  27027. */
  27028. get isWorldMatrixFrozen(): boolean;
  27029. /**
  27030. * Returns the mesh absolute position in the World.
  27031. * @returns a Vector3.
  27032. */
  27033. getAbsolutePosition(): Vector3;
  27034. /**
  27035. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27036. * @param absolutePosition the absolute position to set
  27037. * @returns the TransformNode.
  27038. */
  27039. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27040. /**
  27041. * Sets the mesh position in its local space.
  27042. * @param vector3 the position to set in localspace
  27043. * @returns the TransformNode.
  27044. */
  27045. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27046. /**
  27047. * Returns the mesh position in the local space from the current World matrix values.
  27048. * @returns a new Vector3.
  27049. */
  27050. getPositionExpressedInLocalSpace(): Vector3;
  27051. /**
  27052. * Translates the mesh along the passed Vector3 in its local space.
  27053. * @param vector3 the distance to translate in localspace
  27054. * @returns the TransformNode.
  27055. */
  27056. locallyTranslate(vector3: Vector3): TransformNode;
  27057. private static _lookAtVectorCache;
  27058. /**
  27059. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27060. * @param targetPoint the position (must be in same space as current mesh) to look at
  27061. * @param yawCor optional yaw (y-axis) correction in radians
  27062. * @param pitchCor optional pitch (x-axis) correction in radians
  27063. * @param rollCor optional roll (z-axis) correction in radians
  27064. * @param space the chosen space of the target
  27065. * @returns the TransformNode.
  27066. */
  27067. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27068. /**
  27069. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27070. * This Vector3 is expressed in the World space.
  27071. * @param localAxis axis to rotate
  27072. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27073. */
  27074. getDirection(localAxis: Vector3): Vector3;
  27075. /**
  27076. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27077. * localAxis is expressed in the mesh local space.
  27078. * result is computed in the Wordl space from the mesh World matrix.
  27079. * @param localAxis axis to rotate
  27080. * @param result the resulting transformnode
  27081. * @returns this TransformNode.
  27082. */
  27083. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27084. /**
  27085. * Sets this transform node rotation to the given local axis.
  27086. * @param localAxis the axis in local space
  27087. * @param yawCor optional yaw (y-axis) correction in radians
  27088. * @param pitchCor optional pitch (x-axis) correction in radians
  27089. * @param rollCor optional roll (z-axis) correction in radians
  27090. * @returns this TransformNode
  27091. */
  27092. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27093. /**
  27094. * Sets a new pivot point to the current node
  27095. * @param point defines the new pivot point to use
  27096. * @param space defines if the point is in world or local space (local by default)
  27097. * @returns the current TransformNode
  27098. */
  27099. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27100. /**
  27101. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27102. * @returns the pivot point
  27103. */
  27104. getPivotPoint(): Vector3;
  27105. /**
  27106. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27107. * @param result the vector3 to store the result
  27108. * @returns this TransformNode.
  27109. */
  27110. getPivotPointToRef(result: Vector3): TransformNode;
  27111. /**
  27112. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27113. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27114. */
  27115. getAbsolutePivotPoint(): Vector3;
  27116. /**
  27117. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27118. * @param result vector3 to store the result
  27119. * @returns this TransformNode.
  27120. */
  27121. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27122. /**
  27123. * Defines the passed node as the parent of the current node.
  27124. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27125. * @see https://doc.babylonjs.com/how_to/parenting
  27126. * @param node the node ot set as the parent
  27127. * @returns this TransformNode.
  27128. */
  27129. setParent(node: Nullable<Node>): TransformNode;
  27130. private _nonUniformScaling;
  27131. /**
  27132. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27133. */
  27134. get nonUniformScaling(): boolean;
  27135. /** @hidden */
  27136. _updateNonUniformScalingState(value: boolean): boolean;
  27137. /**
  27138. * Attach the current TransformNode to another TransformNode associated with a bone
  27139. * @param bone Bone affecting the TransformNode
  27140. * @param affectedTransformNode TransformNode associated with the bone
  27141. * @returns this object
  27142. */
  27143. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27144. /**
  27145. * Detach the transform node if its associated with a bone
  27146. * @returns this object
  27147. */
  27148. detachFromBone(): TransformNode;
  27149. private static _rotationAxisCache;
  27150. /**
  27151. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27152. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27153. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27154. * The passed axis is also normalized.
  27155. * @param axis the axis to rotate around
  27156. * @param amount the amount to rotate in radians
  27157. * @param space Space to rotate in (Default: local)
  27158. * @returns the TransformNode.
  27159. */
  27160. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27161. /**
  27162. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27163. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27164. * The passed axis is also normalized. .
  27165. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27166. * @param point the point to rotate around
  27167. * @param axis the axis to rotate around
  27168. * @param amount the amount to rotate in radians
  27169. * @returns the TransformNode
  27170. */
  27171. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27172. /**
  27173. * Translates the mesh along the axis vector for the passed distance in the given space.
  27174. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27175. * @param axis the axis to translate in
  27176. * @param distance the distance to translate
  27177. * @param space Space to rotate in (Default: local)
  27178. * @returns the TransformNode.
  27179. */
  27180. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27181. /**
  27182. * Adds a rotation step to the mesh current rotation.
  27183. * x, y, z are Euler angles expressed in radians.
  27184. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27185. * This means this rotation is made in the mesh local space only.
  27186. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27187. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27188. * ```javascript
  27189. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27190. * ```
  27191. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27192. * 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.
  27193. * @param x Rotation to add
  27194. * @param y Rotation to add
  27195. * @param z Rotation to add
  27196. * @returns the TransformNode.
  27197. */
  27198. addRotation(x: number, y: number, z: number): TransformNode;
  27199. /**
  27200. * @hidden
  27201. */
  27202. protected _getEffectiveParent(): Nullable<Node>;
  27203. /**
  27204. * Computes the world matrix of the node
  27205. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27206. * @returns the world matrix
  27207. */
  27208. computeWorldMatrix(force?: boolean): Matrix;
  27209. /**
  27210. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27211. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27212. */
  27213. resetLocalMatrix(independentOfChildren?: boolean): void;
  27214. protected _afterComputeWorldMatrix(): void;
  27215. /**
  27216. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27217. * @param func callback function to add
  27218. *
  27219. * @returns the TransformNode.
  27220. */
  27221. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27222. /**
  27223. * Removes a registered callback function.
  27224. * @param func callback function to remove
  27225. * @returns the TransformNode.
  27226. */
  27227. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27228. /**
  27229. * Gets the position of the current mesh in camera space
  27230. * @param camera defines the camera to use
  27231. * @returns a position
  27232. */
  27233. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27234. /**
  27235. * Returns the distance from the mesh to the active camera
  27236. * @param camera defines the camera to use
  27237. * @returns the distance
  27238. */
  27239. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27240. /**
  27241. * Clone the current transform node
  27242. * @param name Name of the new clone
  27243. * @param newParent New parent for the clone
  27244. * @param doNotCloneChildren Do not clone children hierarchy
  27245. * @returns the new transform node
  27246. */
  27247. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27248. /**
  27249. * Serializes the objects information.
  27250. * @param currentSerializationObject defines the object to serialize in
  27251. * @returns the serialized object
  27252. */
  27253. serialize(currentSerializationObject?: any): any;
  27254. /**
  27255. * Returns a new TransformNode object parsed from the source provided.
  27256. * @param parsedTransformNode is the source.
  27257. * @param scene the scene the object belongs to
  27258. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27259. * @returns a new TransformNode object parsed from the source provided.
  27260. */
  27261. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27262. /**
  27263. * Get all child-transformNodes of this node
  27264. * @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
  27265. * @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
  27266. * @returns an array of TransformNode
  27267. */
  27268. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27269. /**
  27270. * Releases resources associated with this transform node.
  27271. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27272. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27273. */
  27274. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27275. /**
  27276. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27277. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27278. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27279. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27280. * @returns the current mesh
  27281. */
  27282. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27283. private _syncAbsoluteScalingAndRotation;
  27284. }
  27285. }
  27286. declare module BABYLON {
  27287. /**
  27288. * Defines the types of pose enabled controllers that are supported
  27289. */
  27290. export enum PoseEnabledControllerType {
  27291. /**
  27292. * HTC Vive
  27293. */
  27294. VIVE = 0,
  27295. /**
  27296. * Oculus Rift
  27297. */
  27298. OCULUS = 1,
  27299. /**
  27300. * Windows mixed reality
  27301. */
  27302. WINDOWS = 2,
  27303. /**
  27304. * Samsung gear VR
  27305. */
  27306. GEAR_VR = 3,
  27307. /**
  27308. * Google Daydream
  27309. */
  27310. DAYDREAM = 4,
  27311. /**
  27312. * Generic
  27313. */
  27314. GENERIC = 5
  27315. }
  27316. /**
  27317. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27318. */
  27319. export interface MutableGamepadButton {
  27320. /**
  27321. * Value of the button/trigger
  27322. */
  27323. value: number;
  27324. /**
  27325. * If the button/trigger is currently touched
  27326. */
  27327. touched: boolean;
  27328. /**
  27329. * If the button/trigger is currently pressed
  27330. */
  27331. pressed: boolean;
  27332. }
  27333. /**
  27334. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27335. * @hidden
  27336. */
  27337. export interface ExtendedGamepadButton extends GamepadButton {
  27338. /**
  27339. * If the button/trigger is currently pressed
  27340. */
  27341. readonly pressed: boolean;
  27342. /**
  27343. * If the button/trigger is currently touched
  27344. */
  27345. readonly touched: boolean;
  27346. /**
  27347. * Value of the button/trigger
  27348. */
  27349. readonly value: number;
  27350. }
  27351. /** @hidden */
  27352. export interface _GamePadFactory {
  27353. /**
  27354. * Returns whether or not the current gamepad can be created for this type of controller.
  27355. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27356. * @returns true if it can be created, otherwise false
  27357. */
  27358. canCreate(gamepadInfo: any): boolean;
  27359. /**
  27360. * Creates a new instance of the Gamepad.
  27361. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27362. * @returns the new gamepad instance
  27363. */
  27364. create(gamepadInfo: any): Gamepad;
  27365. }
  27366. /**
  27367. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27368. */
  27369. export class PoseEnabledControllerHelper {
  27370. /** @hidden */
  27371. static _ControllerFactories: _GamePadFactory[];
  27372. /** @hidden */
  27373. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27374. /**
  27375. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27376. * @param vrGamepad the gamepad to initialized
  27377. * @returns a vr controller of the type the gamepad identified as
  27378. */
  27379. static InitiateController(vrGamepad: any): Gamepad;
  27380. }
  27381. /**
  27382. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27383. */
  27384. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27385. /**
  27386. * If the controller is used in a webXR session
  27387. */
  27388. isXR: boolean;
  27389. private _deviceRoomPosition;
  27390. private _deviceRoomRotationQuaternion;
  27391. /**
  27392. * The device position in babylon space
  27393. */
  27394. devicePosition: Vector3;
  27395. /**
  27396. * The device rotation in babylon space
  27397. */
  27398. deviceRotationQuaternion: Quaternion;
  27399. /**
  27400. * The scale factor of the device in babylon space
  27401. */
  27402. deviceScaleFactor: number;
  27403. /**
  27404. * (Likely devicePosition should be used instead) The device position in its room space
  27405. */
  27406. position: Vector3;
  27407. /**
  27408. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27409. */
  27410. rotationQuaternion: Quaternion;
  27411. /**
  27412. * The type of controller (Eg. Windows mixed reality)
  27413. */
  27414. controllerType: PoseEnabledControllerType;
  27415. protected _calculatedPosition: Vector3;
  27416. private _calculatedRotation;
  27417. /**
  27418. * The raw pose from the device
  27419. */
  27420. rawPose: DevicePose;
  27421. private _trackPosition;
  27422. private _maxRotationDistFromHeadset;
  27423. private _draggedRoomRotation;
  27424. /**
  27425. * @hidden
  27426. */
  27427. _disableTrackPosition(fixedPosition: Vector3): void;
  27428. /**
  27429. * Internal, the mesh attached to the controller
  27430. * @hidden
  27431. */
  27432. _mesh: Nullable<AbstractMesh>;
  27433. private _poseControlledCamera;
  27434. private _leftHandSystemQuaternion;
  27435. /**
  27436. * Internal, matrix used to convert room space to babylon space
  27437. * @hidden
  27438. */
  27439. _deviceToWorld: Matrix;
  27440. /**
  27441. * Node to be used when casting a ray from the controller
  27442. * @hidden
  27443. */
  27444. _pointingPoseNode: Nullable<TransformNode>;
  27445. /**
  27446. * Name of the child mesh that can be used to cast a ray from the controller
  27447. */
  27448. static readonly POINTING_POSE: string;
  27449. /**
  27450. * Creates a new PoseEnabledController from a gamepad
  27451. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27452. */
  27453. constructor(browserGamepad: any);
  27454. private _workingMatrix;
  27455. /**
  27456. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27457. */
  27458. update(): void;
  27459. /**
  27460. * Updates only the pose device and mesh without doing any button event checking
  27461. */
  27462. protected _updatePoseAndMesh(): void;
  27463. /**
  27464. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27465. * @param poseData raw pose fromthe device
  27466. */
  27467. updateFromDevice(poseData: DevicePose): void;
  27468. /**
  27469. * @hidden
  27470. */
  27471. _meshAttachedObservable: Observable<AbstractMesh>;
  27472. /**
  27473. * Attaches a mesh to the controller
  27474. * @param mesh the mesh to be attached
  27475. */
  27476. attachToMesh(mesh: AbstractMesh): void;
  27477. /**
  27478. * Attaches the controllers mesh to a camera
  27479. * @param camera the camera the mesh should be attached to
  27480. */
  27481. attachToPoseControlledCamera(camera: TargetCamera): void;
  27482. /**
  27483. * Disposes of the controller
  27484. */
  27485. dispose(): void;
  27486. /**
  27487. * The mesh that is attached to the controller
  27488. */
  27489. get mesh(): Nullable<AbstractMesh>;
  27490. /**
  27491. * Gets the ray of the controller in the direction the controller is pointing
  27492. * @param length the length the resulting ray should be
  27493. * @returns a ray in the direction the controller is pointing
  27494. */
  27495. getForwardRay(length?: number): Ray;
  27496. }
  27497. }
  27498. declare module BABYLON {
  27499. /**
  27500. * Defines the WebVRController object that represents controllers tracked in 3D space
  27501. */
  27502. export abstract class WebVRController extends PoseEnabledController {
  27503. /**
  27504. * Internal, the default controller model for the controller
  27505. */
  27506. protected _defaultModel: Nullable<AbstractMesh>;
  27507. /**
  27508. * Fired when the trigger state has changed
  27509. */
  27510. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27511. /**
  27512. * Fired when the main button state has changed
  27513. */
  27514. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27515. /**
  27516. * Fired when the secondary button state has changed
  27517. */
  27518. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27519. /**
  27520. * Fired when the pad state has changed
  27521. */
  27522. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27523. /**
  27524. * Fired when controllers stick values have changed
  27525. */
  27526. onPadValuesChangedObservable: Observable<StickValues>;
  27527. /**
  27528. * Array of button availible on the controller
  27529. */
  27530. protected _buttons: Array<MutableGamepadButton>;
  27531. private _onButtonStateChange;
  27532. /**
  27533. * Fired when a controller button's state has changed
  27534. * @param callback the callback containing the button that was modified
  27535. */
  27536. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27537. /**
  27538. * X and Y axis corresponding to the controllers joystick
  27539. */
  27540. pad: StickValues;
  27541. /**
  27542. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27543. */
  27544. hand: string;
  27545. /**
  27546. * The default controller model for the controller
  27547. */
  27548. get defaultModel(): Nullable<AbstractMesh>;
  27549. /**
  27550. * Creates a new WebVRController from a gamepad
  27551. * @param vrGamepad the gamepad that the WebVRController should be created from
  27552. */
  27553. constructor(vrGamepad: any);
  27554. /**
  27555. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27556. */
  27557. update(): void;
  27558. /**
  27559. * Function to be called when a button is modified
  27560. */
  27561. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27562. /**
  27563. * Loads a mesh and attaches it to the controller
  27564. * @param scene the scene the mesh should be added to
  27565. * @param meshLoaded callback for when the mesh has been loaded
  27566. */
  27567. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27568. private _setButtonValue;
  27569. private _changes;
  27570. private _checkChanges;
  27571. /**
  27572. * Disposes of th webVRCOntroller
  27573. */
  27574. dispose(): void;
  27575. }
  27576. }
  27577. declare module BABYLON {
  27578. /**
  27579. * The HemisphericLight simulates the ambient environment light,
  27580. * so the passed direction is the light reflection direction, not the incoming direction.
  27581. */
  27582. export class HemisphericLight extends Light {
  27583. /**
  27584. * The groundColor is the light in the opposite direction to the one specified during creation.
  27585. * 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.
  27586. */
  27587. groundColor: Color3;
  27588. /**
  27589. * The light reflection direction, not the incoming direction.
  27590. */
  27591. direction: Vector3;
  27592. /**
  27593. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27594. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27595. * The HemisphericLight can't cast shadows.
  27596. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27597. * @param name The friendly name of the light
  27598. * @param direction The direction of the light reflection
  27599. * @param scene The scene the light belongs to
  27600. */
  27601. constructor(name: string, direction: Vector3, scene: Scene);
  27602. protected _buildUniformLayout(): void;
  27603. /**
  27604. * Returns the string "HemisphericLight".
  27605. * @return The class name
  27606. */
  27607. getClassName(): string;
  27608. /**
  27609. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27610. * Returns the updated direction.
  27611. * @param target The target the direction should point to
  27612. * @return The computed direction
  27613. */
  27614. setDirectionToTarget(target: Vector3): Vector3;
  27615. /**
  27616. * Returns the shadow generator associated to the light.
  27617. * @returns Always null for hemispheric lights because it does not support shadows.
  27618. */
  27619. getShadowGenerator(): Nullable<IShadowGenerator>;
  27620. /**
  27621. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27622. * @param effect The effect to update
  27623. * @param lightIndex The index of the light in the effect to update
  27624. * @returns The hemispheric light
  27625. */
  27626. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27627. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27628. /**
  27629. * Computes the world matrix of the node
  27630. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27631. * @param useWasUpdatedFlag defines a reserved property
  27632. * @returns the world matrix
  27633. */
  27634. computeWorldMatrix(): Matrix;
  27635. /**
  27636. * Returns the integer 3.
  27637. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27638. */
  27639. getTypeID(): number;
  27640. /**
  27641. * Prepares the list of defines specific to the light type.
  27642. * @param defines the list of defines
  27643. * @param lightIndex defines the index of the light for the effect
  27644. */
  27645. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27646. }
  27647. }
  27648. declare module BABYLON {
  27649. /** @hidden */
  27650. export var vrMultiviewToSingleviewPixelShader: {
  27651. name: string;
  27652. shader: string;
  27653. };
  27654. }
  27655. declare module BABYLON {
  27656. /**
  27657. * Renders to multiple views with a single draw call
  27658. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27659. */
  27660. export class MultiviewRenderTarget extends RenderTargetTexture {
  27661. /**
  27662. * Creates a multiview render target
  27663. * @param scene scene used with the render target
  27664. * @param size the size of the render target (used for each view)
  27665. */
  27666. constructor(scene: Scene, size?: number | {
  27667. width: number;
  27668. height: number;
  27669. } | {
  27670. ratio: number;
  27671. });
  27672. /**
  27673. * @hidden
  27674. * @param faceIndex the face index, if its a cube texture
  27675. */
  27676. _bindFrameBuffer(faceIndex?: number): void;
  27677. /**
  27678. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27679. * @returns the view count
  27680. */
  27681. getViewCount(): number;
  27682. }
  27683. }
  27684. declare module BABYLON {
  27685. interface Engine {
  27686. /**
  27687. * Creates a new multiview render target
  27688. * @param width defines the width of the texture
  27689. * @param height defines the height of the texture
  27690. * @returns the created multiview texture
  27691. */
  27692. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27693. /**
  27694. * Binds a multiview framebuffer to be drawn to
  27695. * @param multiviewTexture texture to bind
  27696. */
  27697. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27698. }
  27699. interface Camera {
  27700. /**
  27701. * @hidden
  27702. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  27703. */
  27704. _useMultiviewToSingleView: boolean;
  27705. /**
  27706. * @hidden
  27707. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  27708. */
  27709. _multiviewTexture: Nullable<RenderTargetTexture>;
  27710. /**
  27711. * @hidden
  27712. * ensures the multiview texture of the camera exists and has the specified width/height
  27713. * @param width height to set on the multiview texture
  27714. * @param height width to set on the multiview texture
  27715. */
  27716. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27717. }
  27718. interface Scene {
  27719. /** @hidden */
  27720. _transformMatrixR: Matrix;
  27721. /** @hidden */
  27722. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27723. /** @hidden */
  27724. _createMultiviewUbo(): void;
  27725. /** @hidden */
  27726. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27727. /** @hidden */
  27728. _renderMultiviewToSingleView(camera: Camera): void;
  27729. }
  27730. }
  27731. declare module BABYLON {
  27732. /**
  27733. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27734. * This will not be used for webXR as it supports displaying texture arrays directly
  27735. */
  27736. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27737. /**
  27738. * Gets a string identifying the name of the class
  27739. * @returns "VRMultiviewToSingleviewPostProcess" string
  27740. */
  27741. getClassName(): string;
  27742. /**
  27743. * Initializes a VRMultiviewToSingleview
  27744. * @param name name of the post process
  27745. * @param camera camera to be applied to
  27746. * @param scaleFactor scaling factor to the size of the output texture
  27747. */
  27748. constructor(name: string, camera: Camera, scaleFactor: number);
  27749. }
  27750. }
  27751. declare module BABYLON {
  27752. /**
  27753. * Interface used to define additional presentation attributes
  27754. */
  27755. export interface IVRPresentationAttributes {
  27756. /**
  27757. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27758. */
  27759. highRefreshRate: boolean;
  27760. /**
  27761. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27762. */
  27763. foveationLevel: number;
  27764. }
  27765. interface Engine {
  27766. /** @hidden */
  27767. _vrDisplay: any;
  27768. /** @hidden */
  27769. _vrSupported: boolean;
  27770. /** @hidden */
  27771. _oldSize: Size;
  27772. /** @hidden */
  27773. _oldHardwareScaleFactor: number;
  27774. /** @hidden */
  27775. _vrExclusivePointerMode: boolean;
  27776. /** @hidden */
  27777. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27778. /** @hidden */
  27779. _onVRDisplayPointerRestricted: () => void;
  27780. /** @hidden */
  27781. _onVRDisplayPointerUnrestricted: () => void;
  27782. /** @hidden */
  27783. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27784. /** @hidden */
  27785. _onVrDisplayDisconnect: Nullable<() => void>;
  27786. /** @hidden */
  27787. _onVrDisplayPresentChange: Nullable<() => void>;
  27788. /**
  27789. * Observable signaled when VR display mode changes
  27790. */
  27791. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27792. /**
  27793. * Observable signaled when VR request present is complete
  27794. */
  27795. onVRRequestPresentComplete: Observable<boolean>;
  27796. /**
  27797. * Observable signaled when VR request present starts
  27798. */
  27799. onVRRequestPresentStart: Observable<Engine>;
  27800. /**
  27801. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27802. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27803. */
  27804. isInVRExclusivePointerMode: boolean;
  27805. /**
  27806. * Gets a boolean indicating if a webVR device was detected
  27807. * @returns true if a webVR device was detected
  27808. */
  27809. isVRDevicePresent(): boolean;
  27810. /**
  27811. * Gets the current webVR device
  27812. * @returns the current webVR device (or null)
  27813. */
  27814. getVRDevice(): any;
  27815. /**
  27816. * Initializes a webVR display and starts listening to display change events
  27817. * The onVRDisplayChangedObservable will be notified upon these changes
  27818. * @returns A promise containing a VRDisplay and if vr is supported
  27819. */
  27820. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27821. /** @hidden */
  27822. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27823. /**
  27824. * Gets or sets the presentation attributes used to configure VR rendering
  27825. */
  27826. vrPresentationAttributes?: IVRPresentationAttributes;
  27827. /**
  27828. * Call this function to switch to webVR mode
  27829. * Will do nothing if webVR is not supported or if there is no webVR device
  27830. * @param options the webvr options provided to the camera. mainly used for multiview
  27831. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27832. */
  27833. enableVR(options: WebVROptions): void;
  27834. /** @hidden */
  27835. _onVRFullScreenTriggered(): void;
  27836. }
  27837. }
  27838. declare module BABYLON {
  27839. /**
  27840. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27841. * IMPORTANT!! The data is right-hand data.
  27842. * @export
  27843. * @interface DevicePose
  27844. */
  27845. export interface DevicePose {
  27846. /**
  27847. * The position of the device, values in array are [x,y,z].
  27848. */
  27849. readonly position: Nullable<Float32Array>;
  27850. /**
  27851. * The linearVelocity of the device, values in array are [x,y,z].
  27852. */
  27853. readonly linearVelocity: Nullable<Float32Array>;
  27854. /**
  27855. * The linearAcceleration of the device, values in array are [x,y,z].
  27856. */
  27857. readonly linearAcceleration: Nullable<Float32Array>;
  27858. /**
  27859. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27860. */
  27861. readonly orientation: Nullable<Float32Array>;
  27862. /**
  27863. * The angularVelocity of the device, values in array are [x,y,z].
  27864. */
  27865. readonly angularVelocity: Nullable<Float32Array>;
  27866. /**
  27867. * The angularAcceleration of the device, values in array are [x,y,z].
  27868. */
  27869. readonly angularAcceleration: Nullable<Float32Array>;
  27870. }
  27871. /**
  27872. * Interface representing a pose controlled object in Babylon.
  27873. * A pose controlled object has both regular pose values as well as pose values
  27874. * from an external device such as a VR head mounted display
  27875. */
  27876. export interface PoseControlled {
  27877. /**
  27878. * The position of the object in babylon space.
  27879. */
  27880. position: Vector3;
  27881. /**
  27882. * The rotation quaternion of the object in babylon space.
  27883. */
  27884. rotationQuaternion: Quaternion;
  27885. /**
  27886. * The position of the device in babylon space.
  27887. */
  27888. devicePosition?: Vector3;
  27889. /**
  27890. * The rotation quaternion of the device in babylon space.
  27891. */
  27892. deviceRotationQuaternion: Quaternion;
  27893. /**
  27894. * The raw pose coming from the device.
  27895. */
  27896. rawPose: Nullable<DevicePose>;
  27897. /**
  27898. * The scale of the device to be used when translating from device space to babylon space.
  27899. */
  27900. deviceScaleFactor: number;
  27901. /**
  27902. * Updates the poseControlled values based on the input device pose.
  27903. * @param poseData the pose data to update the object with
  27904. */
  27905. updateFromDevice(poseData: DevicePose): void;
  27906. }
  27907. /**
  27908. * Set of options to customize the webVRCamera
  27909. */
  27910. export interface WebVROptions {
  27911. /**
  27912. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27913. */
  27914. trackPosition?: boolean;
  27915. /**
  27916. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27917. */
  27918. positionScale?: number;
  27919. /**
  27920. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27921. */
  27922. displayName?: string;
  27923. /**
  27924. * Should the native controller meshes be initialized. (default: true)
  27925. */
  27926. controllerMeshes?: boolean;
  27927. /**
  27928. * Creating a default HemiLight only on controllers. (default: true)
  27929. */
  27930. defaultLightingOnControllers?: boolean;
  27931. /**
  27932. * If you don't want to use the default VR button of the helper. (default: false)
  27933. */
  27934. useCustomVRButton?: boolean;
  27935. /**
  27936. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27937. */
  27938. customVRButton?: HTMLButtonElement;
  27939. /**
  27940. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27941. */
  27942. rayLength?: number;
  27943. /**
  27944. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27945. */
  27946. defaultHeight?: number;
  27947. /**
  27948. * If multiview should be used if available (default: false)
  27949. */
  27950. useMultiview?: boolean;
  27951. }
  27952. /**
  27953. * This represents a WebVR camera.
  27954. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27955. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27956. */
  27957. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27958. private webVROptions;
  27959. /**
  27960. * @hidden
  27961. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27962. */
  27963. _vrDevice: any;
  27964. /**
  27965. * The rawPose of the vrDevice.
  27966. */
  27967. rawPose: Nullable<DevicePose>;
  27968. private _onVREnabled;
  27969. private _specsVersion;
  27970. private _attached;
  27971. private _frameData;
  27972. protected _descendants: Array<Node>;
  27973. private _deviceRoomPosition;
  27974. /** @hidden */
  27975. _deviceRoomRotationQuaternion: Quaternion;
  27976. private _standingMatrix;
  27977. /**
  27978. * Represents device position in babylon space.
  27979. */
  27980. devicePosition: Vector3;
  27981. /**
  27982. * Represents device rotation in babylon space.
  27983. */
  27984. deviceRotationQuaternion: Quaternion;
  27985. /**
  27986. * The scale of the device to be used when translating from device space to babylon space.
  27987. */
  27988. deviceScaleFactor: number;
  27989. private _deviceToWorld;
  27990. private _worldToDevice;
  27991. /**
  27992. * References to the webVR controllers for the vrDevice.
  27993. */
  27994. controllers: Array<WebVRController>;
  27995. /**
  27996. * Emits an event when a controller is attached.
  27997. */
  27998. onControllersAttachedObservable: Observable<WebVRController[]>;
  27999. /**
  28000. * Emits an event when a controller's mesh has been loaded;
  28001. */
  28002. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28003. /**
  28004. * Emits an event when the HMD's pose has been updated.
  28005. */
  28006. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28007. private _poseSet;
  28008. /**
  28009. * If the rig cameras be used as parent instead of this camera.
  28010. */
  28011. rigParenting: boolean;
  28012. private _lightOnControllers;
  28013. private _defaultHeight?;
  28014. /**
  28015. * Instantiates a WebVRFreeCamera.
  28016. * @param name The name of the WebVRFreeCamera
  28017. * @param position The starting anchor position for the camera
  28018. * @param scene The scene the camera belongs to
  28019. * @param webVROptions a set of customizable options for the webVRCamera
  28020. */
  28021. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28022. /**
  28023. * Gets the device distance from the ground in meters.
  28024. * @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.
  28025. */
  28026. deviceDistanceToRoomGround(): number;
  28027. /**
  28028. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28029. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28030. */
  28031. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28032. /**
  28033. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28034. * @returns A promise with a boolean set to if the standing matrix is supported.
  28035. */
  28036. useStandingMatrixAsync(): Promise<boolean>;
  28037. /**
  28038. * Disposes the camera
  28039. */
  28040. dispose(): void;
  28041. /**
  28042. * Gets a vrController by name.
  28043. * @param name The name of the controller to retreive
  28044. * @returns the controller matching the name specified or null if not found
  28045. */
  28046. getControllerByName(name: string): Nullable<WebVRController>;
  28047. private _leftController;
  28048. /**
  28049. * The controller corresponding to the users left hand.
  28050. */
  28051. get leftController(): Nullable<WebVRController>;
  28052. private _rightController;
  28053. /**
  28054. * The controller corresponding to the users right hand.
  28055. */
  28056. get rightController(): Nullable<WebVRController>;
  28057. /**
  28058. * Casts a ray forward from the vrCamera's gaze.
  28059. * @param length Length of the ray (default: 100)
  28060. * @returns the ray corresponding to the gaze
  28061. */
  28062. getForwardRay(length?: number): Ray;
  28063. /**
  28064. * @hidden
  28065. * Updates the camera based on device's frame data
  28066. */
  28067. _checkInputs(): void;
  28068. /**
  28069. * Updates the poseControlled values based on the input device pose.
  28070. * @param poseData Pose coming from the device
  28071. */
  28072. updateFromDevice(poseData: DevicePose): void;
  28073. private _detachIfAttached;
  28074. /**
  28075. * WebVR's attach control will start broadcasting frames to the device.
  28076. * Note that in certain browsers (chrome for example) this function must be called
  28077. * within a user-interaction callback. Example:
  28078. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28079. *
  28080. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28081. */
  28082. attachControl(noPreventDefault?: boolean): void;
  28083. /**
  28084. * Detach the current controls from the specified dom element.
  28085. */
  28086. detachControl(): void;
  28087. /**
  28088. * @returns the name of this class
  28089. */
  28090. getClassName(): string;
  28091. /**
  28092. * Calls resetPose on the vrDisplay
  28093. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28094. */
  28095. resetToCurrentRotation(): void;
  28096. /**
  28097. * @hidden
  28098. * Updates the rig cameras (left and right eye)
  28099. */
  28100. _updateRigCameras(): void;
  28101. private _workingVector;
  28102. private _oneVector;
  28103. private _workingMatrix;
  28104. private updateCacheCalled;
  28105. private _correctPositionIfNotTrackPosition;
  28106. /**
  28107. * @hidden
  28108. * Updates the cached values of the camera
  28109. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28110. */
  28111. _updateCache(ignoreParentClass?: boolean): void;
  28112. /**
  28113. * @hidden
  28114. * Get current device position in babylon world
  28115. */
  28116. _computeDevicePosition(): void;
  28117. /**
  28118. * Updates the current device position and rotation in the babylon world
  28119. */
  28120. update(): void;
  28121. /**
  28122. * @hidden
  28123. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28124. * @returns an identity matrix
  28125. */
  28126. _getViewMatrix(): Matrix;
  28127. private _tmpMatrix;
  28128. /**
  28129. * This function is called by the two RIG cameras.
  28130. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28131. * @hidden
  28132. */
  28133. _getWebVRViewMatrix(): Matrix;
  28134. /** @hidden */
  28135. _getWebVRProjectionMatrix(): Matrix;
  28136. private _onGamepadConnectedObserver;
  28137. private _onGamepadDisconnectedObserver;
  28138. private _updateCacheWhenTrackingDisabledObserver;
  28139. /**
  28140. * Initializes the controllers and their meshes
  28141. */
  28142. initControllers(): void;
  28143. }
  28144. }
  28145. declare module BABYLON {
  28146. /**
  28147. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28148. *
  28149. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28150. *
  28151. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28152. */
  28153. export class MaterialHelper {
  28154. /**
  28155. * Bind the current view position to an effect.
  28156. * @param effect The effect to be bound
  28157. * @param scene The scene the eyes position is used from
  28158. * @param variableName name of the shader variable that will hold the eye position
  28159. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  28160. * @return the computed eye position
  28161. */
  28162. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  28163. /**
  28164. * Update the scene ubo before it can be used in rendering processing
  28165. * @param scene the scene to retrieve the ubo from
  28166. * @returns the scene UniformBuffer
  28167. */
  28168. static FinalizeSceneUbo(scene: Scene): UniformBuffer;
  28169. /**
  28170. * Binds the scene's uniform buffer to the effect.
  28171. * @param effect defines the effect to bind to the scene uniform buffer
  28172. * @param sceneUbo defines the uniform buffer storing scene data
  28173. */
  28174. static BindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  28175. /**
  28176. * Helps preparing the defines values about the UVs in used in the effect.
  28177. * UVs are shared as much as we can across channels in the shaders.
  28178. * @param texture The texture we are preparing the UVs for
  28179. * @param defines The defines to update
  28180. * @param key The channel key "diffuse", "specular"... used in the shader
  28181. */
  28182. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28183. /**
  28184. * Binds a texture matrix value to its corresponding uniform
  28185. * @param texture The texture to bind the matrix for
  28186. * @param uniformBuffer The uniform buffer receiving the data
  28187. * @param key The channel key "diffuse", "specular"... used in the shader
  28188. */
  28189. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28190. /**
  28191. * Gets the current status of the fog (should it be enabled?)
  28192. * @param mesh defines the mesh to evaluate for fog support
  28193. * @param scene defines the hosting scene
  28194. * @returns true if fog must be enabled
  28195. */
  28196. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28197. /**
  28198. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28199. * @param mesh defines the current mesh
  28200. * @param scene defines the current scene
  28201. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28202. * @param pointsCloud defines if point cloud rendering has to be turned on
  28203. * @param fogEnabled defines if fog has to be turned on
  28204. * @param alphaTest defines if alpha testing has to be turned on
  28205. * @param defines defines the current list of defines
  28206. */
  28207. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28208. /**
  28209. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28210. * @param scene defines the current scene
  28211. * @param engine defines the current engine
  28212. * @param defines specifies the list of active defines
  28213. * @param useInstances defines if instances have to be turned on
  28214. * @param useClipPlane defines if clip plane have to be turned on
  28215. * @param useInstances defines if instances have to be turned on
  28216. * @param useThinInstances defines if thin instances have to be turned on
  28217. */
  28218. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28219. /**
  28220. * Prepares the defines for bones
  28221. * @param mesh The mesh containing the geometry data we will draw
  28222. * @param defines The defines to update
  28223. */
  28224. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28225. /**
  28226. * Prepares the defines for morph targets
  28227. * @param mesh The mesh containing the geometry data we will draw
  28228. * @param defines The defines to update
  28229. */
  28230. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28231. /**
  28232. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28233. * @param mesh The mesh containing the geometry data we will draw
  28234. * @param defines The defines to update
  28235. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28236. * @param useBones Precise whether bones should be used or not (override mesh info)
  28237. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28238. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28239. * @returns false if defines are considered not dirty and have not been checked
  28240. */
  28241. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28242. /**
  28243. * Prepares the defines related to multiview
  28244. * @param scene The scene we are intending to draw
  28245. * @param defines The defines to update
  28246. */
  28247. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28248. /**
  28249. * Prepares the defines related to the prepass
  28250. * @param scene The scene we are intending to draw
  28251. * @param defines The defines to update
  28252. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28253. */
  28254. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28255. /**
  28256. * Prepares the defines related to the light information passed in parameter
  28257. * @param scene The scene we are intending to draw
  28258. * @param mesh The mesh the effect is compiling for
  28259. * @param light The light the effect is compiling for
  28260. * @param lightIndex The index of the light
  28261. * @param defines The defines to update
  28262. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28263. * @param state Defines the current state regarding what is needed (normals, etc...)
  28264. */
  28265. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28266. needNormals: boolean;
  28267. needRebuild: boolean;
  28268. shadowEnabled: boolean;
  28269. specularEnabled: boolean;
  28270. lightmapMode: boolean;
  28271. }): void;
  28272. /**
  28273. * Prepares the defines related to the light information passed in parameter
  28274. * @param scene The scene we are intending to draw
  28275. * @param mesh The mesh the effect is compiling for
  28276. * @param defines The defines to update
  28277. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28278. * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max
  28279. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28280. * @returns true if normals will be required for the rest of the effect
  28281. */
  28282. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28283. /**
  28284. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28285. * @param lightIndex defines the light index
  28286. * @param uniformsList The uniform list
  28287. * @param samplersList The sampler list
  28288. * @param projectedLightTexture defines if projected texture must be used
  28289. * @param uniformBuffersList defines an optional list of uniform buffers
  28290. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28291. */
  28292. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28293. /**
  28294. * Prepares the uniforms and samplers list to be used in the effect
  28295. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
  28296. * @param samplersList The sampler list
  28297. * @param defines The defines helping in the list generation
  28298. * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
  28299. */
  28300. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28301. /**
  28302. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28303. * @param defines The defines to update while falling back
  28304. * @param fallbacks The authorized effect fallbacks
  28305. * @param maxSimultaneousLights The maximum number of lights allowed
  28306. * @param rank the current rank of the Effect
  28307. * @returns The newly affected rank
  28308. */
  28309. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28310. private static _TmpMorphInfluencers;
  28311. /**
  28312. * Prepares the list of attributes required for morph targets according to the effect defines.
  28313. * @param attribs The current list of supported attribs
  28314. * @param mesh The mesh to prepare the morph targets attributes for
  28315. * @param influencers The number of influencers
  28316. */
  28317. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28318. /**
  28319. * Prepares the list of attributes required for morph targets according to the effect defines.
  28320. * @param attribs The current list of supported attribs
  28321. * @param mesh The mesh to prepare the morph targets attributes for
  28322. * @param defines The current Defines of the effect
  28323. */
  28324. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28325. /**
  28326. * Prepares the list of attributes required for bones according to the effect defines.
  28327. * @param attribs The current list of supported attribs
  28328. * @param mesh The mesh to prepare the bones attributes for
  28329. * @param defines The current Defines of the effect
  28330. * @param fallbacks The current effect fallback strategy
  28331. */
  28332. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28333. /**
  28334. * Check and prepare the list of attributes required for instances according to the effect defines.
  28335. * @param attribs The current list of supported attribs
  28336. * @param defines The current MaterialDefines of the effect
  28337. */
  28338. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28339. /**
  28340. * Add the list of attributes required for instances to the attribs array.
  28341. * @param attribs The current list of supported attribs
  28342. */
  28343. static PushAttributesForInstances(attribs: string[]): void;
  28344. /**
  28345. * Binds the light information to the effect.
  28346. * @param light The light containing the generator
  28347. * @param effect The effect we are binding the data to
  28348. * @param lightIndex The light index in the effect used to render
  28349. */
  28350. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28351. /**
  28352. * Binds the lights information from the scene to the effect for the given mesh.
  28353. * @param light Light to bind
  28354. * @param lightIndex Light index
  28355. * @param scene The scene where the light belongs to
  28356. * @param effect The effect we are binding the data to
  28357. * @param useSpecular Defines if specular is supported
  28358. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28359. */
  28360. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28361. /**
  28362. * Binds the lights information from the scene to the effect for the given mesh.
  28363. * @param scene The scene the lights belongs to
  28364. * @param mesh The mesh we are binding the information to render
  28365. * @param effect The effect we are binding the data to
  28366. * @param defines The generated defines for the effect
  28367. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28368. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28369. */
  28370. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28371. private static _tempFogColor;
  28372. /**
  28373. * Binds the fog information from the scene to the effect for the given mesh.
  28374. * @param scene The scene the lights belongs to
  28375. * @param mesh The mesh we are binding the information to render
  28376. * @param effect The effect we are binding the data to
  28377. * @param linearSpace Defines if the fog effect is applied in linear space
  28378. */
  28379. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28380. /**
  28381. * Binds the bones information from the mesh to the effect.
  28382. * @param mesh The mesh we are binding the information to render
  28383. * @param effect The effect we are binding the data to
  28384. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28385. */
  28386. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28387. private static _CopyBonesTransformationMatrices;
  28388. /**
  28389. * Binds the morph targets information from the mesh to the effect.
  28390. * @param abstractMesh The mesh we are binding the information to render
  28391. * @param effect The effect we are binding the data to
  28392. */
  28393. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28394. /**
  28395. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28396. * @param defines The generated defines used in the effect
  28397. * @param effect The effect we are binding the data to
  28398. * @param scene The scene we are willing to render with logarithmic scale for
  28399. */
  28400. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28401. /**
  28402. * Binds the clip plane information from the scene to the effect.
  28403. * @param scene The scene the clip plane information are extracted from
  28404. * @param effect The effect we are binding the data to
  28405. */
  28406. static BindClipPlane(effect: Effect, scene: Scene): void;
  28407. }
  28408. }
  28409. declare module BABYLON {
  28410. /** @hidden */
  28411. export var bayerDitherFunctions: {
  28412. name: string;
  28413. shader: string;
  28414. };
  28415. }
  28416. declare module BABYLON {
  28417. /** @hidden */
  28418. export var shadowMapFragmentDeclaration: {
  28419. name: string;
  28420. shader: string;
  28421. };
  28422. }
  28423. declare module BABYLON {
  28424. /** @hidden */
  28425. export var shadowMapFragment: {
  28426. name: string;
  28427. shader: string;
  28428. };
  28429. }
  28430. declare module BABYLON {
  28431. /** @hidden */
  28432. export var shadowMapPixelShader: {
  28433. name: string;
  28434. shader: string;
  28435. };
  28436. }
  28437. declare module BABYLON {
  28438. /** @hidden */
  28439. export var shadowMapVertexDeclaration: {
  28440. name: string;
  28441. shader: string;
  28442. };
  28443. }
  28444. declare module BABYLON {
  28445. /** @hidden */
  28446. export var shadowMapVertexNormalBias: {
  28447. name: string;
  28448. shader: string;
  28449. };
  28450. }
  28451. declare module BABYLON {
  28452. /** @hidden */
  28453. export var shadowMapVertexMetric: {
  28454. name: string;
  28455. shader: string;
  28456. };
  28457. }
  28458. declare module BABYLON {
  28459. /** @hidden */
  28460. export var shadowMapVertexShader: {
  28461. name: string;
  28462. shader: string;
  28463. };
  28464. }
  28465. declare module BABYLON {
  28466. /** @hidden */
  28467. export var depthBoxBlurPixelShader: {
  28468. name: string;
  28469. shader: string;
  28470. };
  28471. }
  28472. declare module BABYLON {
  28473. /** @hidden */
  28474. export var shadowMapFragmentSoftTransparentShadow: {
  28475. name: string;
  28476. shader: string;
  28477. };
  28478. }
  28479. declare module BABYLON {
  28480. /**
  28481. * Creates an instance based on a source mesh.
  28482. */
  28483. export class InstancedMesh extends AbstractMesh {
  28484. private _sourceMesh;
  28485. private _currentLOD;
  28486. /** @hidden */
  28487. _indexInSourceMeshInstanceArray: number;
  28488. constructor(name: string, source: Mesh);
  28489. /**
  28490. * Returns the string "InstancedMesh".
  28491. */
  28492. getClassName(): string;
  28493. /** Gets the list of lights affecting that mesh */
  28494. get lightSources(): Light[];
  28495. _resyncLightSources(): void;
  28496. _resyncLightSource(light: Light): void;
  28497. _removeLightSource(light: Light, dispose: boolean): void;
  28498. /**
  28499. * If the source mesh receives shadows
  28500. */
  28501. get receiveShadows(): boolean;
  28502. /**
  28503. * The material of the source mesh
  28504. */
  28505. get material(): Nullable<Material>;
  28506. /**
  28507. * Visibility of the source mesh
  28508. */
  28509. get visibility(): number;
  28510. /**
  28511. * Skeleton of the source mesh
  28512. */
  28513. get skeleton(): Nullable<Skeleton>;
  28514. /**
  28515. * Rendering ground id of the source mesh
  28516. */
  28517. get renderingGroupId(): number;
  28518. set renderingGroupId(value: number);
  28519. /**
  28520. * Returns the total number of vertices (integer).
  28521. */
  28522. getTotalVertices(): number;
  28523. /**
  28524. * Returns a positive integer : the total number of indices in this mesh geometry.
  28525. * @returns the numner of indices or zero if the mesh has no geometry.
  28526. */
  28527. getTotalIndices(): number;
  28528. /**
  28529. * The source mesh of the instance
  28530. */
  28531. get sourceMesh(): Mesh;
  28532. /**
  28533. * Creates a new InstancedMesh object from the mesh model.
  28534. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28535. * @param name defines the name of the new instance
  28536. * @returns a new InstancedMesh
  28537. */
  28538. createInstance(name: string): InstancedMesh;
  28539. /**
  28540. * Is this node ready to be used/rendered
  28541. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28542. * @return {boolean} is it ready
  28543. */
  28544. isReady(completeCheck?: boolean): boolean;
  28545. /**
  28546. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28547. * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)
  28548. * @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.
  28549. * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.
  28550. */
  28551. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28552. /**
  28553. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28554. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28555. * The `data` are either a numeric array either a Float32Array.
  28556. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.
  28557. * 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).
  28558. * Note that a new underlying VertexBuffer object is created each call.
  28559. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28560. *
  28561. * Possible `kind` values :
  28562. * - VertexBuffer.PositionKind
  28563. * - VertexBuffer.UVKind
  28564. * - VertexBuffer.UV2Kind
  28565. * - VertexBuffer.UV3Kind
  28566. * - VertexBuffer.UV4Kind
  28567. * - VertexBuffer.UV5Kind
  28568. * - VertexBuffer.UV6Kind
  28569. * - VertexBuffer.ColorKind
  28570. * - VertexBuffer.MatricesIndicesKind
  28571. * - VertexBuffer.MatricesIndicesExtraKind
  28572. * - VertexBuffer.MatricesWeightsKind
  28573. * - VertexBuffer.MatricesWeightsExtraKind
  28574. *
  28575. * Returns the Mesh.
  28576. */
  28577. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28578. /**
  28579. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28580. * If the mesh has no geometry, it is simply returned as it is.
  28581. * The `data` are either a numeric array either a Float32Array.
  28582. * No new underlying VertexBuffer object is created.
  28583. * 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.
  28584. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28585. *
  28586. * Possible `kind` values :
  28587. * - VertexBuffer.PositionKind
  28588. * - VertexBuffer.UVKind
  28589. * - VertexBuffer.UV2Kind
  28590. * - VertexBuffer.UV3Kind
  28591. * - VertexBuffer.UV4Kind
  28592. * - VertexBuffer.UV5Kind
  28593. * - VertexBuffer.UV6Kind
  28594. * - VertexBuffer.ColorKind
  28595. * - VertexBuffer.MatricesIndicesKind
  28596. * - VertexBuffer.MatricesIndicesExtraKind
  28597. * - VertexBuffer.MatricesWeightsKind
  28598. * - VertexBuffer.MatricesWeightsExtraKind
  28599. *
  28600. * Returns the Mesh.
  28601. */
  28602. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28603. /**
  28604. * Sets the mesh indices.
  28605. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28606. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28607. * This method creates a new index buffer each call.
  28608. * Returns the Mesh.
  28609. */
  28610. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28611. /**
  28612. * Boolean : True if the mesh owns the requested kind of data.
  28613. */
  28614. isVerticesDataPresent(kind: string): boolean;
  28615. /**
  28616. * Returns an array of indices (IndicesArray).
  28617. */
  28618. getIndices(): Nullable<IndicesArray>;
  28619. get _positions(): Nullable<Vector3[]>;
  28620. /**
  28621. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28622. * This means the mesh underlying bounding box and sphere are recomputed.
  28623. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28624. * @returns the current mesh
  28625. */
  28626. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28627. /** @hidden */
  28628. _preActivate(): InstancedMesh;
  28629. /** @hidden */
  28630. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28631. /** @hidden */
  28632. _postActivate(): void;
  28633. getWorldMatrix(): Matrix;
  28634. get isAnInstance(): boolean;
  28635. /**
  28636. * Returns the current associated LOD AbstractMesh.
  28637. */
  28638. getLOD(camera: Camera): AbstractMesh;
  28639. /** @hidden */
  28640. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28641. /** @hidden */
  28642. _syncSubMeshes(): InstancedMesh;
  28643. /** @hidden */
  28644. _generatePointsArray(): boolean;
  28645. /** @hidden */
  28646. _updateBoundingInfo(): AbstractMesh;
  28647. /**
  28648. * Creates a new InstancedMesh from the current mesh.
  28649. * - name (string) : the cloned mesh name
  28650. * - newParent (optional Node) : the optional Node to parent the clone to.
  28651. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28652. *
  28653. * Returns the clone.
  28654. */
  28655. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28656. /**
  28657. * Disposes the InstancedMesh.
  28658. * Returns nothing.
  28659. */
  28660. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28661. }
  28662. interface Mesh {
  28663. /**
  28664. * Register a custom buffer that will be instanced
  28665. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28666. * @param kind defines the buffer kind
  28667. * @param stride defines the stride in floats
  28668. */
  28669. registerInstancedBuffer(kind: string, stride: number): void;
  28670. /**
  28671. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  28672. */
  28673. _invalidateInstanceVertexArrayObject(): void;
  28674. /**
  28675. * true to use the edge renderer for all instances of this mesh
  28676. */
  28677. edgesShareWithInstances: boolean;
  28678. /** @hidden */
  28679. _userInstancedBuffersStorage: {
  28680. data: {
  28681. [key: string]: Float32Array;
  28682. };
  28683. sizes: {
  28684. [key: string]: number;
  28685. };
  28686. vertexBuffers: {
  28687. [key: string]: Nullable<VertexBuffer>;
  28688. };
  28689. strides: {
  28690. [key: string]: number;
  28691. };
  28692. vertexArrayObjects?: {
  28693. [key: string]: WebGLVertexArrayObject;
  28694. };
  28695. };
  28696. }
  28697. interface AbstractMesh {
  28698. /**
  28699. * Object used to store instanced buffers defined by user
  28700. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28701. */
  28702. instancedBuffers: {
  28703. [key: string]: any;
  28704. };
  28705. }
  28706. }
  28707. declare module BABYLON {
  28708. /**
  28709. * Defines the options associated with the creation of a shader material.
  28710. */
  28711. export interface IShaderMaterialOptions {
  28712. /**
  28713. * Does the material work in alpha blend mode
  28714. */
  28715. needAlphaBlending: boolean;
  28716. /**
  28717. * Does the material work in alpha test mode
  28718. */
  28719. needAlphaTesting: boolean;
  28720. /**
  28721. * The list of attribute names used in the shader
  28722. */
  28723. attributes: string[];
  28724. /**
  28725. * The list of uniform names used in the shader
  28726. */
  28727. uniforms: string[];
  28728. /**
  28729. * The list of UBO names used in the shader
  28730. */
  28731. uniformBuffers: string[];
  28732. /**
  28733. * The list of sampler names used in the shader
  28734. */
  28735. samplers: string[];
  28736. /**
  28737. * The list of defines used in the shader
  28738. */
  28739. defines: string[];
  28740. }
  28741. /**
  28742. * 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.
  28743. *
  28744. * This returned material effects how the mesh will look based on the code in the shaders.
  28745. *
  28746. * @see https://doc.babylonjs.com/how_to/shader_material
  28747. */
  28748. export class ShaderMaterial extends Material {
  28749. private _shaderPath;
  28750. private _options;
  28751. private _textures;
  28752. private _textureArrays;
  28753. private _floats;
  28754. private _ints;
  28755. private _floatsArrays;
  28756. private _colors3;
  28757. private _colors3Arrays;
  28758. private _colors4;
  28759. private _colors4Arrays;
  28760. private _vectors2;
  28761. private _vectors3;
  28762. private _vectors4;
  28763. private _matrices;
  28764. private _matrixArrays;
  28765. private _matrices3x3;
  28766. private _matrices2x2;
  28767. private _vectors2Arrays;
  28768. private _vectors3Arrays;
  28769. private _vectors4Arrays;
  28770. private _cachedWorldViewMatrix;
  28771. private _cachedWorldViewProjectionMatrix;
  28772. private _renderId;
  28773. private _multiview;
  28774. private _cachedDefines;
  28775. /** Define the Url to load snippets */
  28776. static SnippetUrl: string;
  28777. /** Snippet ID if the material was created from the snippet server */
  28778. snippetId: string;
  28779. /**
  28780. * Instantiate a new shader material.
  28781. * 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.
  28782. * This returned material effects how the mesh will look based on the code in the shaders.
  28783. * @see https://doc.babylonjs.com/how_to/shader_material
  28784. * @param name Define the name of the material in the scene
  28785. * @param scene Define the scene the material belongs to
  28786. * @param shaderPath Defines the route to the shader code in one of three ways:
  28787. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28788. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28789. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28790. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28791. * @param options Define the options used to create the shader
  28792. */
  28793. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28794. /**
  28795. * Gets the shader path used to define the shader code
  28796. * It can be modified to trigger a new compilation
  28797. */
  28798. get shaderPath(): any;
  28799. /**
  28800. * Sets the shader path used to define the shader code
  28801. * It can be modified to trigger a new compilation
  28802. */
  28803. set shaderPath(shaderPath: any);
  28804. /**
  28805. * Gets the options used to compile the shader.
  28806. * They can be modified to trigger a new compilation
  28807. */
  28808. get options(): IShaderMaterialOptions;
  28809. /**
  28810. * Gets the current class name of the material e.g. "ShaderMaterial"
  28811. * Mainly use in serialization.
  28812. * @returns the class name
  28813. */
  28814. getClassName(): string;
  28815. /**
  28816. * Specifies if the material will require alpha blending
  28817. * @returns a boolean specifying if alpha blending is needed
  28818. */
  28819. needAlphaBlending(): boolean;
  28820. /**
  28821. * Specifies if this material should be rendered in alpha test mode
  28822. * @returns a boolean specifying if an alpha test is needed.
  28823. */
  28824. needAlphaTesting(): boolean;
  28825. private _checkUniform;
  28826. /**
  28827. * Set a texture in the shader.
  28828. * @param name Define the name of the uniform samplers as defined in the shader
  28829. * @param texture Define the texture to bind to this sampler
  28830. * @return the material itself allowing "fluent" like uniform updates
  28831. */
  28832. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28833. /**
  28834. * Set a texture array in the shader.
  28835. * @param name Define the name of the uniform sampler array as defined in the shader
  28836. * @param textures Define the list of textures to bind to this sampler
  28837. * @return the material itself allowing "fluent" like uniform updates
  28838. */
  28839. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28840. /**
  28841. * Set a float in the shader.
  28842. * @param name Define the name of the uniform as defined in the shader
  28843. * @param value Define the value to give to the uniform
  28844. * @return the material itself allowing "fluent" like uniform updates
  28845. */
  28846. setFloat(name: string, value: number): ShaderMaterial;
  28847. /**
  28848. * Set a int in the shader.
  28849. * @param name Define the name of the uniform as defined in the shader
  28850. * @param value Define the value to give to the uniform
  28851. * @return the material itself allowing "fluent" like uniform updates
  28852. */
  28853. setInt(name: string, value: number): ShaderMaterial;
  28854. /**
  28855. * Set an array of floats in the shader.
  28856. * @param name Define the name of the uniform as defined in the shader
  28857. * @param value Define the value to give to the uniform
  28858. * @return the material itself allowing "fluent" like uniform updates
  28859. */
  28860. setFloats(name: string, value: number[]): ShaderMaterial;
  28861. /**
  28862. * Set a vec3 in the shader from a Color3.
  28863. * @param name Define the name of the uniform as defined in the shader
  28864. * @param value Define the value to give to the uniform
  28865. * @return the material itself allowing "fluent" like uniform updates
  28866. */
  28867. setColor3(name: string, value: Color3): ShaderMaterial;
  28868. /**
  28869. * Set a vec3 array in the shader from a Color3 array.
  28870. * @param name Define the name of the uniform as defined in the shader
  28871. * @param value Define the value to give to the uniform
  28872. * @return the material itself allowing "fluent" like uniform updates
  28873. */
  28874. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28875. /**
  28876. * Set a vec4 in the shader from a Color4.
  28877. * @param name Define the name of the uniform as defined in the shader
  28878. * @param value Define the value to give to the uniform
  28879. * @return the material itself allowing "fluent" like uniform updates
  28880. */
  28881. setColor4(name: string, value: Color4): ShaderMaterial;
  28882. /**
  28883. * Set a vec4 array in the shader from a Color4 array.
  28884. * @param name Define the name of the uniform as defined in the shader
  28885. * @param value Define the value to give to the uniform
  28886. * @return the material itself allowing "fluent" like uniform updates
  28887. */
  28888. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28889. /**
  28890. * Set a vec2 in the shader from a Vector2.
  28891. * @param name Define the name of the uniform as defined in the shader
  28892. * @param value Define the value to give to the uniform
  28893. * @return the material itself allowing "fluent" like uniform updates
  28894. */
  28895. setVector2(name: string, value: Vector2): ShaderMaterial;
  28896. /**
  28897. * Set a vec3 in the shader from a Vector3.
  28898. * @param name Define the name of the uniform as defined in the shader
  28899. * @param value Define the value to give to the uniform
  28900. * @return the material itself allowing "fluent" like uniform updates
  28901. */
  28902. setVector3(name: string, value: Vector3): ShaderMaterial;
  28903. /**
  28904. * Set a vec4 in the shader from a Vector4.
  28905. * @param name Define the name of the uniform as defined in the shader
  28906. * @param value Define the value to give to the uniform
  28907. * @return the material itself allowing "fluent" like uniform updates
  28908. */
  28909. setVector4(name: string, value: Vector4): ShaderMaterial;
  28910. /**
  28911. * Set a mat4 in the shader from a Matrix.
  28912. * @param name Define the name of the uniform as defined in the shader
  28913. * @param value Define the value to give to the uniform
  28914. * @return the material itself allowing "fluent" like uniform updates
  28915. */
  28916. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28917. /**
  28918. * Set a float32Array in the shader from a matrix array.
  28919. * @param name Define the name of the uniform as defined in the shader
  28920. * @param value Define the value to give to the uniform
  28921. * @return the material itself allowing "fluent" like uniform updates
  28922. */
  28923. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28924. /**
  28925. * Set a mat3 in the shader from a Float32Array.
  28926. * @param name Define the name of the uniform as defined in the shader
  28927. * @param value Define the value to give to the uniform
  28928. * @return the material itself allowing "fluent" like uniform updates
  28929. */
  28930. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28931. /**
  28932. * Set a mat2 in the shader from a Float32Array.
  28933. * @param name Define the name of the uniform as defined in the shader
  28934. * @param value Define the value to give to the uniform
  28935. * @return the material itself allowing "fluent" like uniform updates
  28936. */
  28937. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28938. /**
  28939. * Set a vec2 array in the shader from a number array.
  28940. * @param name Define the name of the uniform as defined in the shader
  28941. * @param value Define the value to give to the uniform
  28942. * @return the material itself allowing "fluent" like uniform updates
  28943. */
  28944. setArray2(name: string, value: number[]): ShaderMaterial;
  28945. /**
  28946. * Set a vec3 array in the shader from a number array.
  28947. * @param name Define the name of the uniform as defined in the shader
  28948. * @param value Define the value to give to the uniform
  28949. * @return the material itself allowing "fluent" like uniform updates
  28950. */
  28951. setArray3(name: string, value: number[]): ShaderMaterial;
  28952. /**
  28953. * Set a vec4 array in the shader from a number array.
  28954. * @param name Define the name of the uniform as defined in the shader
  28955. * @param value Define the value to give to the uniform
  28956. * @return the material itself allowing "fluent" like uniform updates
  28957. */
  28958. setArray4(name: string, value: number[]): ShaderMaterial;
  28959. private _checkCache;
  28960. /**
  28961. * Specifies that the submesh is ready to be used
  28962. * @param mesh defines the mesh to check
  28963. * @param subMesh defines which submesh to check
  28964. * @param useInstances specifies that instances should be used
  28965. * @returns a boolean indicating that the submesh is ready or not
  28966. */
  28967. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28968. /**
  28969. * Checks if the material is ready to render the requested mesh
  28970. * @param mesh Define the mesh to render
  28971. * @param useInstances Define whether or not the material is used with instances
  28972. * @returns true if ready, otherwise false
  28973. */
  28974. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28975. /**
  28976. * Binds the world matrix to the material
  28977. * @param world defines the world transformation matrix
  28978. * @param effectOverride - If provided, use this effect instead of internal effect
  28979. */
  28980. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28981. /**
  28982. * Binds the submesh to this material by preparing the effect and shader to draw
  28983. * @param world defines the world transformation matrix
  28984. * @param mesh defines the mesh containing the submesh
  28985. * @param subMesh defines the submesh to bind the material to
  28986. */
  28987. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28988. /**
  28989. * Binds the material to the mesh
  28990. * @param world defines the world transformation matrix
  28991. * @param mesh defines the mesh to bind the material to
  28992. * @param effectOverride - If provided, use this effect instead of internal effect
  28993. */
  28994. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  28995. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  28996. /**
  28997. * Gets the active textures from the material
  28998. * @returns an array of textures
  28999. */
  29000. getActiveTextures(): BaseTexture[];
  29001. /**
  29002. * Specifies if the material uses a texture
  29003. * @param texture defines the texture to check against the material
  29004. * @returns a boolean specifying if the material uses the texture
  29005. */
  29006. hasTexture(texture: BaseTexture): boolean;
  29007. /**
  29008. * Makes a duplicate of the material, and gives it a new name
  29009. * @param name defines the new name for the duplicated material
  29010. * @returns the cloned material
  29011. */
  29012. clone(name: string): ShaderMaterial;
  29013. /**
  29014. * Disposes the material
  29015. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29016. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29017. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29018. */
  29019. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29020. /**
  29021. * Serializes this material in a JSON representation
  29022. * @returns the serialized material object
  29023. */
  29024. serialize(): any;
  29025. /**
  29026. * Creates a shader material from parsed shader material data
  29027. * @param source defines the JSON representation of the material
  29028. * @param scene defines the hosting scene
  29029. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29030. * @returns a new material
  29031. */
  29032. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29033. /**
  29034. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29035. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29036. * @param url defines the url to load from
  29037. * @param scene defines the hosting scene
  29038. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29039. * @returns a promise that will resolve to the new ShaderMaterial
  29040. */
  29041. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29042. /**
  29043. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29044. * @param snippetId defines the snippet to load
  29045. * @param scene defines the hosting scene
  29046. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29047. * @returns a promise that will resolve to the new ShaderMaterial
  29048. */
  29049. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29050. }
  29051. }
  29052. declare module BABYLON {
  29053. /** @hidden */
  29054. export var colorPixelShader: {
  29055. name: string;
  29056. shader: string;
  29057. };
  29058. }
  29059. declare module BABYLON {
  29060. /** @hidden */
  29061. export var colorVertexShader: {
  29062. name: string;
  29063. shader: string;
  29064. };
  29065. }
  29066. declare module BABYLON {
  29067. /**
  29068. * Line mesh
  29069. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29070. */
  29071. export class LinesMesh extends Mesh {
  29072. /**
  29073. * If vertex color should be applied to the mesh
  29074. */
  29075. readonly useVertexColor?: boolean | undefined;
  29076. /**
  29077. * If vertex alpha should be applied to the mesh
  29078. */
  29079. readonly useVertexAlpha?: boolean | undefined;
  29080. /**
  29081. * Color of the line (Default: White)
  29082. */
  29083. color: Color3;
  29084. /**
  29085. * Alpha of the line (Default: 1)
  29086. */
  29087. alpha: number;
  29088. /**
  29089. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29090. * This margin is expressed in world space coordinates, so its value may vary.
  29091. * Default value is 0.1
  29092. */
  29093. intersectionThreshold: number;
  29094. private _colorShader;
  29095. private color4;
  29096. /**
  29097. * Creates a new LinesMesh
  29098. * @param name defines the name
  29099. * @param scene defines the hosting scene
  29100. * @param parent defines the parent mesh if any
  29101. * @param source defines the optional source LinesMesh used to clone data from
  29102. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29103. * When false, achieved by calling a clone(), also passing False.
  29104. * This will make creation of children, recursive.
  29105. * @param useVertexColor defines if this LinesMesh supports vertex color
  29106. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29107. */
  29108. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29109. /**
  29110. * If vertex color should be applied to the mesh
  29111. */
  29112. useVertexColor?: boolean | undefined,
  29113. /**
  29114. * If vertex alpha should be applied to the mesh
  29115. */
  29116. useVertexAlpha?: boolean | undefined);
  29117. private _addClipPlaneDefine;
  29118. private _removeClipPlaneDefine;
  29119. isReady(): boolean;
  29120. /**
  29121. * Returns the string "LineMesh"
  29122. */
  29123. getClassName(): string;
  29124. /**
  29125. * @hidden
  29126. */
  29127. get material(): Material;
  29128. /**
  29129. * @hidden
  29130. */
  29131. set material(value: Material);
  29132. /**
  29133. * @hidden
  29134. */
  29135. get checkCollisions(): boolean;
  29136. set checkCollisions(value: boolean);
  29137. /** @hidden */
  29138. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29139. /** @hidden */
  29140. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29141. /**
  29142. * Disposes of the line mesh
  29143. * @param doNotRecurse If children should be disposed
  29144. */
  29145. dispose(doNotRecurse?: boolean): void;
  29146. /**
  29147. * Returns a new LineMesh object cloned from the current one.
  29148. */
  29149. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29150. /**
  29151. * Creates a new InstancedLinesMesh object from the mesh model.
  29152. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29153. * @param name defines the name of the new instance
  29154. * @returns a new InstancedLinesMesh
  29155. */
  29156. createInstance(name: string): InstancedLinesMesh;
  29157. }
  29158. /**
  29159. * Creates an instance based on a source LinesMesh
  29160. */
  29161. export class InstancedLinesMesh extends InstancedMesh {
  29162. /**
  29163. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29164. * This margin is expressed in world space coordinates, so its value may vary.
  29165. * Initialized with the intersectionThreshold value of the source LinesMesh
  29166. */
  29167. intersectionThreshold: number;
  29168. constructor(name: string, source: LinesMesh);
  29169. /**
  29170. * Returns the string "InstancedLinesMesh".
  29171. */
  29172. getClassName(): string;
  29173. }
  29174. }
  29175. declare module BABYLON {
  29176. /** @hidden */
  29177. export var linePixelShader: {
  29178. name: string;
  29179. shader: string;
  29180. };
  29181. }
  29182. declare module BABYLON {
  29183. /** @hidden */
  29184. export var lineVertexShader: {
  29185. name: string;
  29186. shader: string;
  29187. };
  29188. }
  29189. declare module BABYLON {
  29190. interface Scene {
  29191. /** @hidden */
  29192. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29193. }
  29194. interface AbstractMesh {
  29195. /**
  29196. * Gets the edgesRenderer associated with the mesh
  29197. */
  29198. edgesRenderer: Nullable<EdgesRenderer>;
  29199. }
  29200. interface LinesMesh {
  29201. /**
  29202. * Enables the edge rendering mode on the mesh.
  29203. * This mode makes the mesh edges visible
  29204. * @param epsilon defines the maximal distance between two angles to detect a face
  29205. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29206. * @returns the currentAbstractMesh
  29207. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29208. */
  29209. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29210. }
  29211. interface InstancedLinesMesh {
  29212. /**
  29213. * Enables the edge rendering mode on the mesh.
  29214. * This mode makes the mesh edges visible
  29215. * @param epsilon defines the maximal distance between two angles to detect a face
  29216. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29217. * @returns the current InstancedLinesMesh
  29218. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29219. */
  29220. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29221. }
  29222. /**
  29223. * Defines the minimum contract an Edges renderer should follow.
  29224. */
  29225. export interface IEdgesRenderer extends IDisposable {
  29226. /**
  29227. * Gets or sets a boolean indicating if the edgesRenderer is active
  29228. */
  29229. isEnabled: boolean;
  29230. /**
  29231. * Renders the edges of the attached mesh,
  29232. */
  29233. render(): void;
  29234. /**
  29235. * Checks whether or not the edges renderer is ready to render.
  29236. * @return true if ready, otherwise false.
  29237. */
  29238. isReady(): boolean;
  29239. /**
  29240. * List of instances to render in case the source mesh has instances
  29241. */
  29242. customInstances: SmartArray<Matrix>;
  29243. }
  29244. /**
  29245. * Defines the additional options of the edges renderer
  29246. */
  29247. export interface IEdgesRendererOptions {
  29248. /**
  29249. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29250. * If not defined, the default value is true
  29251. */
  29252. useAlternateEdgeFinder?: boolean;
  29253. /**
  29254. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29255. * If not defined, the default value is true.
  29256. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  29257. * This option is used only if useAlternateEdgeFinder = true
  29258. */
  29259. useFastVertexMerger?: boolean;
  29260. /**
  29261. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit within which vertices are considered to be equal.
  29262. * The default value is 1e-6
  29263. * This option is used only if useAlternateEdgeFinder = true
  29264. */
  29265. epsilonVertexMerge?: number;
  29266. /**
  29267. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  29268. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  29269. * This option is used only if useAlternateEdgeFinder = true
  29270. */
  29271. applyTessellation?: boolean;
  29272. /**
  29273. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  29274. * The default value is 1e-6
  29275. * This option is used only if useAlternateEdgeFinder = true
  29276. */
  29277. epsilonVertexAligned?: number;
  29278. }
  29279. /**
  29280. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29281. */
  29282. export class EdgesRenderer implements IEdgesRenderer {
  29283. /**
  29284. * Define the size of the edges with an orthographic camera
  29285. */
  29286. edgesWidthScalerForOrthographic: number;
  29287. /**
  29288. * Define the size of the edges with a perspective camera
  29289. */
  29290. edgesWidthScalerForPerspective: number;
  29291. protected _source: AbstractMesh;
  29292. protected _linesPositions: number[];
  29293. protected _linesNormals: number[];
  29294. protected _linesIndices: number[];
  29295. protected _epsilon: number;
  29296. protected _indicesCount: number;
  29297. protected _lineShader: ShaderMaterial;
  29298. protected _ib: DataBuffer;
  29299. protected _buffers: {
  29300. [key: string]: Nullable<VertexBuffer>;
  29301. };
  29302. protected _buffersForInstances: {
  29303. [key: string]: Nullable<VertexBuffer>;
  29304. };
  29305. protected _checkVerticesInsteadOfIndices: boolean;
  29306. protected _options: Nullable<IEdgesRendererOptions>;
  29307. private _meshRebuildObserver;
  29308. private _meshDisposeObserver;
  29309. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29310. isEnabled: boolean;
  29311. /** Gets the vertices generated by the edge renderer */
  29312. get linesPositions(): Immutable<Array<number>>;
  29313. /** Gets the normals generated by the edge renderer */
  29314. get linesNormals(): Immutable<Array<number>>;
  29315. /** Gets the indices generated by the edge renderer */
  29316. get linesIndices(): Immutable<Array<number>>;
  29317. /**
  29318. * List of instances to render in case the source mesh has instances
  29319. */
  29320. customInstances: SmartArray<Matrix>;
  29321. private static GetShader;
  29322. /**
  29323. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29324. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29325. * @param source Mesh used to create edges
  29326. * @param epsilon sum of angles in adjacency to check for edge
  29327. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29328. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29329. * @param options The options to apply when generating the edges
  29330. */
  29331. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29332. protected _prepareRessources(): void;
  29333. /** @hidden */
  29334. _rebuild(): void;
  29335. /**
  29336. * Releases the required resources for the edges renderer
  29337. */
  29338. dispose(): void;
  29339. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29340. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29341. /**
  29342. * Checks if the pair of p0 and p1 is en edge
  29343. * @param faceIndex
  29344. * @param edge
  29345. * @param faceNormals
  29346. * @param p0
  29347. * @param p1
  29348. * @private
  29349. */
  29350. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29351. /**
  29352. * push line into the position, normal and index buffer
  29353. * @protected
  29354. */
  29355. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29356. /**
  29357. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29358. */
  29359. private _tessellateTriangle;
  29360. private _generateEdgesLinesAlternate;
  29361. /**
  29362. * Generates lines edges from adjacencjes
  29363. * @private
  29364. */
  29365. _generateEdgesLines(): void;
  29366. /**
  29367. * Checks whether or not the edges renderer is ready to render.
  29368. * @return true if ready, otherwise false.
  29369. */
  29370. isReady(): boolean;
  29371. /**
  29372. * Renders the edges of the attached mesh,
  29373. */
  29374. render(): void;
  29375. }
  29376. /**
  29377. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29378. */
  29379. export class LineEdgesRenderer extends EdgesRenderer {
  29380. /**
  29381. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29382. * @param source LineMesh used to generate edges
  29383. * @param epsilon not important (specified angle for edge detection)
  29384. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29385. */
  29386. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29387. /**
  29388. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29389. */
  29390. _generateEdgesLines(): void;
  29391. }
  29392. }
  29393. declare module BABYLON {
  29394. /**
  29395. * This represents the object necessary to create a rendering group.
  29396. * This is exclusively used and created by the rendering manager.
  29397. * To modify the behavior, you use the available helpers in your scene or meshes.
  29398. * @hidden
  29399. */
  29400. export class RenderingGroup {
  29401. index: number;
  29402. private static _zeroVector;
  29403. private _scene;
  29404. private _opaqueSubMeshes;
  29405. private _transparentSubMeshes;
  29406. private _alphaTestSubMeshes;
  29407. private _depthOnlySubMeshes;
  29408. private _particleSystems;
  29409. private _spriteManagers;
  29410. private _opaqueSortCompareFn;
  29411. private _alphaTestSortCompareFn;
  29412. private _transparentSortCompareFn;
  29413. private _renderOpaque;
  29414. private _renderAlphaTest;
  29415. private _renderTransparent;
  29416. /** @hidden */
  29417. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29418. onBeforeTransparentRendering: () => void;
  29419. /**
  29420. * Set the opaque sort comparison function.
  29421. * If null the sub meshes will be render in the order they were created
  29422. */
  29423. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29424. /**
  29425. * Set the alpha test sort comparison function.
  29426. * If null the sub meshes will be render in the order they were created
  29427. */
  29428. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29429. /**
  29430. * Set the transparent sort comparison function.
  29431. * If null the sub meshes will be render in the order they were created
  29432. */
  29433. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29434. /**
  29435. * Creates a new rendering group.
  29436. * @param index The rendering group index
  29437. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29438. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29439. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29440. */
  29441. 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>);
  29442. /**
  29443. * Render all the sub meshes contained in the group.
  29444. * @param customRenderFunction Used to override the default render behaviour of the group.
  29445. * @returns true if rendered some submeshes.
  29446. */
  29447. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29448. /**
  29449. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29450. * @param subMeshes The submeshes to render
  29451. */
  29452. private renderOpaqueSorted;
  29453. /**
  29454. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29455. * @param subMeshes The submeshes to render
  29456. */
  29457. private renderAlphaTestSorted;
  29458. /**
  29459. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29460. * @param subMeshes The submeshes to render
  29461. */
  29462. private renderTransparentSorted;
  29463. /**
  29464. * Renders the submeshes in a specified order.
  29465. * @param subMeshes The submeshes to sort before render
  29466. * @param sortCompareFn The comparison function use to sort
  29467. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29468. * @param transparent Specifies to activate blending if true
  29469. */
  29470. private static renderSorted;
  29471. /**
  29472. * Renders the submeshes in the order they were dispatched (no sort applied).
  29473. * @param subMeshes The submeshes to render
  29474. */
  29475. private static renderUnsorted;
  29476. /**
  29477. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29478. * are rendered back to front if in the same alpha index.
  29479. *
  29480. * @param a The first submesh
  29481. * @param b The second submesh
  29482. * @returns The result of the comparison
  29483. */
  29484. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29485. /**
  29486. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29487. * are rendered back to front.
  29488. *
  29489. * @param a The first submesh
  29490. * @param b The second submesh
  29491. * @returns The result of the comparison
  29492. */
  29493. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29494. /**
  29495. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29496. * are rendered front to back (prevent overdraw).
  29497. *
  29498. * @param a The first submesh
  29499. * @param b The second submesh
  29500. * @returns The result of the comparison
  29501. */
  29502. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29503. /**
  29504. * Resets the different lists of submeshes to prepare a new frame.
  29505. */
  29506. prepare(): void;
  29507. dispose(): void;
  29508. /**
  29509. * Inserts the submesh in its correct queue depending on its material.
  29510. * @param subMesh The submesh to dispatch
  29511. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29512. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29513. */
  29514. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29515. dispatchSprites(spriteManager: ISpriteManager): void;
  29516. dispatchParticles(particleSystem: IParticleSystem): void;
  29517. private _renderParticles;
  29518. private _renderSprites;
  29519. }
  29520. }
  29521. declare module BABYLON {
  29522. /**
  29523. * Interface describing the different options available in the rendering manager
  29524. * regarding Auto Clear between groups.
  29525. */
  29526. export interface IRenderingManagerAutoClearSetup {
  29527. /**
  29528. * Defines whether or not autoclear is enable.
  29529. */
  29530. autoClear: boolean;
  29531. /**
  29532. * Defines whether or not to autoclear the depth buffer.
  29533. */
  29534. depth: boolean;
  29535. /**
  29536. * Defines whether or not to autoclear the stencil buffer.
  29537. */
  29538. stencil: boolean;
  29539. }
  29540. /**
  29541. * This class is used by the onRenderingGroupObservable
  29542. */
  29543. export class RenderingGroupInfo {
  29544. /**
  29545. * The Scene that being rendered
  29546. */
  29547. scene: Scene;
  29548. /**
  29549. * The camera currently used for the rendering pass
  29550. */
  29551. camera: Nullable<Camera>;
  29552. /**
  29553. * The ID of the renderingGroup being processed
  29554. */
  29555. renderingGroupId: number;
  29556. }
  29557. /**
  29558. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29559. * It is enable to manage the different groups as well as the different necessary sort functions.
  29560. * This should not be used directly aside of the few static configurations
  29561. */
  29562. export class RenderingManager {
  29563. /**
  29564. * The max id used for rendering groups (not included)
  29565. */
  29566. static MAX_RENDERINGGROUPS: number;
  29567. /**
  29568. * The min id used for rendering groups (included)
  29569. */
  29570. static MIN_RENDERINGGROUPS: number;
  29571. /**
  29572. * Used to globally prevent autoclearing scenes.
  29573. */
  29574. static AUTOCLEAR: boolean;
  29575. /**
  29576. * @hidden
  29577. */
  29578. _useSceneAutoClearSetup: boolean;
  29579. private _scene;
  29580. private _renderingGroups;
  29581. private _depthStencilBufferAlreadyCleaned;
  29582. private _autoClearDepthStencil;
  29583. private _customOpaqueSortCompareFn;
  29584. private _customAlphaTestSortCompareFn;
  29585. private _customTransparentSortCompareFn;
  29586. private _renderingGroupInfo;
  29587. /**
  29588. * Instantiates a new rendering group for a particular scene
  29589. * @param scene Defines the scene the groups belongs to
  29590. */
  29591. constructor(scene: Scene);
  29592. private _clearDepthStencilBuffer;
  29593. /**
  29594. * Renders the entire managed groups. This is used by the scene or the different render targets.
  29595. * @hidden
  29596. */
  29597. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29598. /**
  29599. * Resets the different information of the group to prepare a new frame
  29600. * @hidden
  29601. */
  29602. reset(): void;
  29603. /**
  29604. * Dispose and release the group and its associated resources.
  29605. * @hidden
  29606. */
  29607. dispose(): void;
  29608. /**
  29609. * Clear the info related to rendering groups preventing retention points during dispose.
  29610. */
  29611. freeRenderingGroups(): void;
  29612. private _prepareRenderingGroup;
  29613. /**
  29614. * Add a sprite manager to the rendering manager in order to render it this frame.
  29615. * @param spriteManager Define the sprite manager to render
  29616. */
  29617. dispatchSprites(spriteManager: ISpriteManager): void;
  29618. /**
  29619. * Add a particle system to the rendering manager in order to render it this frame.
  29620. * @param particleSystem Define the particle system to render
  29621. */
  29622. dispatchParticles(particleSystem: IParticleSystem): void;
  29623. /**
  29624. * Add a submesh to the manager in order to render it this frame
  29625. * @param subMesh The submesh to dispatch
  29626. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29627. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29628. */
  29629. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29630. /**
  29631. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  29632. * This allowed control for front to back rendering or reversely depending of the special needs.
  29633. *
  29634. * @param renderingGroupId The rendering group id corresponding to its index
  29635. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29636. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29637. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29638. */
  29639. 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;
  29640. /**
  29641. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29642. *
  29643. * @param renderingGroupId The rendering group id corresponding to its index
  29644. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29645. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29646. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29647. */
  29648. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29649. /**
  29650. * Gets the current auto clear configuration for one rendering group of the rendering
  29651. * manager.
  29652. * @param index the rendering group index to get the information for
  29653. * @returns The auto clear setup for the requested rendering group
  29654. */
  29655. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29656. }
  29657. }
  29658. declare module BABYLON {
  29659. /**
  29660. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29661. */
  29662. export interface ICustomShaderOptions {
  29663. /**
  29664. * Gets or sets the custom shader name to use
  29665. */
  29666. shaderName: string;
  29667. /**
  29668. * The list of attribute names used in the shader
  29669. */
  29670. attributes?: string[];
  29671. /**
  29672. * The list of uniform names used in the shader
  29673. */
  29674. uniforms?: string[];
  29675. /**
  29676. * The list of sampler names used in the shader
  29677. */
  29678. samplers?: string[];
  29679. /**
  29680. * The list of defines used in the shader
  29681. */
  29682. defines?: string[];
  29683. }
  29684. /**
  29685. * Interface to implement to create a shadow generator compatible with BJS.
  29686. */
  29687. export interface IShadowGenerator {
  29688. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29689. id: string;
  29690. /**
  29691. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29692. * @returns The render target texture if present otherwise, null
  29693. */
  29694. getShadowMap(): Nullable<RenderTargetTexture>;
  29695. /**
  29696. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29697. * @param subMesh The submesh we want to render in the shadow map
  29698. * @param useInstances Defines whether will draw in the map using instances
  29699. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29700. * @returns true if ready otherwise, false
  29701. */
  29702. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29703. /**
  29704. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29705. * @param defines Defines of the material we want to update
  29706. * @param lightIndex Index of the light in the enabled light list of the material
  29707. */
  29708. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29709. /**
  29710. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29711. * defined in the generator but impacting the effect).
  29712. * It implies the uniforms available on the materials are the standard BJS ones.
  29713. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29714. * @param effect The effect we are binding the information for
  29715. */
  29716. bindShadowLight(lightIndex: string, effect: Effect): void;
  29717. /**
  29718. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29719. * (eq to shadow projection matrix * light transform matrix)
  29720. * @returns The transform matrix used to create the shadow map
  29721. */
  29722. getTransformMatrix(): Matrix;
  29723. /**
  29724. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29725. * Cube and 2D textures for instance.
  29726. */
  29727. recreateShadowMap(): void;
  29728. /**
  29729. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  29730. * @param onCompiled Callback triggered at the and of the effects compilation
  29731. * @param options Sets of optional options forcing the compilation with different modes
  29732. */
  29733. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29734. useInstances: boolean;
  29735. }>): void;
  29736. /**
  29737. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  29738. * @param options Sets of optional options forcing the compilation with different modes
  29739. * @returns A promise that resolves when the compilation completes
  29740. */
  29741. forceCompilationAsync(options?: Partial<{
  29742. useInstances: boolean;
  29743. }>): Promise<void>;
  29744. /**
  29745. * Serializes the shadow generator setup to a json object.
  29746. * @returns The serialized JSON object
  29747. */
  29748. serialize(): any;
  29749. /**
  29750. * Disposes the Shadow map and related Textures and effects.
  29751. */
  29752. dispose(): void;
  29753. }
  29754. /**
  29755. * Default implementation IShadowGenerator.
  29756. * This is the main object responsible of generating shadows in the framework.
  29757. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29758. */
  29759. export class ShadowGenerator implements IShadowGenerator {
  29760. private static _Counter;
  29761. /**
  29762. * Name of the shadow generator class
  29763. */
  29764. static CLASSNAME: string;
  29765. /**
  29766. * Shadow generator mode None: no filtering applied.
  29767. */
  29768. static readonly FILTER_NONE: number;
  29769. /**
  29770. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29771. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29772. */
  29773. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29774. /**
  29775. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29776. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29777. */
  29778. static readonly FILTER_POISSONSAMPLING: number;
  29779. /**
  29780. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29781. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29782. */
  29783. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29784. /**
  29785. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29786. * edge artifacts on steep falloff.
  29787. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29788. */
  29789. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29790. /**
  29791. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29792. * edge artifacts on steep falloff.
  29793. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29794. */
  29795. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29796. /**
  29797. * Shadow generator mode PCF: Percentage Closer Filtering
  29798. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29799. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29800. */
  29801. static readonly FILTER_PCF: number;
  29802. /**
  29803. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29804. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29805. * Contact Hardening
  29806. */
  29807. static readonly FILTER_PCSS: number;
  29808. /**
  29809. * Reserved for PCF and PCSS
  29810. * Highest Quality.
  29811. *
  29812. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29813. *
  29814. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29815. */
  29816. static readonly QUALITY_HIGH: number;
  29817. /**
  29818. * Reserved for PCF and PCSS
  29819. * Good tradeoff for quality/perf cross devices
  29820. *
  29821. * Execute PCF on a 3*3 kernel.
  29822. *
  29823. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29824. */
  29825. static readonly QUALITY_MEDIUM: number;
  29826. /**
  29827. * Reserved for PCF and PCSS
  29828. * The lowest quality but the fastest.
  29829. *
  29830. * Execute PCF on a 1*1 kernel.
  29831. *
  29832. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29833. */
  29834. static readonly QUALITY_LOW: number;
  29835. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29836. id: string;
  29837. /** Gets or sets the custom shader name to use */
  29838. customShaderOptions: ICustomShaderOptions;
  29839. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29840. customAllowRendering: (subMesh: SubMesh) => boolean;
  29841. /**
  29842. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29843. */
  29844. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29845. /**
  29846. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29847. */
  29848. onAfterShadowMapRenderObservable: Observable<Effect>;
  29849. /**
  29850. * Observable triggered before a mesh is rendered in the shadow map.
  29851. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29852. */
  29853. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29854. /**
  29855. * Observable triggered after a mesh is rendered in the shadow map.
  29856. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29857. */
  29858. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29859. protected _bias: number;
  29860. /**
  29861. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29862. */
  29863. get bias(): number;
  29864. /**
  29865. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29866. */
  29867. set bias(bias: number);
  29868. protected _normalBias: number;
  29869. /**
  29870. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  29871. */
  29872. get normalBias(): number;
  29873. /**
  29874. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  29875. */
  29876. set normalBias(normalBias: number);
  29877. protected _blurBoxOffset: number;
  29878. /**
  29879. * Gets the blur box offset: offset applied during the blur pass.
  29880. * Only useful if useKernelBlur = false
  29881. */
  29882. get blurBoxOffset(): number;
  29883. /**
  29884. * Sets the blur box offset: offset applied during the blur pass.
  29885. * Only useful if useKernelBlur = false
  29886. */
  29887. set blurBoxOffset(value: number);
  29888. protected _blurScale: number;
  29889. /**
  29890. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29891. * 2 means half of the size.
  29892. */
  29893. get blurScale(): number;
  29894. /**
  29895. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29896. * 2 means half of the size.
  29897. */
  29898. set blurScale(value: number);
  29899. protected _blurKernel: number;
  29900. /**
  29901. * Gets the blur kernel: kernel size of the blur pass.
  29902. * Only useful if useKernelBlur = true
  29903. */
  29904. get blurKernel(): number;
  29905. /**
  29906. * Sets the blur kernel: kernel size of the blur pass.
  29907. * Only useful if useKernelBlur = true
  29908. */
  29909. set blurKernel(value: number);
  29910. protected _useKernelBlur: boolean;
  29911. /**
  29912. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29913. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29914. */
  29915. get useKernelBlur(): boolean;
  29916. /**
  29917. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29918. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29919. */
  29920. set useKernelBlur(value: boolean);
  29921. protected _depthScale: number;
  29922. /**
  29923. * Gets the depth scale used in ESM mode.
  29924. */
  29925. get depthScale(): number;
  29926. /**
  29927. * Sets the depth scale used in ESM mode.
  29928. * This can override the scale stored on the light.
  29929. */
  29930. set depthScale(value: number);
  29931. protected _validateFilter(filter: number): number;
  29932. protected _filter: number;
  29933. /**
  29934. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29935. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29936. */
  29937. get filter(): number;
  29938. /**
  29939. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29940. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29941. */
  29942. set filter(value: number);
  29943. /**
  29944. * Gets if the current filter is set to Poisson Sampling.
  29945. */
  29946. get usePoissonSampling(): boolean;
  29947. /**
  29948. * Sets the current filter to Poisson Sampling.
  29949. */
  29950. set usePoissonSampling(value: boolean);
  29951. /**
  29952. * Gets if the current filter is set to ESM.
  29953. */
  29954. get useExponentialShadowMap(): boolean;
  29955. /**
  29956. * Sets the current filter is to ESM.
  29957. */
  29958. set useExponentialShadowMap(value: boolean);
  29959. /**
  29960. * Gets if the current filter is set to filtered ESM.
  29961. */
  29962. get useBlurExponentialShadowMap(): boolean;
  29963. /**
  29964. * Gets if the current filter is set to filtered ESM.
  29965. */
  29966. set useBlurExponentialShadowMap(value: boolean);
  29967. /**
  29968. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29969. * exponential to prevent steep falloff artifacts).
  29970. */
  29971. get useCloseExponentialShadowMap(): boolean;
  29972. /**
  29973. * Sets the current filter to "close ESM" (using the inverse of the
  29974. * exponential to prevent steep falloff artifacts).
  29975. */
  29976. set useCloseExponentialShadowMap(value: boolean);
  29977. /**
  29978. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29979. * exponential to prevent steep falloff artifacts).
  29980. */
  29981. get useBlurCloseExponentialShadowMap(): boolean;
  29982. /**
  29983. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29984. * exponential to prevent steep falloff artifacts).
  29985. */
  29986. set useBlurCloseExponentialShadowMap(value: boolean);
  29987. /**
  29988. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29989. */
  29990. get usePercentageCloserFiltering(): boolean;
  29991. /**
  29992. * Sets the current filter to "PCF" (percentage closer filtering).
  29993. */
  29994. set usePercentageCloserFiltering(value: boolean);
  29995. protected _filteringQuality: number;
  29996. /**
  29997. * Gets the PCF or PCSS Quality.
  29998. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29999. */
  30000. get filteringQuality(): number;
  30001. /**
  30002. * Sets the PCF or PCSS Quality.
  30003. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30004. */
  30005. set filteringQuality(filteringQuality: number);
  30006. /**
  30007. * Gets if the current filter is set to "PCSS" (contact hardening).
  30008. */
  30009. get useContactHardeningShadow(): boolean;
  30010. /**
  30011. * Sets the current filter to "PCSS" (contact hardening).
  30012. */
  30013. set useContactHardeningShadow(value: boolean);
  30014. protected _contactHardeningLightSizeUVRatio: number;
  30015. /**
  30016. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30017. * Using a ratio helps keeping shape stability independently of the map size.
  30018. *
  30019. * It does not account for the light projection as it was having too much
  30020. * instability during the light setup or during light position changes.
  30021. *
  30022. * Only valid if useContactHardeningShadow is true.
  30023. */
  30024. get contactHardeningLightSizeUVRatio(): number;
  30025. /**
  30026. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30027. * Using a ratio helps keeping shape stability independently of the map size.
  30028. *
  30029. * It does not account for the light projection as it was having too much
  30030. * instability during the light setup or during light position changes.
  30031. *
  30032. * Only valid if useContactHardeningShadow is true.
  30033. */
  30034. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30035. protected _darkness: number;
  30036. /** Gets or sets the actual darkness of a shadow */
  30037. get darkness(): number;
  30038. set darkness(value: number);
  30039. /**
  30040. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30041. * 0 means strongest and 1 would means no shadow.
  30042. * @returns the darkness.
  30043. */
  30044. getDarkness(): number;
  30045. /**
  30046. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30047. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30048. * @returns the shadow generator allowing fluent coding.
  30049. */
  30050. setDarkness(darkness: number): ShadowGenerator;
  30051. protected _transparencyShadow: boolean;
  30052. /** Gets or sets the ability to have transparent shadow */
  30053. get transparencyShadow(): boolean;
  30054. set transparencyShadow(value: boolean);
  30055. /**
  30056. * Sets the ability to have transparent shadow (boolean).
  30057. * @param transparent True if transparent else False
  30058. * @returns the shadow generator allowing fluent coding
  30059. */
  30060. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30061. /**
  30062. * Enables or disables shadows with varying strength based on the transparency
  30063. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30064. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30065. * mesh.visibility * alphaTexture.a
  30066. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30067. */
  30068. enableSoftTransparentShadow: boolean;
  30069. protected _shadowMap: Nullable<RenderTargetTexture>;
  30070. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30071. /**
  30072. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30073. * @returns The render target texture if present otherwise, null
  30074. */
  30075. getShadowMap(): Nullable<RenderTargetTexture>;
  30076. /**
  30077. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30078. * @returns The render target texture if the shadow map is present otherwise, null
  30079. */
  30080. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30081. /**
  30082. * Gets the class name of that object
  30083. * @returns "ShadowGenerator"
  30084. */
  30085. getClassName(): string;
  30086. /**
  30087. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30088. * @param mesh Mesh to add
  30089. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30090. * @returns the Shadow Generator itself
  30091. */
  30092. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30093. /**
  30094. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30095. * @param mesh Mesh to remove
  30096. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30097. * @returns the Shadow Generator itself
  30098. */
  30099. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30100. /**
  30101. * Controls the extent to which the shadows fade out at the edge of the frustum
  30102. */
  30103. frustumEdgeFalloff: number;
  30104. protected _light: IShadowLight;
  30105. /**
  30106. * Returns the associated light object.
  30107. * @returns the light generating the shadow
  30108. */
  30109. getLight(): IShadowLight;
  30110. /**
  30111. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30112. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30113. * It might on the other hand introduce peter panning.
  30114. */
  30115. forceBackFacesOnly: boolean;
  30116. protected _scene: Scene;
  30117. protected _lightDirection: Vector3;
  30118. protected _viewMatrix: Matrix;
  30119. protected _projectionMatrix: Matrix;
  30120. protected _transformMatrix: Matrix;
  30121. protected _cachedPosition: Vector3;
  30122. protected _cachedDirection: Vector3;
  30123. protected _cachedDefines: string;
  30124. protected _currentRenderID: number;
  30125. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30126. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30127. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30128. protected _blurPostProcesses: PostProcess[];
  30129. protected _mapSize: number;
  30130. protected _currentFaceIndex: number;
  30131. protected _currentFaceIndexCache: number;
  30132. protected _textureType: number;
  30133. protected _defaultTextureMatrix: Matrix;
  30134. protected _storedUniqueId: Nullable<number>;
  30135. protected _nameForCustomEffect: string;
  30136. /** @hidden */
  30137. static _SceneComponentInitialization: (scene: Scene) => void;
  30138. /**
  30139. * Gets or sets the size of the texture what stores the shadows
  30140. */
  30141. get mapSize(): number;
  30142. set mapSize(size: number);
  30143. /**
  30144. * Creates a ShadowGenerator object.
  30145. * A ShadowGenerator is the required tool to use the shadows.
  30146. * Each light casting shadows needs to use its own ShadowGenerator.
  30147. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30148. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30149. * @param light The light object generating the shadows.
  30150. * @param usefulFloatFirst 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.
  30151. */
  30152. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30153. protected _initializeGenerator(): void;
  30154. protected _createTargetRenderTexture(): void;
  30155. protected _initializeShadowMap(): void;
  30156. protected _initializeBlurRTTAndPostProcesses(): void;
  30157. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30158. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30159. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30160. protected _applyFilterValues(): void;
  30161. /**
  30162. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30163. * @param onCompiled Callback triggered at the and of the effects compilation
  30164. * @param options Sets of optional options forcing the compilation with different modes
  30165. */
  30166. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30167. useInstances: boolean;
  30168. }>): void;
  30169. /**
  30170. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30171. * @param options Sets of optional options forcing the compilation with different modes
  30172. * @returns A promise that resolves when the compilation completes
  30173. */
  30174. forceCompilationAsync(options?: Partial<{
  30175. useInstances: boolean;
  30176. }>): Promise<void>;
  30177. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30178. private _prepareShadowDefines;
  30179. /**
  30180. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30181. * @param subMesh The submesh we want to render in the shadow map
  30182. * @param useInstances Defines whether will draw in the map using instances
  30183. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30184. * @returns true if ready otherwise, false
  30185. */
  30186. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30187. /**
  30188. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30189. * @param defines Defines of the material we want to update
  30190. * @param lightIndex Index of the light in the enabled light list of the material
  30191. */
  30192. prepareDefines(defines: any, lightIndex: number): void;
  30193. /**
  30194. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30195. * defined in the generator but impacting the effect).
  30196. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30197. * @param effect The effect we are binding the information for
  30198. */
  30199. bindShadowLight(lightIndex: string, effect: Effect): void;
  30200. /**
  30201. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30202. * (eq to shadow projection matrix * light transform matrix)
  30203. * @returns The transform matrix used to create the shadow map
  30204. */
  30205. getTransformMatrix(): Matrix;
  30206. /**
  30207. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30208. * Cube and 2D textures for instance.
  30209. */
  30210. recreateShadowMap(): void;
  30211. protected _disposeBlurPostProcesses(): void;
  30212. protected _disposeRTTandPostProcesses(): void;
  30213. /**
  30214. * Disposes the ShadowGenerator.
  30215. * Returns nothing.
  30216. */
  30217. dispose(): void;
  30218. /**
  30219. * Serializes the shadow generator setup to a json object.
  30220. * @returns The serialized JSON object
  30221. */
  30222. serialize(): any;
  30223. /**
  30224. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30225. * @param parsedShadowGenerator The JSON object to parse
  30226. * @param scene The scene to create the shadow map for
  30227. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30228. * @returns The parsed shadow generator
  30229. */
  30230. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30231. }
  30232. }
  30233. declare module BABYLON {
  30234. /**
  30235. * Options to be used when creating a shadow depth material
  30236. */
  30237. export interface IIOptionShadowDepthMaterial {
  30238. /** Variables in the vertex shader code that need to have their names remapped.
  30239. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30240. * "var_name" should be either: worldPos or vNormalW
  30241. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30242. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30243. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30244. */
  30245. remappedVariables?: string[];
  30246. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30247. standalone?: boolean;
  30248. }
  30249. /**
  30250. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30251. */
  30252. export class ShadowDepthWrapper {
  30253. private _scene;
  30254. private _options?;
  30255. private _baseMaterial;
  30256. private _onEffectCreatedObserver;
  30257. private _subMeshToEffect;
  30258. private _subMeshToDepthEffect;
  30259. private _meshes;
  30260. /** @hidden */
  30261. _matriceNames: any;
  30262. /** Gets the standalone status of the wrapper */
  30263. get standalone(): boolean;
  30264. /** Gets the base material the wrapper is built upon */
  30265. get baseMaterial(): Material;
  30266. /**
  30267. * Instantiate a new shadow depth wrapper.
  30268. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30269. * generate the shadow depth map. For more information, please refer to the documentation:
  30270. * https://doc.babylonjs.com/babylon101/shadows
  30271. * @param baseMaterial Material to wrap
  30272. * @param scene Define the scene the material belongs to
  30273. * @param options Options used to create the wrapper
  30274. */
  30275. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30276. /**
  30277. * Gets the effect to use to generate the depth map
  30278. * @param subMesh subMesh to get the effect for
  30279. * @param shadowGenerator shadow generator to get the effect for
  30280. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30281. */
  30282. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30283. /**
  30284. * Specifies that the submesh is ready to be used for depth rendering
  30285. * @param subMesh submesh to check
  30286. * @param defines the list of defines to take into account when checking the effect
  30287. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30288. * @param useInstances specifies that instances should be used
  30289. * @returns a boolean indicating that the submesh is ready or not
  30290. */
  30291. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30292. /**
  30293. * Disposes the resources
  30294. */
  30295. dispose(): void;
  30296. private _makeEffect;
  30297. }
  30298. }
  30299. declare module BABYLON {
  30300. /**
  30301. * Options for compiling materials.
  30302. */
  30303. export interface IMaterialCompilationOptions {
  30304. /**
  30305. * Defines whether clip planes are enabled.
  30306. */
  30307. clipPlane: boolean;
  30308. /**
  30309. * Defines whether instances are enabled.
  30310. */
  30311. useInstances: boolean;
  30312. }
  30313. /**
  30314. * Options passed when calling customShaderNameResolve
  30315. */
  30316. export interface ICustomShaderNameResolveOptions {
  30317. /**
  30318. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  30319. */
  30320. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30321. }
  30322. /**
  30323. * Base class for the main features of a material in Babylon.js
  30324. */
  30325. export class Material implements IAnimatable {
  30326. /**
  30327. * Returns the triangle fill mode
  30328. */
  30329. static readonly TriangleFillMode: number;
  30330. /**
  30331. * Returns the wireframe mode
  30332. */
  30333. static readonly WireFrameFillMode: number;
  30334. /**
  30335. * Returns the point fill mode
  30336. */
  30337. static readonly PointFillMode: number;
  30338. /**
  30339. * Returns the point list draw mode
  30340. */
  30341. static readonly PointListDrawMode: number;
  30342. /**
  30343. * Returns the line list draw mode
  30344. */
  30345. static readonly LineListDrawMode: number;
  30346. /**
  30347. * Returns the line loop draw mode
  30348. */
  30349. static readonly LineLoopDrawMode: number;
  30350. /**
  30351. * Returns the line strip draw mode
  30352. */
  30353. static readonly LineStripDrawMode: number;
  30354. /**
  30355. * Returns the triangle strip draw mode
  30356. */
  30357. static readonly TriangleStripDrawMode: number;
  30358. /**
  30359. * Returns the triangle fan draw mode
  30360. */
  30361. static readonly TriangleFanDrawMode: number;
  30362. /**
  30363. * Stores the clock-wise side orientation
  30364. */
  30365. static readonly ClockWiseSideOrientation: number;
  30366. /**
  30367. * Stores the counter clock-wise side orientation
  30368. */
  30369. static readonly CounterClockWiseSideOrientation: number;
  30370. /**
  30371. * The dirty texture flag value
  30372. */
  30373. static readonly TextureDirtyFlag: number;
  30374. /**
  30375. * The dirty light flag value
  30376. */
  30377. static readonly LightDirtyFlag: number;
  30378. /**
  30379. * The dirty fresnel flag value
  30380. */
  30381. static readonly FresnelDirtyFlag: number;
  30382. /**
  30383. * The dirty attribute flag value
  30384. */
  30385. static readonly AttributesDirtyFlag: number;
  30386. /**
  30387. * The dirty misc flag value
  30388. */
  30389. static readonly MiscDirtyFlag: number;
  30390. /**
  30391. * The dirty prepass flag value
  30392. */
  30393. static readonly PrePassDirtyFlag: number;
  30394. /**
  30395. * The all dirty flag value
  30396. */
  30397. static readonly AllDirtyFlag: number;
  30398. /**
  30399. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30400. */
  30401. static readonly MATERIAL_OPAQUE: number;
  30402. /**
  30403. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30404. */
  30405. static readonly MATERIAL_ALPHATEST: number;
  30406. /**
  30407. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30408. */
  30409. static readonly MATERIAL_ALPHABLEND: number;
  30410. /**
  30411. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30412. * They are also discarded below the alpha cutoff threshold to improve performances.
  30413. */
  30414. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30415. /**
  30416. * The Whiteout method is used to blend normals.
  30417. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30418. */
  30419. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30420. /**
  30421. * The Reoriented Normal Mapping method is used to blend normals.
  30422. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30423. */
  30424. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30425. /**
  30426. * Custom callback helping to override the default shader used in the material.
  30427. */
  30428. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30429. /**
  30430. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30431. */
  30432. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30433. /**
  30434. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30435. * This means that the material can keep using a previous shader while a new one is being compiled.
  30436. * This is mostly used when shader parallel compilation is supported (true by default)
  30437. */
  30438. allowShaderHotSwapping: boolean;
  30439. /**
  30440. * The ID of the material
  30441. */
  30442. id: string;
  30443. /**
  30444. * Gets or sets the unique id of the material
  30445. */
  30446. uniqueId: number;
  30447. /**
  30448. * The name of the material
  30449. */
  30450. name: string;
  30451. /**
  30452. * Gets or sets user defined metadata
  30453. */
  30454. metadata: any;
  30455. /**
  30456. * For internal use only. Please do not use.
  30457. */
  30458. reservedDataStore: any;
  30459. /**
  30460. * Specifies if the ready state should be checked on each call
  30461. */
  30462. checkReadyOnEveryCall: boolean;
  30463. /**
  30464. * Specifies if the ready state should be checked once
  30465. */
  30466. checkReadyOnlyOnce: boolean;
  30467. /**
  30468. * The state of the material
  30469. */
  30470. state: string;
  30471. /**
  30472. * If the material can be rendered to several textures with MRT extension
  30473. */
  30474. get canRenderToMRT(): boolean;
  30475. /**
  30476. * The alpha value of the material
  30477. */
  30478. protected _alpha: number;
  30479. /**
  30480. * List of inspectable custom properties (used by the Inspector)
  30481. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30482. */
  30483. inspectableCustomProperties: IInspectable[];
  30484. /**
  30485. * Sets the alpha value of the material
  30486. */
  30487. set alpha(value: number);
  30488. /**
  30489. * Gets the alpha value of the material
  30490. */
  30491. get alpha(): number;
  30492. /**
  30493. * Specifies if back face culling is enabled
  30494. */
  30495. protected _backFaceCulling: boolean;
  30496. /**
  30497. * Sets the back-face culling state
  30498. */
  30499. set backFaceCulling(value: boolean);
  30500. /**
  30501. * Gets the back-face culling state
  30502. */
  30503. get backFaceCulling(): boolean;
  30504. /**
  30505. * Stores the value for side orientation
  30506. */
  30507. sideOrientation: number;
  30508. /**
  30509. * Callback triggered when the material is compiled
  30510. */
  30511. onCompiled: Nullable<(effect: Effect) => void>;
  30512. /**
  30513. * Callback triggered when an error occurs
  30514. */
  30515. onError: Nullable<(effect: Effect, errors: string) => void>;
  30516. /**
  30517. * Callback triggered to get the render target textures
  30518. */
  30519. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30520. /**
  30521. * Gets a boolean indicating that current material needs to register RTT
  30522. */
  30523. get hasRenderTargetTextures(): boolean;
  30524. /**
  30525. * Specifies if the material should be serialized
  30526. */
  30527. doNotSerialize: boolean;
  30528. /**
  30529. * @hidden
  30530. */
  30531. _storeEffectOnSubMeshes: boolean;
  30532. /**
  30533. * Stores the animations for the material
  30534. */
  30535. animations: Nullable<Array<Animation>>;
  30536. /**
  30537. * An event triggered when the material is disposed
  30538. */
  30539. onDisposeObservable: Observable<Material>;
  30540. /**
  30541. * An observer which watches for dispose events
  30542. */
  30543. private _onDisposeObserver;
  30544. private _onUnBindObservable;
  30545. /**
  30546. * Called during a dispose event
  30547. */
  30548. set onDispose(callback: () => void);
  30549. private _onBindObservable;
  30550. /**
  30551. * An event triggered when the material is bound
  30552. */
  30553. get onBindObservable(): Observable<AbstractMesh>;
  30554. /**
  30555. * An observer which watches for bind events
  30556. */
  30557. private _onBindObserver;
  30558. /**
  30559. * Called during a bind event
  30560. */
  30561. set onBind(callback: (Mesh: AbstractMesh) => void);
  30562. /**
  30563. * An event triggered when the material is unbound
  30564. */
  30565. get onUnBindObservable(): Observable<Material>;
  30566. protected _onEffectCreatedObservable: Nullable<Observable<{
  30567. effect: Effect;
  30568. subMesh: Nullable<SubMesh>;
  30569. }>>;
  30570. /**
  30571. * An event triggered when the effect is (re)created
  30572. */
  30573. get onEffectCreatedObservable(): Observable<{
  30574. effect: Effect;
  30575. subMesh: Nullable<SubMesh>;
  30576. }>;
  30577. /**
  30578. * Stores the value of the alpha mode
  30579. */
  30580. private _alphaMode;
  30581. /**
  30582. * Sets the value of the alpha mode.
  30583. *
  30584. * | Value | Type | Description |
  30585. * | --- | --- | --- |
  30586. * | 0 | ALPHA_DISABLE | |
  30587. * | 1 | ALPHA_ADD | |
  30588. * | 2 | ALPHA_COMBINE | |
  30589. * | 3 | ALPHA_SUBTRACT | |
  30590. * | 4 | ALPHA_MULTIPLY | |
  30591. * | 5 | ALPHA_MAXIMIZED | |
  30592. * | 6 | ALPHA_ONEONE | |
  30593. * | 7 | ALPHA_PREMULTIPLIED | |
  30594. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30595. * | 9 | ALPHA_INTERPOLATE | |
  30596. * | 10 | ALPHA_SCREENMODE | |
  30597. *
  30598. */
  30599. set alphaMode(value: number);
  30600. /**
  30601. * Gets the value of the alpha mode
  30602. */
  30603. get alphaMode(): number;
  30604. /**
  30605. * Stores the state of the need depth pre-pass value
  30606. */
  30607. private _needDepthPrePass;
  30608. /**
  30609. * Sets the need depth pre-pass value
  30610. */
  30611. set needDepthPrePass(value: boolean);
  30612. /**
  30613. * Gets the depth pre-pass value
  30614. */
  30615. get needDepthPrePass(): boolean;
  30616. /**
  30617. * Can this material render to prepass
  30618. */
  30619. get isPrePassCapable(): boolean;
  30620. /**
  30621. * Specifies if depth writing should be disabled
  30622. */
  30623. disableDepthWrite: boolean;
  30624. /**
  30625. * Specifies if color writing should be disabled
  30626. */
  30627. disableColorWrite: boolean;
  30628. /**
  30629. * Specifies if depth writing should be forced
  30630. */
  30631. forceDepthWrite: boolean;
  30632. /**
  30633. * Specifies the depth function that should be used. 0 means the default engine function
  30634. */
  30635. depthFunction: number;
  30636. /**
  30637. * Specifies if there should be a separate pass for culling
  30638. */
  30639. separateCullingPass: boolean;
  30640. /**
  30641. * Stores the state specifying if fog should be enabled
  30642. */
  30643. private _fogEnabled;
  30644. /**
  30645. * Sets the state for enabling fog
  30646. */
  30647. set fogEnabled(value: boolean);
  30648. /**
  30649. * Gets the value of the fog enabled state
  30650. */
  30651. get fogEnabled(): boolean;
  30652. /**
  30653. * Stores the size of points
  30654. */
  30655. pointSize: number;
  30656. /**
  30657. * Stores the z offset value
  30658. */
  30659. zOffset: number;
  30660. get wireframe(): boolean;
  30661. /**
  30662. * Sets the state of wireframe mode
  30663. */
  30664. set wireframe(value: boolean);
  30665. /**
  30666. * Gets the value specifying if point clouds are enabled
  30667. */
  30668. get pointsCloud(): boolean;
  30669. /**
  30670. * Sets the state of point cloud mode
  30671. */
  30672. set pointsCloud(value: boolean);
  30673. /**
  30674. * Gets the material fill mode
  30675. */
  30676. get fillMode(): number;
  30677. /**
  30678. * Sets the material fill mode
  30679. */
  30680. set fillMode(value: number);
  30681. /**
  30682. * @hidden
  30683. * Stores the effects for the material
  30684. */
  30685. _effect: Nullable<Effect>;
  30686. /**
  30687. * Specifies if uniform buffers should be used
  30688. */
  30689. private _useUBO;
  30690. /**
  30691. * Stores a reference to the scene
  30692. */
  30693. private _scene;
  30694. private _needToBindSceneUbo;
  30695. /**
  30696. * Stores the fill mode state
  30697. */
  30698. private _fillMode;
  30699. /**
  30700. * Specifies if the depth write state should be cached
  30701. */
  30702. private _cachedDepthWriteState;
  30703. /**
  30704. * Specifies if the color write state should be cached
  30705. */
  30706. private _cachedColorWriteState;
  30707. /**
  30708. * Specifies if the depth function state should be cached
  30709. */
  30710. private _cachedDepthFunctionState;
  30711. /**
  30712. * Stores the uniform buffer
  30713. */
  30714. protected _uniformBuffer: UniformBuffer;
  30715. /** @hidden */
  30716. _indexInSceneMaterialArray: number;
  30717. /** @hidden */
  30718. meshMap: Nullable<{
  30719. [id: string]: AbstractMesh | undefined;
  30720. }>;
  30721. /**
  30722. * Creates a material instance
  30723. * @param name defines the name of the material
  30724. * @param scene defines the scene to reference
  30725. * @param doNotAdd specifies if the material should be added to the scene
  30726. */
  30727. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30728. /**
  30729. * Returns a string representation of the current material
  30730. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30731. * @returns a string with material information
  30732. */
  30733. toString(fullDetails?: boolean): string;
  30734. /**
  30735. * Gets the class name of the material
  30736. * @returns a string with the class name of the material
  30737. */
  30738. getClassName(): string;
  30739. /**
  30740. * Specifies if updates for the material been locked
  30741. */
  30742. get isFrozen(): boolean;
  30743. /**
  30744. * Locks updates for the material
  30745. */
  30746. freeze(): void;
  30747. /**
  30748. * Unlocks updates for the material
  30749. */
  30750. unfreeze(): void;
  30751. /**
  30752. * Specifies if the material is ready to be used
  30753. * @param mesh defines the mesh to check
  30754. * @param useInstances specifies if instances should be used
  30755. * @returns a boolean indicating if the material is ready to be used
  30756. */
  30757. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30758. /**
  30759. * Specifies that the submesh is ready to be used
  30760. * @param mesh defines the mesh to check
  30761. * @param subMesh defines which submesh to check
  30762. * @param useInstances specifies that instances should be used
  30763. * @returns a boolean indicating that the submesh is ready or not
  30764. */
  30765. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30766. /**
  30767. * Returns the material effect
  30768. * @returns the effect associated with the material
  30769. */
  30770. getEffect(): Nullable<Effect>;
  30771. /**
  30772. * Returns the current scene
  30773. * @returns a Scene
  30774. */
  30775. getScene(): Scene;
  30776. /**
  30777. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30778. */
  30779. protected _forceAlphaTest: boolean;
  30780. /**
  30781. * The transparency mode of the material.
  30782. */
  30783. protected _transparencyMode: Nullable<number>;
  30784. /**
  30785. * Gets the current transparency mode.
  30786. */
  30787. get transparencyMode(): Nullable<number>;
  30788. /**
  30789. * Sets the transparency mode of the material.
  30790. *
  30791. * | Value | Type | Description |
  30792. * | ----- | ----------------------------------- | ----------- |
  30793. * | 0 | OPAQUE | |
  30794. * | 1 | ALPHATEST | |
  30795. * | 2 | ALPHABLEND | |
  30796. * | 3 | ALPHATESTANDBLEND | |
  30797. *
  30798. */
  30799. set transparencyMode(value: Nullable<number>);
  30800. /**
  30801. * Returns true if alpha blending should be disabled.
  30802. */
  30803. protected get _disableAlphaBlending(): boolean;
  30804. /**
  30805. * Specifies whether or not this material should be rendered in alpha blend mode.
  30806. * @returns a boolean specifying if alpha blending is needed
  30807. */
  30808. needAlphaBlending(): boolean;
  30809. /**
  30810. * Specifies if the mesh will require alpha blending
  30811. * @param mesh defines the mesh to check
  30812. * @returns a boolean specifying if alpha blending is needed for the mesh
  30813. */
  30814. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30815. /**
  30816. * Specifies whether or not this material should be rendered in alpha test mode.
  30817. * @returns a boolean specifying if an alpha test is needed.
  30818. */
  30819. needAlphaTesting(): boolean;
  30820. /**
  30821. * Specifies if material alpha testing should be turned on for the mesh
  30822. * @param mesh defines the mesh to check
  30823. */
  30824. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30825. /**
  30826. * Gets the texture used for the alpha test
  30827. * @returns the texture to use for alpha testing
  30828. */
  30829. getAlphaTestTexture(): Nullable<BaseTexture>;
  30830. /**
  30831. * Marks the material to indicate that it needs to be re-calculated
  30832. */
  30833. markDirty(): void;
  30834. /** @hidden */
  30835. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30836. /**
  30837. * Binds the material to the mesh
  30838. * @param world defines the world transformation matrix
  30839. * @param mesh defines the mesh to bind the material to
  30840. */
  30841. bind(world: Matrix, mesh?: Mesh): void;
  30842. /**
  30843. * Binds the submesh to the material
  30844. * @param world defines the world transformation matrix
  30845. * @param mesh defines the mesh containing the submesh
  30846. * @param subMesh defines the submesh to bind the material to
  30847. */
  30848. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30849. /**
  30850. * Binds the world matrix to the material
  30851. * @param world defines the world transformation matrix
  30852. */
  30853. bindOnlyWorldMatrix(world: Matrix): void;
  30854. /**
  30855. * Binds the view matrix to the effect
  30856. * @param effect defines the effect to bind the view matrix to
  30857. */
  30858. bindView(effect: Effect): void;
  30859. /**
  30860. * Binds the view projection and projection matrices to the effect
  30861. * @param effect defines the effect to bind the view projection and projection matrices to
  30862. */
  30863. bindViewProjection(effect: Effect): void;
  30864. /**
  30865. * Binds the view matrix to the effect
  30866. * @param effect defines the effect to bind the view matrix to
  30867. * @param variableName name of the shader variable that will hold the eye position
  30868. */
  30869. bindEyePosition(effect: Effect, variableName?: string): void;
  30870. /**
  30871. * Processes to execute after binding the material to a mesh
  30872. * @param mesh defines the rendered mesh
  30873. */
  30874. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30875. /**
  30876. * Unbinds the material from the mesh
  30877. */
  30878. unbind(): void;
  30879. /**
  30880. * Gets the active textures from the material
  30881. * @returns an array of textures
  30882. */
  30883. getActiveTextures(): BaseTexture[];
  30884. /**
  30885. * Specifies if the material uses a texture
  30886. * @param texture defines the texture to check against the material
  30887. * @returns a boolean specifying if the material uses the texture
  30888. */
  30889. hasTexture(texture: BaseTexture): boolean;
  30890. /**
  30891. * Makes a duplicate of the material, and gives it a new name
  30892. * @param name defines the new name for the duplicated material
  30893. * @returns the cloned material
  30894. */
  30895. clone(name: string): Nullable<Material>;
  30896. /**
  30897. * Gets the meshes bound to the material
  30898. * @returns an array of meshes bound to the material
  30899. */
  30900. getBindedMeshes(): AbstractMesh[];
  30901. /**
  30902. * Force shader compilation
  30903. * @param mesh defines the mesh associated with this material
  30904. * @param onCompiled defines a function to execute once the material is compiled
  30905. * @param options defines the options to configure the compilation
  30906. * @param onError defines a function to execute if the material fails compiling
  30907. */
  30908. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30909. /**
  30910. * Force shader compilation
  30911. * @param mesh defines the mesh that will use this material
  30912. * @param options defines additional options for compiling the shaders
  30913. * @returns a promise that resolves when the compilation completes
  30914. */
  30915. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30916. private static readonly _AllDirtyCallBack;
  30917. private static readonly _ImageProcessingDirtyCallBack;
  30918. private static readonly _TextureDirtyCallBack;
  30919. private static readonly _FresnelDirtyCallBack;
  30920. private static readonly _MiscDirtyCallBack;
  30921. private static readonly _PrePassDirtyCallBack;
  30922. private static readonly _LightsDirtyCallBack;
  30923. private static readonly _AttributeDirtyCallBack;
  30924. private static _FresnelAndMiscDirtyCallBack;
  30925. private static _TextureAndMiscDirtyCallBack;
  30926. private static readonly _DirtyCallbackArray;
  30927. private static readonly _RunDirtyCallBacks;
  30928. /**
  30929. * Marks a define in the material to indicate that it needs to be re-computed
  30930. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30931. */
  30932. markAsDirty(flag: number): void;
  30933. /**
  30934. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30935. * @param func defines a function which checks material defines against the submeshes
  30936. */
  30937. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30938. /**
  30939. * Indicates that the scene should check if the rendering now needs a prepass
  30940. */
  30941. protected _markScenePrePassDirty(): void;
  30942. /**
  30943. * Indicates that we need to re-calculated for all submeshes
  30944. */
  30945. protected _markAllSubMeshesAsAllDirty(): void;
  30946. /**
  30947. * Indicates that image processing needs to be re-calculated for all submeshes
  30948. */
  30949. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30950. /**
  30951. * Indicates that textures need to be re-calculated for all submeshes
  30952. */
  30953. protected _markAllSubMeshesAsTexturesDirty(): void;
  30954. /**
  30955. * Indicates that fresnel needs to be re-calculated for all submeshes
  30956. */
  30957. protected _markAllSubMeshesAsFresnelDirty(): void;
  30958. /**
  30959. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30960. */
  30961. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30962. /**
  30963. * Indicates that lights need to be re-calculated for all submeshes
  30964. */
  30965. protected _markAllSubMeshesAsLightsDirty(): void;
  30966. /**
  30967. * Indicates that attributes need to be re-calculated for all submeshes
  30968. */
  30969. protected _markAllSubMeshesAsAttributesDirty(): void;
  30970. /**
  30971. * Indicates that misc needs to be re-calculated for all submeshes
  30972. */
  30973. protected _markAllSubMeshesAsMiscDirty(): void;
  30974. /**
  30975. * Indicates that prepass needs to be re-calculated for all submeshes
  30976. */
  30977. protected _markAllSubMeshesAsPrePassDirty(): void;
  30978. /**
  30979. * Indicates that textures and misc need to be re-calculated for all submeshes
  30980. */
  30981. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30982. /**
  30983. * Sets the required values to the prepass renderer.
  30984. * @param prePassRenderer defines the prepass renderer to setup.
  30985. * @returns true if the pre pass is needed.
  30986. */
  30987. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30988. /**
  30989. * Disposes the material
  30990. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30991. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30992. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30993. */
  30994. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30995. /** @hidden */
  30996. private releaseVertexArrayObject;
  30997. /**
  30998. * Serializes this material
  30999. * @returns the serialized material object
  31000. */
  31001. serialize(): any;
  31002. /**
  31003. * Creates a material from parsed material data
  31004. * @param parsedMaterial defines parsed material data
  31005. * @param scene defines the hosting scene
  31006. * @param rootUrl defines the root URL to use to load textures
  31007. * @returns a new material
  31008. */
  31009. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31010. }
  31011. }
  31012. declare module BABYLON {
  31013. /**
  31014. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31015. * separate meshes. This can be use to improve performances.
  31016. * @see https://doc.babylonjs.com/how_to/multi_materials
  31017. */
  31018. export class MultiMaterial extends Material {
  31019. private _subMaterials;
  31020. /**
  31021. * Gets or Sets the list of Materials used within the multi material.
  31022. * They need to be ordered according to the submeshes order in the associated mesh
  31023. */
  31024. get subMaterials(): Nullable<Material>[];
  31025. set subMaterials(value: Nullable<Material>[]);
  31026. /**
  31027. * Function used to align with Node.getChildren()
  31028. * @returns the list of Materials used within the multi material
  31029. */
  31030. getChildren(): Nullable<Material>[];
  31031. /**
  31032. * Instantiates a new Multi Material
  31033. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31034. * separate meshes. This can be use to improve performances.
  31035. * @see https://doc.babylonjs.com/how_to/multi_materials
  31036. * @param name Define the name in the scene
  31037. * @param scene Define the scene the material belongs to
  31038. */
  31039. constructor(name: string, scene: Scene);
  31040. private _hookArray;
  31041. /**
  31042. * Get one of the submaterial by its index in the submaterials array
  31043. * @param index The index to look the sub material at
  31044. * @returns The Material if the index has been defined
  31045. */
  31046. getSubMaterial(index: number): Nullable<Material>;
  31047. /**
  31048. * Get the list of active textures for the whole sub materials list.
  31049. * @returns All the textures that will be used during the rendering
  31050. */
  31051. getActiveTextures(): BaseTexture[];
  31052. /**
  31053. * Specifies if any sub-materials of this multi-material use a given texture.
  31054. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31055. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31056. */
  31057. hasTexture(texture: BaseTexture): boolean;
  31058. /**
  31059. * Gets the current class name of the material e.g. "MultiMaterial"
  31060. * Mainly use in serialization.
  31061. * @returns the class name
  31062. */
  31063. getClassName(): string;
  31064. /**
  31065. * Checks if the material is ready to render the requested sub mesh
  31066. * @param mesh Define the mesh the submesh belongs to
  31067. * @param subMesh Define the sub mesh to look readiness for
  31068. * @param useInstances Define whether or not the material is used with instances
  31069. * @returns true if ready, otherwise false
  31070. */
  31071. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31072. /**
  31073. * Clones the current material and its related sub materials
  31074. * @param name Define the name of the newly cloned material
  31075. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31076. * @returns the cloned material
  31077. */
  31078. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31079. /**
  31080. * Serializes the materials into a JSON representation.
  31081. * @returns the JSON representation
  31082. */
  31083. serialize(): any;
  31084. /**
  31085. * Dispose the material and release its associated resources
  31086. * @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)
  31087. * @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)
  31088. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  31089. */
  31090. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31091. /**
  31092. * Creates a MultiMaterial from parsed MultiMaterial data.
  31093. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31094. * @param scene defines the hosting scene
  31095. * @returns a new MultiMaterial
  31096. */
  31097. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31098. }
  31099. }
  31100. declare module BABYLON {
  31101. /** @hidden */
  31102. export interface ICustomEffect {
  31103. effect: Effect;
  31104. defines: string;
  31105. }
  31106. /**
  31107. * Defines a subdivision inside a mesh
  31108. */
  31109. export class SubMesh implements ICullable {
  31110. /** the material index to use */
  31111. materialIndex: number;
  31112. /** vertex index start */
  31113. verticesStart: number;
  31114. /** vertices count */
  31115. verticesCount: number;
  31116. /** index start */
  31117. indexStart: number;
  31118. /** indices count */
  31119. indexCount: number;
  31120. /** @hidden */
  31121. _materialDefines: Nullable<MaterialDefines>;
  31122. /** @hidden */
  31123. _materialEffect: Nullable<Effect>;
  31124. /** @hidden */
  31125. _effectOverride: Nullable<Effect>;
  31126. private _customEffects;
  31127. /**
  31128. * Gets material defines used by the effect associated to the sub mesh
  31129. */
  31130. get materialDefines(): Nullable<MaterialDefines>;
  31131. /**
  31132. * Sets material defines used by the effect associated to the sub mesh
  31133. */
  31134. set materialDefines(defines: Nullable<MaterialDefines>);
  31135. /** @hidden */
  31136. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  31137. /** @hidden */
  31138. _removeCustomEffect(name: string): void;
  31139. /**
  31140. * Gets associated effect
  31141. */
  31142. get effect(): Nullable<Effect>;
  31143. /**
  31144. * Sets associated effect (effect used to render this submesh)
  31145. * @param effect defines the effect to associate with
  31146. * @param defines defines the set of defines used to compile this effect
  31147. */
  31148. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31149. /** @hidden */
  31150. _linesIndexCount: number;
  31151. private _mesh;
  31152. private _renderingMesh;
  31153. private _boundingInfo;
  31154. private _linesIndexBuffer;
  31155. /** @hidden */
  31156. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31157. /** @hidden */
  31158. _trianglePlanes: Plane[];
  31159. /** @hidden */
  31160. _lastColliderTransformMatrix: Nullable<Matrix>;
  31161. /** @hidden */
  31162. _renderId: number;
  31163. /** @hidden */
  31164. _alphaIndex: number;
  31165. /** @hidden */
  31166. _distanceToCamera: number;
  31167. /** @hidden */
  31168. _id: number;
  31169. private _currentMaterial;
  31170. /**
  31171. * Add a new submesh to a mesh
  31172. * @param materialIndex defines the material index to use
  31173. * @param verticesStart defines vertex index start
  31174. * @param verticesCount defines vertices count
  31175. * @param indexStart defines index start
  31176. * @param indexCount defines indices count
  31177. * @param mesh defines the parent mesh
  31178. * @param renderingMesh defines an optional rendering mesh
  31179. * @param createBoundingBox defines if bounding box should be created for this submesh
  31180. * @returns the new submesh
  31181. */
  31182. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31183. /**
  31184. * Creates a new submesh
  31185. * @param materialIndex defines the material index to use
  31186. * @param verticesStart defines vertex index start
  31187. * @param verticesCount defines vertices count
  31188. * @param indexStart defines index start
  31189. * @param indexCount defines indices count
  31190. * @param mesh defines the parent mesh
  31191. * @param renderingMesh defines an optional rendering mesh
  31192. * @param createBoundingBox defines if bounding box should be created for this submesh
  31193. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31194. */
  31195. constructor(
  31196. /** the material index to use */
  31197. materialIndex: number,
  31198. /** vertex index start */
  31199. verticesStart: number,
  31200. /** vertices count */
  31201. verticesCount: number,
  31202. /** index start */
  31203. indexStart: number,
  31204. /** indices count */
  31205. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31206. /**
  31207. * Returns true if this submesh covers the entire parent mesh
  31208. * @ignorenaming
  31209. */
  31210. get IsGlobal(): boolean;
  31211. /**
  31212. * Returns the submesh BoundingInfo object
  31213. * @returns current bounding info (or mesh's one if the submesh is global)
  31214. */
  31215. getBoundingInfo(): BoundingInfo;
  31216. /**
  31217. * Sets the submesh BoundingInfo
  31218. * @param boundingInfo defines the new bounding info to use
  31219. * @returns the SubMesh
  31220. */
  31221. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31222. /**
  31223. * Returns the mesh of the current submesh
  31224. * @return the parent mesh
  31225. */
  31226. getMesh(): AbstractMesh;
  31227. /**
  31228. * Returns the rendering mesh of the submesh
  31229. * @returns the rendering mesh (could be different from parent mesh)
  31230. */
  31231. getRenderingMesh(): Mesh;
  31232. /**
  31233. * Returns the replacement mesh of the submesh
  31234. * @returns the replacement mesh (could be different from parent mesh)
  31235. */
  31236. getReplacementMesh(): Nullable<AbstractMesh>;
  31237. /**
  31238. * Returns the effective mesh of the submesh
  31239. * @returns the effective mesh (could be different from parent mesh)
  31240. */
  31241. getEffectiveMesh(): AbstractMesh;
  31242. /**
  31243. * Returns the submesh material
  31244. * @returns null or the current material
  31245. */
  31246. getMaterial(): Nullable<Material>;
  31247. private _IsMultiMaterial;
  31248. /**
  31249. * Sets a new updated BoundingInfo object to the submesh
  31250. * @param data defines an optional position array to use to determine the bounding info
  31251. * @returns the SubMesh
  31252. */
  31253. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31254. /** @hidden */
  31255. _checkCollision(collider: Collider): boolean;
  31256. /**
  31257. * Updates the submesh BoundingInfo
  31258. * @param world defines the world matrix to use to update the bounding info
  31259. * @returns the submesh
  31260. */
  31261. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31262. /**
  31263. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31264. * @param frustumPlanes defines the frustum planes
  31265. * @returns true if the submesh is intersecting with the frustum
  31266. */
  31267. isInFrustum(frustumPlanes: Plane[]): boolean;
  31268. /**
  31269. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31270. * @param frustumPlanes defines the frustum planes
  31271. * @returns true if the submesh is inside the frustum
  31272. */
  31273. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31274. /**
  31275. * Renders the submesh
  31276. * @param enableAlphaMode defines if alpha needs to be used
  31277. * @returns the submesh
  31278. */
  31279. render(enableAlphaMode: boolean): SubMesh;
  31280. /**
  31281. * @hidden
  31282. */
  31283. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31284. /**
  31285. * Checks if the submesh intersects with a ray
  31286. * @param ray defines the ray to test
  31287. * @returns true is the passed ray intersects the submesh bounding box
  31288. */
  31289. canIntersects(ray: Ray): boolean;
  31290. /**
  31291. * Intersects current submesh with a ray
  31292. * @param ray defines the ray to test
  31293. * @param positions defines mesh's positions array
  31294. * @param indices defines mesh's indices array
  31295. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31296. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31297. * @returns intersection info or null if no intersection
  31298. */
  31299. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31300. /** @hidden */
  31301. private _intersectLines;
  31302. /** @hidden */
  31303. private _intersectUnIndexedLines;
  31304. /** @hidden */
  31305. private _intersectTriangles;
  31306. /** @hidden */
  31307. private _intersectUnIndexedTriangles;
  31308. /** @hidden */
  31309. _rebuild(): void;
  31310. /**
  31311. * Creates a new submesh from the passed mesh
  31312. * @param newMesh defines the new hosting mesh
  31313. * @param newRenderingMesh defines an optional rendering mesh
  31314. * @returns the new submesh
  31315. */
  31316. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31317. /**
  31318. * Release associated resources
  31319. */
  31320. dispose(): void;
  31321. /**
  31322. * Gets the class name
  31323. * @returns the string "SubMesh".
  31324. */
  31325. getClassName(): string;
  31326. /**
  31327. * Creates a new submesh from indices data
  31328. * @param materialIndex the index of the main mesh material
  31329. * @param startIndex the index where to start the copy in the mesh indices array
  31330. * @param indexCount the number of indices to copy then from the startIndex
  31331. * @param mesh the main mesh to create the submesh from
  31332. * @param renderingMesh the optional rendering mesh
  31333. * @returns a new submesh
  31334. */
  31335. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31336. }
  31337. }
  31338. declare module BABYLON {
  31339. /**
  31340. * Class used to represent data loading progression
  31341. */
  31342. export class SceneLoaderFlags {
  31343. private static _ForceFullSceneLoadingForIncremental;
  31344. private static _ShowLoadingScreen;
  31345. private static _CleanBoneMatrixWeights;
  31346. private static _loggingLevel;
  31347. /**
  31348. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31349. */
  31350. static get ForceFullSceneLoadingForIncremental(): boolean;
  31351. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31352. /**
  31353. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31354. */
  31355. static get ShowLoadingScreen(): boolean;
  31356. static set ShowLoadingScreen(value: boolean);
  31357. /**
  31358. * Defines the current logging level (while loading the scene)
  31359. * @ignorenaming
  31360. */
  31361. static get loggingLevel(): number;
  31362. static set loggingLevel(value: number);
  31363. /**
  31364. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31365. */
  31366. static get CleanBoneMatrixWeights(): boolean;
  31367. static set CleanBoneMatrixWeights(value: boolean);
  31368. }
  31369. }
  31370. declare module BABYLON {
  31371. /**
  31372. * Class used to store geometry data (vertex buffers + index buffer)
  31373. */
  31374. export class Geometry implements IGetSetVerticesData {
  31375. /**
  31376. * Gets or sets the ID of the geometry
  31377. */
  31378. id: string;
  31379. /**
  31380. * Gets or sets the unique ID of the geometry
  31381. */
  31382. uniqueId: number;
  31383. /**
  31384. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31385. */
  31386. delayLoadState: number;
  31387. /**
  31388. * Gets the file containing the data to load when running in delay load state
  31389. */
  31390. delayLoadingFile: Nullable<string>;
  31391. /**
  31392. * Callback called when the geometry is updated
  31393. */
  31394. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31395. private _scene;
  31396. private _engine;
  31397. private _meshes;
  31398. private _totalVertices;
  31399. /** @hidden */
  31400. _indices: IndicesArray;
  31401. /** @hidden */
  31402. _vertexBuffers: {
  31403. [key: string]: VertexBuffer;
  31404. };
  31405. private _isDisposed;
  31406. private _extend;
  31407. private _boundingBias;
  31408. /** @hidden */
  31409. _delayInfo: Array<string>;
  31410. private _indexBuffer;
  31411. private _indexBufferIsUpdatable;
  31412. /** @hidden */
  31413. _boundingInfo: Nullable<BoundingInfo>;
  31414. /** @hidden */
  31415. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31416. /** @hidden */
  31417. _softwareSkinningFrameId: number;
  31418. private _vertexArrayObjects;
  31419. private _updatable;
  31420. /** @hidden */
  31421. _positions: Nullable<Vector3[]>;
  31422. private _positionsCache;
  31423. /**
  31424. * 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
  31425. */
  31426. get boundingBias(): Vector2;
  31427. /**
  31428. * 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
  31429. */
  31430. set boundingBias(value: Vector2);
  31431. /**
  31432. * Static function used to attach a new empty geometry to a mesh
  31433. * @param mesh defines the mesh to attach the geometry to
  31434. * @returns the new Geometry
  31435. */
  31436. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31437. /** Get the list of meshes using this geometry */
  31438. get meshes(): Mesh[];
  31439. /**
  31440. * If set to true (false by default), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  31441. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31442. */
  31443. useBoundingInfoFromGeometry: boolean;
  31444. /**
  31445. * Creates a new geometry
  31446. * @param id defines the unique ID
  31447. * @param scene defines the hosting scene
  31448. * @param vertexData defines the VertexData used to get geometry data
  31449. * @param updatable defines if geometry must be updatable (false by default)
  31450. * @param mesh defines the mesh that will be associated with the geometry
  31451. */
  31452. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31453. /**
  31454. * Gets the current extend of the geometry
  31455. */
  31456. get extend(): {
  31457. minimum: Vector3;
  31458. maximum: Vector3;
  31459. };
  31460. /**
  31461. * Gets the hosting scene
  31462. * @returns the hosting Scene
  31463. */
  31464. getScene(): Scene;
  31465. /**
  31466. * Gets the hosting engine
  31467. * @returns the hosting Engine
  31468. */
  31469. getEngine(): Engine;
  31470. /**
  31471. * Defines if the geometry is ready to use
  31472. * @returns true if the geometry is ready to be used
  31473. */
  31474. isReady(): boolean;
  31475. /**
  31476. * Gets a value indicating that the geometry should not be serialized
  31477. */
  31478. get doNotSerialize(): boolean;
  31479. /** @hidden */
  31480. _rebuild(): void;
  31481. /**
  31482. * Affects all geometry data in one call
  31483. * @param vertexData defines the geometry data
  31484. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31485. */
  31486. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31487. /**
  31488. * Set specific vertex data
  31489. * @param kind defines the data kind (Position, normal, etc...)
  31490. * @param data defines the vertex data to use
  31491. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31492. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31493. */
  31494. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31495. /**
  31496. * Removes a specific vertex data
  31497. * @param kind defines the data kind (Position, normal, etc...)
  31498. */
  31499. removeVerticesData(kind: string): void;
  31500. /**
  31501. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31502. * @param buffer defines the vertex buffer to use
  31503. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31504. */
  31505. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31506. /**
  31507. * Update a specific vertex buffer
  31508. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31509. * It will do nothing if the buffer is not updatable
  31510. * @param kind defines the data kind (Position, normal, etc...)
  31511. * @param data defines the data to use
  31512. * @param offset defines the offset in the target buffer where to store the data
  31513. * @param useBytes set to true if the offset is in bytes
  31514. */
  31515. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31516. /**
  31517. * Update a specific vertex buffer
  31518. * This function will create a new buffer if the current one is not updatable
  31519. * @param kind defines the data kind (Position, normal, etc...)
  31520. * @param data defines the data to use
  31521. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31522. */
  31523. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31524. private _updateBoundingInfo;
  31525. /** @hidden */
  31526. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  31527. [kind: string]: Nullable<VertexBuffer>;
  31528. }, overrideVertexArrayObjects?: {
  31529. [key: string]: WebGLVertexArrayObject;
  31530. }): void;
  31531. /**
  31532. * Gets total number of vertices
  31533. * @returns the total number of vertices
  31534. */
  31535. getTotalVertices(): number;
  31536. /**
  31537. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31538. * @param kind defines the data kind (Position, normal, etc...)
  31539. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31540. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31541. * @returns a float array containing vertex data
  31542. */
  31543. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31544. /**
  31545. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31546. * @param kind defines the data kind (Position, normal, etc...)
  31547. * @returns true if the vertex buffer with the specified kind is updatable
  31548. */
  31549. isVertexBufferUpdatable(kind: string): boolean;
  31550. /**
  31551. * Gets a specific vertex buffer
  31552. * @param kind defines the data kind (Position, normal, etc...)
  31553. * @returns a VertexBuffer
  31554. */
  31555. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31556. /**
  31557. * Returns all vertex buffers
  31558. * @return an object holding all vertex buffers indexed by kind
  31559. */
  31560. getVertexBuffers(): Nullable<{
  31561. [key: string]: VertexBuffer;
  31562. }>;
  31563. /**
  31564. * Gets a boolean indicating if specific vertex buffer is present
  31565. * @param kind defines the data kind (Position, normal, etc...)
  31566. * @returns true if data is present
  31567. */
  31568. isVerticesDataPresent(kind: string): boolean;
  31569. /**
  31570. * Gets a list of all attached data kinds (Position, normal, etc...)
  31571. * @returns a list of string containing all kinds
  31572. */
  31573. getVerticesDataKinds(): string[];
  31574. /**
  31575. * Update index buffer
  31576. * @param indices defines the indices to store in the index buffer
  31577. * @param offset defines the offset in the target buffer where to store the data
  31578. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  31579. */
  31580. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31581. /**
  31582. * Creates a new index buffer
  31583. * @param indices defines the indices to store in the index buffer
  31584. * @param totalVertices defines the total number of vertices (could be null)
  31585. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31586. */
  31587. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31588. /**
  31589. * Return the total number of indices
  31590. * @returns the total number of indices
  31591. */
  31592. getTotalIndices(): number;
  31593. /**
  31594. * Gets the index buffer array
  31595. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31596. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31597. * @returns the index buffer array
  31598. */
  31599. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31600. /**
  31601. * Gets the index buffer
  31602. * @return the index buffer
  31603. */
  31604. getIndexBuffer(): Nullable<DataBuffer>;
  31605. /** @hidden */
  31606. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31607. /**
  31608. * Release the associated resources for a specific mesh
  31609. * @param mesh defines the source mesh
  31610. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31611. */
  31612. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31613. /**
  31614. * Apply current geometry to a given mesh
  31615. * @param mesh defines the mesh to apply geometry to
  31616. */
  31617. applyToMesh(mesh: Mesh): void;
  31618. private _updateExtend;
  31619. private _applyToMesh;
  31620. private notifyUpdate;
  31621. /**
  31622. * Load the geometry if it was flagged as delay loaded
  31623. * @param scene defines the hosting scene
  31624. * @param onLoaded defines a callback called when the geometry is loaded
  31625. */
  31626. load(scene: Scene, onLoaded?: () => void): void;
  31627. private _queueLoad;
  31628. /**
  31629. * Invert the geometry to move from a right handed system to a left handed one.
  31630. */
  31631. toLeftHanded(): void;
  31632. /** @hidden */
  31633. _resetPointsArrayCache(): void;
  31634. /** @hidden */
  31635. _generatePointsArray(): boolean;
  31636. /**
  31637. * Gets a value indicating if the geometry is disposed
  31638. * @returns true if the geometry was disposed
  31639. */
  31640. isDisposed(): boolean;
  31641. private _disposeVertexArrayObjects;
  31642. /**
  31643. * Free all associated resources
  31644. */
  31645. dispose(): void;
  31646. /**
  31647. * Clone the current geometry into a new geometry
  31648. * @param id defines the unique ID of the new geometry
  31649. * @returns a new geometry object
  31650. */
  31651. copy(id: string): Geometry;
  31652. /**
  31653. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31654. * @return a JSON representation of the current geometry data (without the vertices data)
  31655. */
  31656. serialize(): any;
  31657. private toNumberArray;
  31658. /**
  31659. * Serialize all vertices data into a JSON object
  31660. * @returns a JSON representation of the current geometry data
  31661. */
  31662. serializeVerticeData(): any;
  31663. /**
  31664. * Extracts a clone of a mesh geometry
  31665. * @param mesh defines the source mesh
  31666. * @param id defines the unique ID of the new geometry object
  31667. * @returns the new geometry object
  31668. */
  31669. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31670. /**
  31671. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31672. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31673. * Be aware Math.random() could cause collisions, but:
  31674. * "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"
  31675. * @returns a string containing a new GUID
  31676. */
  31677. static RandomId(): string;
  31678. /** @hidden */
  31679. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31680. private static _CleanMatricesWeights;
  31681. /**
  31682. * Create a new geometry from persisted data (Using .babylon file format)
  31683. * @param parsedVertexData defines the persisted data
  31684. * @param scene defines the hosting scene
  31685. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31686. * @returns the new geometry object
  31687. */
  31688. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31689. }
  31690. }
  31691. declare module BABYLON {
  31692. /**
  31693. * Defines a target to use with MorphTargetManager
  31694. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31695. */
  31696. export class MorphTarget implements IAnimatable {
  31697. /** defines the name of the target */
  31698. name: string;
  31699. /**
  31700. * Gets or sets the list of animations
  31701. */
  31702. animations: Animation[];
  31703. private _scene;
  31704. private _positions;
  31705. private _normals;
  31706. private _tangents;
  31707. private _uvs;
  31708. private _influence;
  31709. private _uniqueId;
  31710. /**
  31711. * Observable raised when the influence changes
  31712. */
  31713. onInfluenceChanged: Observable<boolean>;
  31714. /** @hidden */
  31715. _onDataLayoutChanged: Observable<void>;
  31716. /**
  31717. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31718. */
  31719. get influence(): number;
  31720. set influence(influence: number);
  31721. /**
  31722. * Gets or sets the id of the morph Target
  31723. */
  31724. id: string;
  31725. private _animationPropertiesOverride;
  31726. /**
  31727. * Gets or sets the animation properties override
  31728. */
  31729. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31730. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31731. /**
  31732. * Creates a new MorphTarget
  31733. * @param name defines the name of the target
  31734. * @param influence defines the influence to use
  31735. * @param scene defines the scene the morphtarget belongs to
  31736. */
  31737. constructor(
  31738. /** defines the name of the target */
  31739. name: string, influence?: number, scene?: Nullable<Scene>);
  31740. /**
  31741. * Gets the unique ID of this manager
  31742. */
  31743. get uniqueId(): number;
  31744. /**
  31745. * Gets a boolean defining if the target contains position data
  31746. */
  31747. get hasPositions(): boolean;
  31748. /**
  31749. * Gets a boolean defining if the target contains normal data
  31750. */
  31751. get hasNormals(): boolean;
  31752. /**
  31753. * Gets a boolean defining if the target contains tangent data
  31754. */
  31755. get hasTangents(): boolean;
  31756. /**
  31757. * Gets a boolean defining if the target contains texture coordinates data
  31758. */
  31759. get hasUVs(): boolean;
  31760. /**
  31761. * Affects position data to this target
  31762. * @param data defines the position data to use
  31763. */
  31764. setPositions(data: Nullable<FloatArray>): void;
  31765. /**
  31766. * Gets the position data stored in this target
  31767. * @returns a FloatArray containing the position data (or null if not present)
  31768. */
  31769. getPositions(): Nullable<FloatArray>;
  31770. /**
  31771. * Affects normal data to this target
  31772. * @param data defines the normal data to use
  31773. */
  31774. setNormals(data: Nullable<FloatArray>): void;
  31775. /**
  31776. * Gets the normal data stored in this target
  31777. * @returns a FloatArray containing the normal data (or null if not present)
  31778. */
  31779. getNormals(): Nullable<FloatArray>;
  31780. /**
  31781. * Affects tangent data to this target
  31782. * @param data defines the tangent data to use
  31783. */
  31784. setTangents(data: Nullable<FloatArray>): void;
  31785. /**
  31786. * Gets the tangent data stored in this target
  31787. * @returns a FloatArray containing the tangent data (or null if not present)
  31788. */
  31789. getTangents(): Nullable<FloatArray>;
  31790. /**
  31791. * Affects texture coordinates data to this target
  31792. * @param data defines the texture coordinates data to use
  31793. */
  31794. setUVs(data: Nullable<FloatArray>): void;
  31795. /**
  31796. * Gets the texture coordinates data stored in this target
  31797. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31798. */
  31799. getUVs(): Nullable<FloatArray>;
  31800. /**
  31801. * Clone the current target
  31802. * @returns a new MorphTarget
  31803. */
  31804. clone(): MorphTarget;
  31805. /**
  31806. * Serializes the current target into a Serialization object
  31807. * @returns the serialized object
  31808. */
  31809. serialize(): any;
  31810. /**
  31811. * Returns the string "MorphTarget"
  31812. * @returns "MorphTarget"
  31813. */
  31814. getClassName(): string;
  31815. /**
  31816. * Creates a new target from serialized data
  31817. * @param serializationObject defines the serialized data to use
  31818. * @returns a new MorphTarget
  31819. */
  31820. static Parse(serializationObject: any): MorphTarget;
  31821. /**
  31822. * Creates a MorphTarget from mesh data
  31823. * @param mesh defines the source mesh
  31824. * @param name defines the name to use for the new target
  31825. * @param influence defines the influence to attach to the target
  31826. * @returns a new MorphTarget
  31827. */
  31828. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31829. }
  31830. }
  31831. declare module BABYLON {
  31832. /**
  31833. * This class is used to deform meshes using morphing between different targets
  31834. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31835. */
  31836. export class MorphTargetManager {
  31837. private _targets;
  31838. private _targetInfluenceChangedObservers;
  31839. private _targetDataLayoutChangedObservers;
  31840. private _activeTargets;
  31841. private _scene;
  31842. private _influences;
  31843. private _supportsNormals;
  31844. private _supportsTangents;
  31845. private _supportsUVs;
  31846. private _vertexCount;
  31847. private _uniqueId;
  31848. private _tempInfluences;
  31849. /**
  31850. * Gets or sets a boolean indicating if normals must be morphed
  31851. */
  31852. enableNormalMorphing: boolean;
  31853. /**
  31854. * Gets or sets a boolean indicating if tangents must be morphed
  31855. */
  31856. enableTangentMorphing: boolean;
  31857. /**
  31858. * Gets or sets a boolean indicating if UV must be morphed
  31859. */
  31860. enableUVMorphing: boolean;
  31861. /**
  31862. * Creates a new MorphTargetManager
  31863. * @param scene defines the current scene
  31864. */
  31865. constructor(scene?: Nullable<Scene>);
  31866. /**
  31867. * Gets the unique ID of this manager
  31868. */
  31869. get uniqueId(): number;
  31870. /**
  31871. * Gets the number of vertices handled by this manager
  31872. */
  31873. get vertexCount(): number;
  31874. /**
  31875. * Gets a boolean indicating if this manager supports morphing of normals
  31876. */
  31877. get supportsNormals(): boolean;
  31878. /**
  31879. * Gets a boolean indicating if this manager supports morphing of tangents
  31880. */
  31881. get supportsTangents(): boolean;
  31882. /**
  31883. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31884. */
  31885. get supportsUVs(): boolean;
  31886. /**
  31887. * Gets the number of targets stored in this manager
  31888. */
  31889. get numTargets(): number;
  31890. /**
  31891. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31892. */
  31893. get numInfluencers(): number;
  31894. /**
  31895. * Gets the list of influences (one per target)
  31896. */
  31897. get influences(): Float32Array;
  31898. /**
  31899. * Gets the active target at specified index. An active target is a target with an influence > 0
  31900. * @param index defines the index to check
  31901. * @returns the requested target
  31902. */
  31903. getActiveTarget(index: number): MorphTarget;
  31904. /**
  31905. * Gets the target at specified index
  31906. * @param index defines the index to check
  31907. * @returns the requested target
  31908. */
  31909. getTarget(index: number): MorphTarget;
  31910. /**
  31911. * Add a new target to this manager
  31912. * @param target defines the target to add
  31913. */
  31914. addTarget(target: MorphTarget): void;
  31915. /**
  31916. * Removes a target from the manager
  31917. * @param target defines the target to remove
  31918. */
  31919. removeTarget(target: MorphTarget): void;
  31920. /**
  31921. * Clone the current manager
  31922. * @returns a new MorphTargetManager
  31923. */
  31924. clone(): MorphTargetManager;
  31925. /**
  31926. * Serializes the current manager into a Serialization object
  31927. * @returns the serialized object
  31928. */
  31929. serialize(): any;
  31930. private _syncActiveTargets;
  31931. /**
  31932. * Syncrhonize the targets with all the meshes using this morph target manager
  31933. */
  31934. synchronize(): void;
  31935. /**
  31936. * Creates a new MorphTargetManager from serialized data
  31937. * @param serializationObject defines the serialized data
  31938. * @param scene defines the hosting scene
  31939. * @returns the new MorphTargetManager
  31940. */
  31941. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31942. }
  31943. }
  31944. declare module BABYLON {
  31945. /**
  31946. * Class used to represent a specific level of detail of a mesh
  31947. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31948. */
  31949. export class MeshLODLevel {
  31950. /** Defines the distance where this level should start being displayed */
  31951. distance: number;
  31952. /** Defines the mesh to use to render this level */
  31953. mesh: Nullable<Mesh>;
  31954. /**
  31955. * Creates a new LOD level
  31956. * @param distance defines the distance where this level should star being displayed
  31957. * @param mesh defines the mesh to use to render this level
  31958. */
  31959. constructor(
  31960. /** Defines the distance where this level should start being displayed */
  31961. distance: number,
  31962. /** Defines the mesh to use to render this level */
  31963. mesh: Nullable<Mesh>);
  31964. }
  31965. }
  31966. declare module BABYLON {
  31967. /**
  31968. * Helper class used to generate a canvas to manipulate images
  31969. */
  31970. export class CanvasGenerator {
  31971. /**
  31972. * Create a new canvas (or offscreen canvas depending on the context)
  31973. * @param width defines the expected width
  31974. * @param height defines the expected height
  31975. * @return a new canvas or offscreen canvas
  31976. */
  31977. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31978. }
  31979. }
  31980. declare module BABYLON {
  31981. /**
  31982. * Mesh representing the ground
  31983. */
  31984. export class GroundMesh extends Mesh {
  31985. /** If octree should be generated */
  31986. generateOctree: boolean;
  31987. private _heightQuads;
  31988. /** @hidden */
  31989. _subdivisionsX: number;
  31990. /** @hidden */
  31991. _subdivisionsY: number;
  31992. /** @hidden */
  31993. _width: number;
  31994. /** @hidden */
  31995. _height: number;
  31996. /** @hidden */
  31997. _minX: number;
  31998. /** @hidden */
  31999. _maxX: number;
  32000. /** @hidden */
  32001. _minZ: number;
  32002. /** @hidden */
  32003. _maxZ: number;
  32004. constructor(name: string, scene: Scene);
  32005. /**
  32006. * "GroundMesh"
  32007. * @returns "GroundMesh"
  32008. */
  32009. getClassName(): string;
  32010. /**
  32011. * The minimum of x and y subdivisions
  32012. */
  32013. get subdivisions(): number;
  32014. /**
  32015. * X subdivisions
  32016. */
  32017. get subdivisionsX(): number;
  32018. /**
  32019. * Y subdivisions
  32020. */
  32021. get subdivisionsY(): number;
  32022. /**
  32023. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32024. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32025. * @param chunksCount the number of subdivisions for x and y
  32026. * @param octreeBlocksSize (Default: 32)
  32027. */
  32028. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32029. /**
  32030. * Returns a height (y) value in the World system :
  32031. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32032. * @param x x coordinate
  32033. * @param z z coordinate
  32034. * @returns the ground y position if (x, z) are outside the ground surface.
  32035. */
  32036. getHeightAtCoordinates(x: number, z: number): number;
  32037. /**
  32038. * Returns a normalized vector (Vector3) orthogonal to the ground
  32039. * at the ground coordinates (x, z) expressed in the World system.
  32040. * @param x x coordinate
  32041. * @param z z coordinate
  32042. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32043. */
  32044. getNormalAtCoordinates(x: number, z: number): Vector3;
  32045. /**
  32046. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32047. * at the ground coordinates (x, z) expressed in the World system.
  32048. * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.
  32049. * @param x x coordinate
  32050. * @param z z coordinate
  32051. * @param ref vector to store the result
  32052. * @returns the GroundMesh.
  32053. */
  32054. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32055. /**
  32056. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32057. * if the ground has been updated.
  32058. * This can be used in the render loop.
  32059. * @returns the GroundMesh.
  32060. */
  32061. updateCoordinateHeights(): GroundMesh;
  32062. private _getFacetAt;
  32063. private _initHeightQuads;
  32064. private _computeHeightQuads;
  32065. /**
  32066. * Serializes this ground mesh
  32067. * @param serializationObject object to write serialization to
  32068. */
  32069. serialize(serializationObject: any): void;
  32070. /**
  32071. * Parses a serialized ground mesh
  32072. * @param parsedMesh the serialized mesh
  32073. * @param scene the scene to create the ground mesh in
  32074. * @returns the created ground mesh
  32075. */
  32076. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32077. }
  32078. }
  32079. declare module BABYLON {
  32080. /**
  32081. * Interface for Physics-Joint data
  32082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32083. */
  32084. export interface PhysicsJointData {
  32085. /**
  32086. * The main pivot of the joint
  32087. */
  32088. mainPivot?: Vector3;
  32089. /**
  32090. * The connected pivot of the joint
  32091. */
  32092. connectedPivot?: Vector3;
  32093. /**
  32094. * The main axis of the joint
  32095. */
  32096. mainAxis?: Vector3;
  32097. /**
  32098. * The connected axis of the joint
  32099. */
  32100. connectedAxis?: Vector3;
  32101. /**
  32102. * The collision of the joint
  32103. */
  32104. collision?: boolean;
  32105. /**
  32106. * Native Oimo/Cannon/Energy data
  32107. */
  32108. nativeParams?: any;
  32109. }
  32110. /**
  32111. * This is a holder class for the physics joint created by the physics plugin
  32112. * It holds a set of functions to control the underlying joint
  32113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32114. */
  32115. export class PhysicsJoint {
  32116. /**
  32117. * The type of the physics joint
  32118. */
  32119. type: number;
  32120. /**
  32121. * The data for the physics joint
  32122. */
  32123. jointData: PhysicsJointData;
  32124. private _physicsJoint;
  32125. protected _physicsPlugin: IPhysicsEnginePlugin;
  32126. /**
  32127. * Initializes the physics joint
  32128. * @param type The type of the physics joint
  32129. * @param jointData The data for the physics joint
  32130. */
  32131. constructor(
  32132. /**
  32133. * The type of the physics joint
  32134. */
  32135. type: number,
  32136. /**
  32137. * The data for the physics joint
  32138. */
  32139. jointData: PhysicsJointData);
  32140. /**
  32141. * Gets the physics joint
  32142. */
  32143. get physicsJoint(): any;
  32144. /**
  32145. * Sets the physics joint
  32146. */
  32147. set physicsJoint(newJoint: any);
  32148. /**
  32149. * Sets the physics plugin
  32150. */
  32151. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32152. /**
  32153. * Execute a function that is physics-plugin specific.
  32154. * @param {Function} func the function that will be executed.
  32155. * It accepts two parameters: the physics world and the physics joint
  32156. */
  32157. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32158. /**
  32159. * Distance-Joint type
  32160. */
  32161. static DistanceJoint: number;
  32162. /**
  32163. * Hinge-Joint type
  32164. */
  32165. static HingeJoint: number;
  32166. /**
  32167. * Ball-and-Socket joint type
  32168. */
  32169. static BallAndSocketJoint: number;
  32170. /**
  32171. * Wheel-Joint type
  32172. */
  32173. static WheelJoint: number;
  32174. /**
  32175. * Slider-Joint type
  32176. */
  32177. static SliderJoint: number;
  32178. /**
  32179. * Prismatic-Joint type
  32180. */
  32181. static PrismaticJoint: number;
  32182. /**
  32183. * Universal-Joint type
  32184. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32185. */
  32186. static UniversalJoint: number;
  32187. /**
  32188. * Hinge-Joint 2 type
  32189. */
  32190. static Hinge2Joint: number;
  32191. /**
  32192. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32193. */
  32194. static PointToPointJoint: number;
  32195. /**
  32196. * Spring-Joint type
  32197. */
  32198. static SpringJoint: number;
  32199. /**
  32200. * Lock-Joint type
  32201. */
  32202. static LockJoint: number;
  32203. }
  32204. /**
  32205. * A class representing a physics distance joint
  32206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32207. */
  32208. export class DistanceJoint extends PhysicsJoint {
  32209. /**
  32210. *
  32211. * @param jointData The data for the Distance-Joint
  32212. */
  32213. constructor(jointData: DistanceJointData);
  32214. /**
  32215. * Update the predefined distance.
  32216. * @param maxDistance The maximum preferred distance
  32217. * @param minDistance The minimum preferred distance
  32218. */
  32219. updateDistance(maxDistance: number, minDistance?: number): void;
  32220. }
  32221. /**
  32222. * Represents a Motor-Enabled Joint
  32223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32224. */
  32225. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32226. /**
  32227. * Initializes the Motor-Enabled Joint
  32228. * @param type The type of the joint
  32229. * @param jointData The physical joint data for the joint
  32230. */
  32231. constructor(type: number, jointData: PhysicsJointData);
  32232. /**
  32233. * Set the motor values.
  32234. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32235. * @param force the force to apply
  32236. * @param maxForce max force for this motor.
  32237. */
  32238. setMotor(force?: number, maxForce?: number): void;
  32239. /**
  32240. * Set the motor's limits.
  32241. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32242. * @param upperLimit The upper limit of the motor
  32243. * @param lowerLimit The lower limit of the motor
  32244. */
  32245. setLimit(upperLimit: number, lowerLimit?: number): void;
  32246. }
  32247. /**
  32248. * This class represents a single physics Hinge-Joint
  32249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32250. */
  32251. export class HingeJoint extends MotorEnabledJoint {
  32252. /**
  32253. * Initializes the Hinge-Joint
  32254. * @param jointData The joint data for the Hinge-Joint
  32255. */
  32256. constructor(jointData: PhysicsJointData);
  32257. /**
  32258. * Set the motor values.
  32259. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32260. * @param {number} force the force to apply
  32261. * @param {number} maxForce max force for this motor.
  32262. */
  32263. setMotor(force?: number, maxForce?: number): void;
  32264. /**
  32265. * Set the motor's limits.
  32266. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32267. * @param upperLimit The upper limit of the motor
  32268. * @param lowerLimit The lower limit of the motor
  32269. */
  32270. setLimit(upperLimit: number, lowerLimit?: number): void;
  32271. }
  32272. /**
  32273. * This class represents a dual hinge physics joint (same as wheel joint)
  32274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32275. */
  32276. export class Hinge2Joint extends MotorEnabledJoint {
  32277. /**
  32278. * Initializes the Hinge2-Joint
  32279. * @param jointData The joint data for the Hinge2-Joint
  32280. */
  32281. constructor(jointData: PhysicsJointData);
  32282. /**
  32283. * Set the motor values.
  32284. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32285. * @param {number} targetSpeed the speed the motor is to reach
  32286. * @param {number} maxForce max force for this motor.
  32287. * @param {motorIndex} the motor's index, 0 or 1.
  32288. */
  32289. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32290. /**
  32291. * Set the motor limits.
  32292. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32293. * @param {number} upperLimit the upper limit
  32294. * @param {number} lowerLimit lower limit
  32295. * @param {motorIndex} the motor's index, 0 or 1.
  32296. */
  32297. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32298. }
  32299. /**
  32300. * Interface for a motor enabled joint
  32301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32302. */
  32303. export interface IMotorEnabledJoint {
  32304. /**
  32305. * Physics joint
  32306. */
  32307. physicsJoint: any;
  32308. /**
  32309. * Sets the motor of the motor-enabled joint
  32310. * @param force The force of the motor
  32311. * @param maxForce The maximum force of the motor
  32312. * @param motorIndex The index of the motor
  32313. */
  32314. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32315. /**
  32316. * Sets the limit of the motor
  32317. * @param upperLimit The upper limit of the motor
  32318. * @param lowerLimit The lower limit of the motor
  32319. * @param motorIndex The index of the motor
  32320. */
  32321. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32322. }
  32323. /**
  32324. * Joint data for a Distance-Joint
  32325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32326. */
  32327. export interface DistanceJointData extends PhysicsJointData {
  32328. /**
  32329. * Max distance the 2 joint objects can be apart
  32330. */
  32331. maxDistance: number;
  32332. }
  32333. /**
  32334. * Joint data from a spring joint
  32335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32336. */
  32337. export interface SpringJointData extends PhysicsJointData {
  32338. /**
  32339. * Length of the spring
  32340. */
  32341. length: number;
  32342. /**
  32343. * Stiffness of the spring
  32344. */
  32345. stiffness: number;
  32346. /**
  32347. * Damping of the spring
  32348. */
  32349. damping: number;
  32350. /** this callback will be called when applying the force to the impostors. */
  32351. forceApplicationCallback: () => void;
  32352. }
  32353. }
  32354. declare module BABYLON {
  32355. /**
  32356. * Holds the data for the raycast result
  32357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32358. */
  32359. export class PhysicsRaycastResult {
  32360. private _hasHit;
  32361. private _hitDistance;
  32362. private _hitNormalWorld;
  32363. private _hitPointWorld;
  32364. private _rayFromWorld;
  32365. private _rayToWorld;
  32366. /**
  32367. * Gets if there was a hit
  32368. */
  32369. get hasHit(): boolean;
  32370. /**
  32371. * Gets the distance from the hit
  32372. */
  32373. get hitDistance(): number;
  32374. /**
  32375. * Gets the hit normal/direction in the world
  32376. */
  32377. get hitNormalWorld(): Vector3;
  32378. /**
  32379. * Gets the hit point in the world
  32380. */
  32381. get hitPointWorld(): Vector3;
  32382. /**
  32383. * Gets the ray "start point" of the ray in the world
  32384. */
  32385. get rayFromWorld(): Vector3;
  32386. /**
  32387. * Gets the ray "end point" of the ray in the world
  32388. */
  32389. get rayToWorld(): Vector3;
  32390. /**
  32391. * Sets the hit data (normal & point in world space)
  32392. * @param hitNormalWorld defines the normal in world space
  32393. * @param hitPointWorld defines the point in world space
  32394. */
  32395. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32396. /**
  32397. * Sets the distance from the start point to the hit point
  32398. * @param distance
  32399. */
  32400. setHitDistance(distance: number): void;
  32401. /**
  32402. * Calculates the distance manually
  32403. */
  32404. calculateHitDistance(): void;
  32405. /**
  32406. * Resets all the values to default
  32407. * @param from The from point on world space
  32408. * @param to The to point on world space
  32409. */
  32410. reset(from?: Vector3, to?: Vector3): void;
  32411. }
  32412. /**
  32413. * Interface for the size containing width and height
  32414. */
  32415. interface IXYZ {
  32416. /**
  32417. * X
  32418. */
  32419. x: number;
  32420. /**
  32421. * Y
  32422. */
  32423. y: number;
  32424. /**
  32425. * Z
  32426. */
  32427. z: number;
  32428. }
  32429. }
  32430. declare module BABYLON {
  32431. /**
  32432. * Interface used to describe a physics joint
  32433. */
  32434. export interface PhysicsImpostorJoint {
  32435. /** Defines the main impostor to which the joint is linked */
  32436. mainImpostor: PhysicsImpostor;
  32437. /** Defines the impostor that is connected to the main impostor using this joint */
  32438. connectedImpostor: PhysicsImpostor;
  32439. /** Defines the joint itself */
  32440. joint: PhysicsJoint;
  32441. }
  32442. /** @hidden */
  32443. export interface IPhysicsEnginePlugin {
  32444. world: any;
  32445. name: string;
  32446. setGravity(gravity: Vector3): void;
  32447. setTimeStep(timeStep: number): void;
  32448. getTimeStep(): number;
  32449. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32450. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32451. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32452. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32453. removePhysicsBody(impostor: PhysicsImpostor): void;
  32454. generateJoint(joint: PhysicsImpostorJoint): void;
  32455. removeJoint(joint: PhysicsImpostorJoint): void;
  32456. isSupported(): boolean;
  32457. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32458. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32459. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32460. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32461. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32462. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32463. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32464. getBodyMass(impostor: PhysicsImpostor): number;
  32465. getBodyFriction(impostor: PhysicsImpostor): number;
  32466. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32467. getBodyRestitution(impostor: PhysicsImpostor): number;
  32468. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32469. getBodyPressure?(impostor: PhysicsImpostor): number;
  32470. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32471. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32472. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32473. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32474. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32475. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32476. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32477. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32478. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32479. sleepBody(impostor: PhysicsImpostor): void;
  32480. wakeUpBody(impostor: PhysicsImpostor): void;
  32481. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32482. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32483. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32484. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32485. getRadius(impostor: PhysicsImpostor): number;
  32486. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32487. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32488. dispose(): void;
  32489. }
  32490. /**
  32491. * Interface used to define a physics engine
  32492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32493. */
  32494. export interface IPhysicsEngine {
  32495. /**
  32496. * Gets the gravity vector used by the simulation
  32497. */
  32498. gravity: Vector3;
  32499. /**
  32500. * Sets the gravity vector used by the simulation
  32501. * @param gravity defines the gravity vector to use
  32502. */
  32503. setGravity(gravity: Vector3): void;
  32504. /**
  32505. * Set the time step of the physics engine.
  32506. * Default is 1/60.
  32507. * To slow it down, enter 1/600 for example.
  32508. * To speed it up, 1/30
  32509. * @param newTimeStep the new timestep to apply to this world.
  32510. */
  32511. setTimeStep(newTimeStep: number): void;
  32512. /**
  32513. * Get the time step of the physics engine.
  32514. * @returns the current time step
  32515. */
  32516. getTimeStep(): number;
  32517. /**
  32518. * Set the sub time step of the physics engine.
  32519. * Default is 0 meaning there is no sub steps
  32520. * To increase physics resolution precision, set a small value (like 1 ms)
  32521. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32522. */
  32523. setSubTimeStep(subTimeStep: number): void;
  32524. /**
  32525. * Get the sub time step of the physics engine.
  32526. * @returns the current sub time step
  32527. */
  32528. getSubTimeStep(): number;
  32529. /**
  32530. * Release all resources
  32531. */
  32532. dispose(): void;
  32533. /**
  32534. * Gets the name of the current physics plugin
  32535. * @returns the name of the plugin
  32536. */
  32537. getPhysicsPluginName(): string;
  32538. /**
  32539. * Adding a new impostor for the impostor tracking.
  32540. * This will be done by the impostor itself.
  32541. * @param impostor the impostor to add
  32542. */
  32543. addImpostor(impostor: PhysicsImpostor): void;
  32544. /**
  32545. * Remove an impostor from the engine.
  32546. * This impostor and its mesh will not longer be updated by the physics engine.
  32547. * @param impostor the impostor to remove
  32548. */
  32549. removeImpostor(impostor: PhysicsImpostor): void;
  32550. /**
  32551. * Add a joint to the physics engine
  32552. * @param mainImpostor defines the main impostor to which the joint is added.
  32553. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32554. * @param joint defines the joint that will connect both impostors.
  32555. */
  32556. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32557. /**
  32558. * Removes a joint from the simulation
  32559. * @param mainImpostor defines the impostor used with the joint
  32560. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32561. * @param joint defines the joint to remove
  32562. */
  32563. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32564. /**
  32565. * Gets the current plugin used to run the simulation
  32566. * @returns current plugin
  32567. */
  32568. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32569. /**
  32570. * Gets the list of physic impostors
  32571. * @returns an array of PhysicsImpostor
  32572. */
  32573. getImpostors(): Array<PhysicsImpostor>;
  32574. /**
  32575. * Gets the impostor for a physics enabled object
  32576. * @param object defines the object impersonated by the impostor
  32577. * @returns the PhysicsImpostor or null if not found
  32578. */
  32579. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32580. /**
  32581. * Gets the impostor for a physics body object
  32582. * @param body defines physics body used by the impostor
  32583. * @returns the PhysicsImpostor or null if not found
  32584. */
  32585. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32586. /**
  32587. * Does a raycast in the physics world
  32588. * @param from when should the ray start?
  32589. * @param to when should the ray end?
  32590. * @returns PhysicsRaycastResult
  32591. */
  32592. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32593. /**
  32594. * Called by the scene. No need to call it.
  32595. * @param delta defines the timespan between frames
  32596. */
  32597. _step(delta: number): void;
  32598. }
  32599. }
  32600. declare module BABYLON {
  32601. /**
  32602. * The interface for the physics imposter parameters
  32603. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32604. */
  32605. export interface PhysicsImpostorParameters {
  32606. /**
  32607. * The mass of the physics imposter
  32608. */
  32609. mass: number;
  32610. /**
  32611. * The friction of the physics imposter
  32612. */
  32613. friction?: number;
  32614. /**
  32615. * The coefficient of restitution of the physics imposter
  32616. */
  32617. restitution?: number;
  32618. /**
  32619. * The native options of the physics imposter
  32620. */
  32621. nativeOptions?: any;
  32622. /**
  32623. * Specifies if the parent should be ignored
  32624. */
  32625. ignoreParent?: boolean;
  32626. /**
  32627. * Specifies if bi-directional transformations should be disabled
  32628. */
  32629. disableBidirectionalTransformation?: boolean;
  32630. /**
  32631. * The pressure inside the physics imposter, soft object only
  32632. */
  32633. pressure?: number;
  32634. /**
  32635. * The stiffness the physics imposter, soft object only
  32636. */
  32637. stiffness?: number;
  32638. /**
  32639. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32640. */
  32641. velocityIterations?: number;
  32642. /**
  32643. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32644. */
  32645. positionIterations?: number;
  32646. /**
  32647. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32648. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32649. * Add to fix multiple points
  32650. */
  32651. fixedPoints?: number;
  32652. /**
  32653. * The collision margin around a soft object
  32654. */
  32655. margin?: number;
  32656. /**
  32657. * The collision margin around a soft object
  32658. */
  32659. damping?: number;
  32660. /**
  32661. * The path for a rope based on an extrusion
  32662. */
  32663. path?: any;
  32664. /**
  32665. * The shape of an extrusion used for a rope based on an extrusion
  32666. */
  32667. shape?: any;
  32668. }
  32669. /**
  32670. * Interface for a physics-enabled object
  32671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32672. */
  32673. export interface IPhysicsEnabledObject {
  32674. /**
  32675. * The position of the physics-enabled object
  32676. */
  32677. position: Vector3;
  32678. /**
  32679. * The rotation of the physics-enabled object
  32680. */
  32681. rotationQuaternion: Nullable<Quaternion>;
  32682. /**
  32683. * The scale of the physics-enabled object
  32684. */
  32685. scaling: Vector3;
  32686. /**
  32687. * The rotation of the physics-enabled object
  32688. */
  32689. rotation?: Vector3;
  32690. /**
  32691. * The parent of the physics-enabled object
  32692. */
  32693. parent?: any;
  32694. /**
  32695. * The bounding info of the physics-enabled object
  32696. * @returns The bounding info of the physics-enabled object
  32697. */
  32698. getBoundingInfo(): BoundingInfo;
  32699. /**
  32700. * Computes the world matrix
  32701. * @param force Specifies if the world matrix should be computed by force
  32702. * @returns A world matrix
  32703. */
  32704. computeWorldMatrix(force: boolean): Matrix;
  32705. /**
  32706. * Gets the world matrix
  32707. * @returns A world matrix
  32708. */
  32709. getWorldMatrix?(): Matrix;
  32710. /**
  32711. * Gets the child meshes
  32712. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32713. * @returns An array of abstract meshes
  32714. */
  32715. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32716. /**
  32717. * Gets the vertex data
  32718. * @param kind The type of vertex data
  32719. * @returns A nullable array of numbers, or a float32 array
  32720. */
  32721. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32722. /**
  32723. * Gets the indices from the mesh
  32724. * @returns A nullable array of index arrays
  32725. */
  32726. getIndices?(): Nullable<IndicesArray>;
  32727. /**
  32728. * Gets the scene from the mesh
  32729. * @returns the indices array or null
  32730. */
  32731. getScene?(): Scene;
  32732. /**
  32733. * Gets the absolute position from the mesh
  32734. * @returns the absolute position
  32735. */
  32736. getAbsolutePosition(): Vector3;
  32737. /**
  32738. * Gets the absolute pivot point from the mesh
  32739. * @returns the absolute pivot point
  32740. */
  32741. getAbsolutePivotPoint(): Vector3;
  32742. /**
  32743. * Rotates the mesh
  32744. * @param axis The axis of rotation
  32745. * @param amount The amount of rotation
  32746. * @param space The space of the rotation
  32747. * @returns The rotation transform node
  32748. */
  32749. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32750. /**
  32751. * Translates the mesh
  32752. * @param axis The axis of translation
  32753. * @param distance The distance of translation
  32754. * @param space The space of the translation
  32755. * @returns The transform node
  32756. */
  32757. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32758. /**
  32759. * Sets the absolute position of the mesh
  32760. * @param absolutePosition The absolute position of the mesh
  32761. * @returns The transform node
  32762. */
  32763. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32764. /**
  32765. * Gets the class name of the mesh
  32766. * @returns The class name
  32767. */
  32768. getClassName(): string;
  32769. }
  32770. /**
  32771. * Represents a physics imposter
  32772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32773. */
  32774. export class PhysicsImpostor {
  32775. /**
  32776. * The physics-enabled object used as the physics imposter
  32777. */
  32778. object: IPhysicsEnabledObject;
  32779. /**
  32780. * The type of the physics imposter
  32781. */
  32782. type: number;
  32783. private _options;
  32784. private _scene?;
  32785. /**
  32786. * The default object size of the imposter
  32787. */
  32788. static DEFAULT_OBJECT_SIZE: Vector3;
  32789. /**
  32790. * The identity quaternion of the imposter
  32791. */
  32792. static IDENTITY_QUATERNION: Quaternion;
  32793. /** @hidden */
  32794. _pluginData: any;
  32795. private _physicsEngine;
  32796. private _physicsBody;
  32797. private _bodyUpdateRequired;
  32798. private _onBeforePhysicsStepCallbacks;
  32799. private _onAfterPhysicsStepCallbacks;
  32800. /** @hidden */
  32801. _onPhysicsCollideCallbacks: Array<{
  32802. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32803. otherImpostors: Array<PhysicsImpostor>;
  32804. }>;
  32805. private _deltaPosition;
  32806. private _deltaRotation;
  32807. private _deltaRotationConjugated;
  32808. /** @hidden */
  32809. _isFromLine: boolean;
  32810. private _parent;
  32811. private _isDisposed;
  32812. private static _tmpVecs;
  32813. private static _tmpQuat;
  32814. /**
  32815. * Specifies if the physics imposter is disposed
  32816. */
  32817. get isDisposed(): boolean;
  32818. /**
  32819. * Gets the mass of the physics imposter
  32820. */
  32821. get mass(): number;
  32822. set mass(value: number);
  32823. /**
  32824. * Gets the coefficient of friction
  32825. */
  32826. get friction(): number;
  32827. /**
  32828. * Sets the coefficient of friction
  32829. */
  32830. set friction(value: number);
  32831. /**
  32832. * Gets the coefficient of restitution
  32833. */
  32834. get restitution(): number;
  32835. /**
  32836. * Sets the coefficient of restitution
  32837. */
  32838. set restitution(value: number);
  32839. /**
  32840. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32841. */
  32842. get pressure(): number;
  32843. /**
  32844. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32845. */
  32846. set pressure(value: number);
  32847. /**
  32848. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32849. */
  32850. get stiffness(): number;
  32851. /**
  32852. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32853. */
  32854. set stiffness(value: number);
  32855. /**
  32856. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32857. */
  32858. get velocityIterations(): number;
  32859. /**
  32860. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32861. */
  32862. set velocityIterations(value: number);
  32863. /**
  32864. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32865. */
  32866. get positionIterations(): number;
  32867. /**
  32868. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32869. */
  32870. set positionIterations(value: number);
  32871. /**
  32872. * The unique id of the physics imposter
  32873. * set by the physics engine when adding this impostor to the array
  32874. */
  32875. uniqueId: number;
  32876. /**
  32877. * @hidden
  32878. */
  32879. soft: boolean;
  32880. /**
  32881. * @hidden
  32882. */
  32883. segments: number;
  32884. private _joints;
  32885. /**
  32886. * Initializes the physics imposter
  32887. * @param object The physics-enabled object used as the physics imposter
  32888. * @param type The type of the physics imposter
  32889. * @param _options The options for the physics imposter
  32890. * @param _scene The Babylon scene
  32891. */
  32892. constructor(
  32893. /**
  32894. * The physics-enabled object used as the physics imposter
  32895. */
  32896. object: IPhysicsEnabledObject,
  32897. /**
  32898. * The type of the physics imposter
  32899. */
  32900. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32901. /**
  32902. * This function will completely initialize this impostor.
  32903. * It will create a new body - but only if this mesh has no parent.
  32904. * If it has, this impostor will not be used other than to define the impostor
  32905. * of the child mesh.
  32906. * @hidden
  32907. */
  32908. _init(): void;
  32909. private _getPhysicsParent;
  32910. /**
  32911. * Should a new body be generated.
  32912. * @returns boolean specifying if body initialization is required
  32913. */
  32914. isBodyInitRequired(): boolean;
  32915. /**
  32916. * Sets the updated scaling
  32917. * @param updated Specifies if the scaling is updated
  32918. */
  32919. setScalingUpdated(): void;
  32920. /**
  32921. * Force a regeneration of this or the parent's impostor's body.
  32922. * Use under cautious - This will remove all joints already implemented.
  32923. */
  32924. forceUpdate(): void;
  32925. /**
  32926. * Gets the body that holds this impostor. Either its own, or its parent.
  32927. */
  32928. get physicsBody(): any;
  32929. /**
  32930. * Get the parent of the physics imposter
  32931. * @returns Physics imposter or null
  32932. */
  32933. get parent(): Nullable<PhysicsImpostor>;
  32934. /**
  32935. * Sets the parent of the physics imposter
  32936. */
  32937. set parent(value: Nullable<PhysicsImpostor>);
  32938. /**
  32939. * Set the physics body. Used mainly by the physics engine/plugin
  32940. */
  32941. set physicsBody(physicsBody: any);
  32942. /**
  32943. * Resets the update flags
  32944. */
  32945. resetUpdateFlags(): void;
  32946. /**
  32947. * Gets the object extend size
  32948. * @returns the object extend size
  32949. */
  32950. getObjectExtendSize(): Vector3;
  32951. /**
  32952. * Gets the object center
  32953. * @returns The object center
  32954. */
  32955. getObjectCenter(): Vector3;
  32956. /**
  32957. * Get a specific parameter from the options parameters
  32958. * @param paramName The object parameter name
  32959. * @returns The object parameter
  32960. */
  32961. getParam(paramName: string): any;
  32962. /**
  32963. * Sets a specific parameter in the options given to the physics plugin
  32964. * @param paramName The parameter name
  32965. * @param value The value of the parameter
  32966. */
  32967. setParam(paramName: string, value: number): void;
  32968. /**
  32969. * Specifically change the body's mass option. Won't recreate the physics body object
  32970. * @param mass The mass of the physics imposter
  32971. */
  32972. setMass(mass: number): void;
  32973. /**
  32974. * Gets the linear velocity
  32975. * @returns linear velocity or null
  32976. */
  32977. getLinearVelocity(): Nullable<Vector3>;
  32978. /**
  32979. * Sets the linear velocity
  32980. * @param velocity linear velocity or null
  32981. */
  32982. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32983. /**
  32984. * Gets the angular velocity
  32985. * @returns angular velocity or null
  32986. */
  32987. getAngularVelocity(): Nullable<Vector3>;
  32988. /**
  32989. * Sets the angular velocity
  32990. * @param velocity The velocity or null
  32991. */
  32992. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32993. /**
  32994. * Execute a function with the physics plugin native code
  32995. * Provide a function the will have two variables - the world object and the physics body object
  32996. * @param func The function to execute with the physics plugin native code
  32997. */
  32998. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32999. /**
  33000. * Register a function that will be executed before the physics world is stepping forward
  33001. * @param func The function to execute before the physics world is stepped forward
  33002. */
  33003. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33004. /**
  33005. * Unregister a function that will be executed before the physics world is stepping forward
  33006. * @param func The function to execute before the physics world is stepped forward
  33007. */
  33008. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33009. /**
  33010. * Register a function that will be executed after the physics step
  33011. * @param func The function to execute after physics step
  33012. */
  33013. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33014. /**
  33015. * Unregisters a function that will be executed after the physics step
  33016. * @param func The function to execute after physics step
  33017. */
  33018. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33019. /**
  33020. * register a function that will be executed when this impostor collides against a different body
  33021. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33022. * @param func Callback that is executed on collision
  33023. */
  33024. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33025. /**
  33026. * Unregisters the physics imposter on contact
  33027. * @param collideAgainst The physics object to collide against
  33028. * @param func Callback to execute on collision
  33029. */
  33030. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33031. private _tmpQuat;
  33032. private _tmpQuat2;
  33033. /**
  33034. * Get the parent rotation
  33035. * @returns The parent rotation
  33036. */
  33037. getParentsRotation(): Quaternion;
  33038. /**
  33039. * this function is executed by the physics engine.
  33040. */
  33041. beforeStep: () => void;
  33042. /**
  33043. * this function is executed by the physics engine
  33044. */
  33045. afterStep: () => void;
  33046. /**
  33047. * Legacy collision detection event support
  33048. */
  33049. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33050. /**
  33051. * event and body object due to cannon's event-based architecture.
  33052. */
  33053. onCollide: (e: {
  33054. body: any;
  33055. point: Nullable<Vector3>;
  33056. }) => void;
  33057. /**
  33058. * Apply a force
  33059. * @param force The force to apply
  33060. * @param contactPoint The contact point for the force
  33061. * @returns The physics imposter
  33062. */
  33063. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33064. /**
  33065. * Apply an impulse
  33066. * @param force The impulse force
  33067. * @param contactPoint The contact point for the impulse force
  33068. * @returns The physics imposter
  33069. */
  33070. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33071. /**
  33072. * A help function to create a joint
  33073. * @param otherImpostor A physics imposter used to create a joint
  33074. * @param jointType The type of joint
  33075. * @param jointData The data for the joint
  33076. * @returns The physics imposter
  33077. */
  33078. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33079. /**
  33080. * Add a joint to this impostor with a different impostor
  33081. * @param otherImpostor A physics imposter used to add a joint
  33082. * @param joint The joint to add
  33083. * @returns The physics imposter
  33084. */
  33085. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33086. /**
  33087. * Add an anchor to a cloth impostor
  33088. * @param otherImpostor rigid impostor to anchor to
  33089. * @param width ratio across width from 0 to 1
  33090. * @param height ratio up height from 0 to 1
  33091. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  33092. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33093. * @returns impostor the soft imposter
  33094. */
  33095. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33096. /**
  33097. * Add a hook to a rope impostor
  33098. * @param otherImpostor rigid impostor to anchor to
  33099. * @param length ratio across rope from 0 to 1
  33100. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch
  33101. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33102. * @returns impostor the rope imposter
  33103. */
  33104. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33105. /**
  33106. * Will keep this body still, in a sleep mode.
  33107. * @returns the physics imposter
  33108. */
  33109. sleep(): PhysicsImpostor;
  33110. /**
  33111. * Wake the body up.
  33112. * @returns The physics imposter
  33113. */
  33114. wakeUp(): PhysicsImpostor;
  33115. /**
  33116. * Clones the physics imposter
  33117. * @param newObject The physics imposter clones to this physics-enabled object
  33118. * @returns A nullable physics imposter
  33119. */
  33120. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33121. /**
  33122. * Disposes the physics imposter
  33123. */
  33124. dispose(): void;
  33125. /**
  33126. * Sets the delta position
  33127. * @param position The delta position amount
  33128. */
  33129. setDeltaPosition(position: Vector3): void;
  33130. /**
  33131. * Sets the delta rotation
  33132. * @param rotation The delta rotation amount
  33133. */
  33134. setDeltaRotation(rotation: Quaternion): void;
  33135. /**
  33136. * Gets the box size of the physics imposter and stores the result in the input parameter
  33137. * @param result Stores the box size
  33138. * @returns The physics imposter
  33139. */
  33140. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33141. /**
  33142. * Gets the radius of the physics imposter
  33143. * @returns Radius of the physics imposter
  33144. */
  33145. getRadius(): number;
  33146. /**
  33147. * Sync a bone with this impostor
  33148. * @param bone The bone to sync to the impostor.
  33149. * @param boneMesh The mesh that the bone is influencing.
  33150. * @param jointPivot The pivot of the joint / bone in local space.
  33151. * @param distToJoint Optional distance from the impostor to the joint.
  33152. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33153. */
  33154. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33155. /**
  33156. * Sync impostor to a bone
  33157. * @param bone The bone that the impostor will be synced to.
  33158. * @param boneMesh The mesh that the bone is influencing.
  33159. * @param jointPivot The pivot of the joint / bone in local space.
  33160. * @param distToJoint Optional distance from the impostor to the joint.
  33161. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33162. * @param boneAxis Optional vector3 axis the bone is aligned with
  33163. */
  33164. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33165. /**
  33166. * No-Imposter type
  33167. */
  33168. static NoImpostor: number;
  33169. /**
  33170. * Sphere-Imposter type
  33171. */
  33172. static SphereImpostor: number;
  33173. /**
  33174. * Box-Imposter type
  33175. */
  33176. static BoxImpostor: number;
  33177. /**
  33178. * Plane-Imposter type
  33179. */
  33180. static PlaneImpostor: number;
  33181. /**
  33182. * Mesh-imposter type
  33183. */
  33184. static MeshImpostor: number;
  33185. /**
  33186. * Capsule-Impostor type (Ammo.js plugin only)
  33187. */
  33188. static CapsuleImpostor: number;
  33189. /**
  33190. * Cylinder-Imposter type
  33191. */
  33192. static CylinderImpostor: number;
  33193. /**
  33194. * Particle-Imposter type
  33195. */
  33196. static ParticleImpostor: number;
  33197. /**
  33198. * Heightmap-Imposter type
  33199. */
  33200. static HeightmapImpostor: number;
  33201. /**
  33202. * ConvexHull-Impostor type (Ammo.js plugin only)
  33203. */
  33204. static ConvexHullImpostor: number;
  33205. /**
  33206. * Custom-Imposter type (Ammo.js plugin only)
  33207. */
  33208. static CustomImpostor: number;
  33209. /**
  33210. * Rope-Imposter type
  33211. */
  33212. static RopeImpostor: number;
  33213. /**
  33214. * Cloth-Imposter type
  33215. */
  33216. static ClothImpostor: number;
  33217. /**
  33218. * Softbody-Imposter type
  33219. */
  33220. static SoftbodyImpostor: number;
  33221. }
  33222. }
  33223. declare module BABYLON {
  33224. /**
  33225. * @hidden
  33226. **/
  33227. export class _CreationDataStorage {
  33228. closePath?: boolean;
  33229. closeArray?: boolean;
  33230. idx: number[];
  33231. dashSize: number;
  33232. gapSize: number;
  33233. path3D: Path3D;
  33234. pathArray: Vector3[][];
  33235. arc: number;
  33236. radius: number;
  33237. cap: number;
  33238. tessellation: number;
  33239. }
  33240. /**
  33241. * @hidden
  33242. **/
  33243. class _InstanceDataStorage {
  33244. visibleInstances: any;
  33245. batchCache: _InstancesBatch;
  33246. instancesBufferSize: number;
  33247. instancesBuffer: Nullable<Buffer>;
  33248. instancesData: Float32Array;
  33249. overridenInstanceCount: number;
  33250. isFrozen: boolean;
  33251. previousBatch: Nullable<_InstancesBatch>;
  33252. hardwareInstancedRendering: boolean;
  33253. sideOrientation: number;
  33254. manualUpdate: boolean;
  33255. previousRenderId: number;
  33256. }
  33257. /**
  33258. * @hidden
  33259. **/
  33260. export class _InstancesBatch {
  33261. mustReturn: boolean;
  33262. visibleInstances: Nullable<InstancedMesh[]>[];
  33263. renderSelf: boolean[];
  33264. hardwareInstancedRendering: boolean[];
  33265. }
  33266. /**
  33267. * @hidden
  33268. **/
  33269. class _ThinInstanceDataStorage {
  33270. instancesCount: number;
  33271. matrixBuffer: Nullable<Buffer>;
  33272. matrixBufferSize: number;
  33273. matrixData: Nullable<Float32Array>;
  33274. boundingVectors: Array<Vector3>;
  33275. worldMatrices: Nullable<Matrix[]>;
  33276. }
  33277. /**
  33278. * Class used to represent renderable models
  33279. */
  33280. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33281. /**
  33282. * Mesh side orientation : usually the external or front surface
  33283. */
  33284. static readonly FRONTSIDE: number;
  33285. /**
  33286. * Mesh side orientation : usually the internal or back surface
  33287. */
  33288. static readonly BACKSIDE: number;
  33289. /**
  33290. * Mesh side orientation : both internal and external or front and back surfaces
  33291. */
  33292. static readonly DOUBLESIDE: number;
  33293. /**
  33294. * Mesh side orientation : by default, `FRONTSIDE`
  33295. */
  33296. static readonly DEFAULTSIDE: number;
  33297. /**
  33298. * Mesh cap setting : no cap
  33299. */
  33300. static readonly NO_CAP: number;
  33301. /**
  33302. * Mesh cap setting : one cap at the beginning of the mesh
  33303. */
  33304. static readonly CAP_START: number;
  33305. /**
  33306. * Mesh cap setting : one cap at the end of the mesh
  33307. */
  33308. static readonly CAP_END: number;
  33309. /**
  33310. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33311. */
  33312. static readonly CAP_ALL: number;
  33313. /**
  33314. * Mesh pattern setting : no flip or rotate
  33315. */
  33316. static readonly NO_FLIP: number;
  33317. /**
  33318. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33319. */
  33320. static readonly FLIP_TILE: number;
  33321. /**
  33322. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33323. */
  33324. static readonly ROTATE_TILE: number;
  33325. /**
  33326. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33327. */
  33328. static readonly FLIP_ROW: number;
  33329. /**
  33330. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33331. */
  33332. static readonly ROTATE_ROW: number;
  33333. /**
  33334. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33335. */
  33336. static readonly FLIP_N_ROTATE_TILE: number;
  33337. /**
  33338. * Mesh pattern setting : rotate pattern and rotate
  33339. */
  33340. static readonly FLIP_N_ROTATE_ROW: number;
  33341. /**
  33342. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33343. */
  33344. static readonly CENTER: number;
  33345. /**
  33346. * Mesh tile positioning : part tiles on left
  33347. */
  33348. static readonly LEFT: number;
  33349. /**
  33350. * Mesh tile positioning : part tiles on right
  33351. */
  33352. static readonly RIGHT: number;
  33353. /**
  33354. * Mesh tile positioning : part tiles on top
  33355. */
  33356. static readonly TOP: number;
  33357. /**
  33358. * Mesh tile positioning : part tiles on bottom
  33359. */
  33360. static readonly BOTTOM: number;
  33361. /**
  33362. * Gets the default side orientation.
  33363. * @param orientation the orientation to value to attempt to get
  33364. * @returns the default orientation
  33365. * @hidden
  33366. */
  33367. static _GetDefaultSideOrientation(orientation?: number): number;
  33368. private _internalMeshDataInfo;
  33369. get computeBonesUsingShaders(): boolean;
  33370. set computeBonesUsingShaders(value: boolean);
  33371. /**
  33372. * An event triggered before rendering the mesh
  33373. */
  33374. get onBeforeRenderObservable(): Observable<Mesh>;
  33375. /**
  33376. * An event triggered before binding the mesh
  33377. */
  33378. get onBeforeBindObservable(): Observable<Mesh>;
  33379. /**
  33380. * An event triggered after rendering the mesh
  33381. */
  33382. get onAfterRenderObservable(): Observable<Mesh>;
  33383. /**
  33384. * An event triggered before drawing the mesh
  33385. */
  33386. get onBeforeDrawObservable(): Observable<Mesh>;
  33387. private _onBeforeDrawObserver;
  33388. /**
  33389. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33390. */
  33391. set onBeforeDraw(callback: () => void);
  33392. get hasInstances(): boolean;
  33393. get hasThinInstances(): boolean;
  33394. /**
  33395. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33396. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33397. */
  33398. delayLoadState: number;
  33399. /**
  33400. * Gets the list of instances created from this mesh
  33401. * it is not supposed to be modified manually.
  33402. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33403. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33404. */
  33405. instances: InstancedMesh[];
  33406. /**
  33407. * Gets the file containing delay loading data for this mesh
  33408. */
  33409. delayLoadingFile: string;
  33410. /** @hidden */
  33411. _binaryInfo: any;
  33412. /**
  33413. * User defined function used to change how LOD level selection is done
  33414. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33415. */
  33416. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33417. /**
  33418. * Gets or sets the morph target manager
  33419. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33420. */
  33421. get morphTargetManager(): Nullable<MorphTargetManager>;
  33422. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33423. /** @hidden */
  33424. _creationDataStorage: Nullable<_CreationDataStorage>;
  33425. /** @hidden */
  33426. _geometry: Nullable<Geometry>;
  33427. /** @hidden */
  33428. _delayInfo: Array<string>;
  33429. /** @hidden */
  33430. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33431. /** @hidden */
  33432. _instanceDataStorage: _InstanceDataStorage;
  33433. /** @hidden */
  33434. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33435. private _effectiveMaterial;
  33436. /** @hidden */
  33437. _shouldGenerateFlatShading: boolean;
  33438. /** @hidden */
  33439. _originalBuilderSideOrientation: number;
  33440. /**
  33441. * Use this property to change the original side orientation defined at construction time
  33442. */
  33443. overrideMaterialSideOrientation: Nullable<number>;
  33444. /**
  33445. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33446. * Note this will reduce performance when set to true.
  33447. */
  33448. ignoreCameraMaxZ: boolean;
  33449. /**
  33450. * Gets the source mesh (the one used to clone this one from)
  33451. */
  33452. get source(): Nullable<Mesh>;
  33453. /**
  33454. * Gets the list of clones of this mesh
  33455. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33456. * Note that useClonedMeshMap=true is the default setting
  33457. */
  33458. get cloneMeshMap(): Nullable<{
  33459. [id: string]: Mesh | undefined;
  33460. }>;
  33461. /**
  33462. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33463. */
  33464. get isUnIndexed(): boolean;
  33465. set isUnIndexed(value: boolean);
  33466. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33467. get worldMatrixInstancedBuffer(): Float32Array;
  33468. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33469. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33470. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33471. /**
  33472. * @constructor
  33473. * @param name The value used by scene.getMeshByName() to do a lookup.
  33474. * @param scene The scene to add this mesh to.
  33475. * @param parent The parent of this mesh, if it has one
  33476. * @param source An optional Mesh from which geometry is shared, cloned.
  33477. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33478. * When false, achieved by calling a clone(), also passing False.
  33479. * This will make creation of children, recursive.
  33480. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33481. */
  33482. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33483. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33484. doNotInstantiate: boolean;
  33485. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33486. /**
  33487. * Gets the class name
  33488. * @returns the string "Mesh".
  33489. */
  33490. getClassName(): string;
  33491. /** @hidden */
  33492. get _isMesh(): boolean;
  33493. /**
  33494. * Returns a description of this mesh
  33495. * @param fullDetails define if full details about this mesh must be used
  33496. * @returns a descriptive string representing this mesh
  33497. */
  33498. toString(fullDetails?: boolean): string;
  33499. /** @hidden */
  33500. _unBindEffect(): void;
  33501. /**
  33502. * Gets a boolean indicating if this mesh has LOD
  33503. */
  33504. get hasLODLevels(): boolean;
  33505. /**
  33506. * Gets the list of MeshLODLevel associated with the current mesh
  33507. * @returns an array of MeshLODLevel
  33508. */
  33509. getLODLevels(): MeshLODLevel[];
  33510. private _sortLODLevels;
  33511. /**
  33512. * Add a mesh as LOD level triggered at the given distance.
  33513. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33514. * @param distance The distance from the center of the object to show this level
  33515. * @param mesh The mesh to be added as LOD level (can be null)
  33516. * @return This mesh (for chaining)
  33517. */
  33518. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33519. /**
  33520. * Returns the LOD level mesh at the passed distance or null if not found.
  33521. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33522. * @param distance The distance from the center of the object to show this level
  33523. * @returns a Mesh or `null`
  33524. */
  33525. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33526. /**
  33527. * Remove a mesh from the LOD array
  33528. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33529. * @param mesh defines the mesh to be removed
  33530. * @return This mesh (for chaining)
  33531. */
  33532. removeLODLevel(mesh: Mesh): Mesh;
  33533. /**
  33534. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33535. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33536. * @param camera defines the camera to use to compute distance
  33537. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33538. * @return This mesh (for chaining)
  33539. */
  33540. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33541. /**
  33542. * Gets the mesh internal Geometry object
  33543. */
  33544. get geometry(): Nullable<Geometry>;
  33545. /**
  33546. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33547. * @returns the total number of vertices
  33548. */
  33549. getTotalVertices(): number;
  33550. /**
  33551. * Returns the content of an associated vertex buffer
  33552. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33553. * - VertexBuffer.PositionKind
  33554. * - VertexBuffer.UVKind
  33555. * - VertexBuffer.UV2Kind
  33556. * - VertexBuffer.UV3Kind
  33557. * - VertexBuffer.UV4Kind
  33558. * - VertexBuffer.UV5Kind
  33559. * - VertexBuffer.UV6Kind
  33560. * - VertexBuffer.ColorKind
  33561. * - VertexBuffer.MatricesIndicesKind
  33562. * - VertexBuffer.MatricesIndicesExtraKind
  33563. * - VertexBuffer.MatricesWeightsKind
  33564. * - VertexBuffer.MatricesWeightsExtraKind
  33565. * @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
  33566. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33567. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33568. */
  33569. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33570. /**
  33571. * Returns the mesh VertexBuffer object from the requested `kind`
  33572. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33573. * - VertexBuffer.PositionKind
  33574. * - VertexBuffer.NormalKind
  33575. * - VertexBuffer.UVKind
  33576. * - VertexBuffer.UV2Kind
  33577. * - VertexBuffer.UV3Kind
  33578. * - VertexBuffer.UV4Kind
  33579. * - VertexBuffer.UV5Kind
  33580. * - VertexBuffer.UV6Kind
  33581. * - VertexBuffer.ColorKind
  33582. * - VertexBuffer.MatricesIndicesKind
  33583. * - VertexBuffer.MatricesIndicesExtraKind
  33584. * - VertexBuffer.MatricesWeightsKind
  33585. * - VertexBuffer.MatricesWeightsExtraKind
  33586. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33587. */
  33588. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33589. /**
  33590. * Tests if a specific vertex buffer is associated with this mesh
  33591. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33592. * - VertexBuffer.PositionKind
  33593. * - VertexBuffer.NormalKind
  33594. * - VertexBuffer.UVKind
  33595. * - VertexBuffer.UV2Kind
  33596. * - VertexBuffer.UV3Kind
  33597. * - VertexBuffer.UV4Kind
  33598. * - VertexBuffer.UV5Kind
  33599. * - VertexBuffer.UV6Kind
  33600. * - VertexBuffer.ColorKind
  33601. * - VertexBuffer.MatricesIndicesKind
  33602. * - VertexBuffer.MatricesIndicesExtraKind
  33603. * - VertexBuffer.MatricesWeightsKind
  33604. * - VertexBuffer.MatricesWeightsExtraKind
  33605. * @returns a boolean
  33606. */
  33607. isVerticesDataPresent(kind: string): boolean;
  33608. /**
  33609. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33610. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33611. * - VertexBuffer.PositionKind
  33612. * - VertexBuffer.UVKind
  33613. * - VertexBuffer.UV2Kind
  33614. * - VertexBuffer.UV3Kind
  33615. * - VertexBuffer.UV4Kind
  33616. * - VertexBuffer.UV5Kind
  33617. * - VertexBuffer.UV6Kind
  33618. * - VertexBuffer.ColorKind
  33619. * - VertexBuffer.MatricesIndicesKind
  33620. * - VertexBuffer.MatricesIndicesExtraKind
  33621. * - VertexBuffer.MatricesWeightsKind
  33622. * - VertexBuffer.MatricesWeightsExtraKind
  33623. * @returns a boolean
  33624. */
  33625. isVertexBufferUpdatable(kind: string): boolean;
  33626. /**
  33627. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33628. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33629. * - VertexBuffer.PositionKind
  33630. * - VertexBuffer.NormalKind
  33631. * - VertexBuffer.UVKind
  33632. * - VertexBuffer.UV2Kind
  33633. * - VertexBuffer.UV3Kind
  33634. * - VertexBuffer.UV4Kind
  33635. * - VertexBuffer.UV5Kind
  33636. * - VertexBuffer.UV6Kind
  33637. * - VertexBuffer.ColorKind
  33638. * - VertexBuffer.MatricesIndicesKind
  33639. * - VertexBuffer.MatricesIndicesExtraKind
  33640. * - VertexBuffer.MatricesWeightsKind
  33641. * - VertexBuffer.MatricesWeightsExtraKind
  33642. * @returns an array of strings
  33643. */
  33644. getVerticesDataKinds(): string[];
  33645. /**
  33646. * Returns a positive integer : the total number of indices in this mesh geometry.
  33647. * @returns the numner of indices or zero if the mesh has no geometry.
  33648. */
  33649. getTotalIndices(): number;
  33650. /**
  33651. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33652. * @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.
  33653. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33654. * @returns the indices array or an empty array if the mesh has no geometry
  33655. */
  33656. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33657. get isBlocked(): boolean;
  33658. /**
  33659. * Determine if the current mesh is ready to be rendered
  33660. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33661. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33662. * @returns true if all associated assets are ready (material, textures, shaders)
  33663. */
  33664. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33665. /**
  33666. * 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.
  33667. */
  33668. get areNormalsFrozen(): boolean;
  33669. /**
  33670. * 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.
  33671. * @returns the current mesh
  33672. */
  33673. freezeNormals(): Mesh;
  33674. /**
  33675. * 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
  33676. * @returns the current mesh
  33677. */
  33678. unfreezeNormals(): Mesh;
  33679. /**
  33680. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33681. */
  33682. set overridenInstanceCount(count: number);
  33683. /** @hidden */
  33684. _preActivate(): Mesh;
  33685. /** @hidden */
  33686. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33687. /** @hidden */
  33688. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33689. protected _afterComputeWorldMatrix(): void;
  33690. /** @hidden */
  33691. _postActivate(): void;
  33692. /**
  33693. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33694. * This means the mesh underlying bounding box and sphere are recomputed.
  33695. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33696. * @returns the current mesh
  33697. */
  33698. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33699. /** @hidden */
  33700. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33701. /**
  33702. * This function will subdivide the mesh into multiple submeshes
  33703. * @param count defines the expected number of submeshes
  33704. */
  33705. subdivide(count: number): void;
  33706. /**
  33707. * Copy a FloatArray into a specific associated vertex buffer
  33708. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33709. * - VertexBuffer.PositionKind
  33710. * - VertexBuffer.UVKind
  33711. * - VertexBuffer.UV2Kind
  33712. * - VertexBuffer.UV3Kind
  33713. * - VertexBuffer.UV4Kind
  33714. * - VertexBuffer.UV5Kind
  33715. * - VertexBuffer.UV6Kind
  33716. * - VertexBuffer.ColorKind
  33717. * - VertexBuffer.MatricesIndicesKind
  33718. * - VertexBuffer.MatricesIndicesExtraKind
  33719. * - VertexBuffer.MatricesWeightsKind
  33720. * - VertexBuffer.MatricesWeightsExtraKind
  33721. * @param data defines the data source
  33722. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33723. * @param stride defines the data stride size (can be null)
  33724. * @returns the current mesh
  33725. */
  33726. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33727. /**
  33728. * Delete a vertex buffer associated with this mesh
  33729. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33730. * - VertexBuffer.PositionKind
  33731. * - VertexBuffer.UVKind
  33732. * - VertexBuffer.UV2Kind
  33733. * - VertexBuffer.UV3Kind
  33734. * - VertexBuffer.UV4Kind
  33735. * - VertexBuffer.UV5Kind
  33736. * - VertexBuffer.UV6Kind
  33737. * - VertexBuffer.ColorKind
  33738. * - VertexBuffer.MatricesIndicesKind
  33739. * - VertexBuffer.MatricesIndicesExtraKind
  33740. * - VertexBuffer.MatricesWeightsKind
  33741. * - VertexBuffer.MatricesWeightsExtraKind
  33742. */
  33743. removeVerticesData(kind: string): void;
  33744. /**
  33745. * Flags an associated vertex buffer as updatable
  33746. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33747. * - VertexBuffer.PositionKind
  33748. * - VertexBuffer.UVKind
  33749. * - VertexBuffer.UV2Kind
  33750. * - VertexBuffer.UV3Kind
  33751. * - VertexBuffer.UV4Kind
  33752. * - VertexBuffer.UV5Kind
  33753. * - VertexBuffer.UV6Kind
  33754. * - VertexBuffer.ColorKind
  33755. * - VertexBuffer.MatricesIndicesKind
  33756. * - VertexBuffer.MatricesIndicesExtraKind
  33757. * - VertexBuffer.MatricesWeightsKind
  33758. * - VertexBuffer.MatricesWeightsExtraKind
  33759. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33760. */
  33761. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33762. /**
  33763. * Sets the mesh global Vertex Buffer
  33764. * @param buffer defines the buffer to use
  33765. * @returns the current mesh
  33766. */
  33767. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33768. /**
  33769. * Update a specific associated vertex buffer
  33770. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33771. * - VertexBuffer.PositionKind
  33772. * - VertexBuffer.UVKind
  33773. * - VertexBuffer.UV2Kind
  33774. * - VertexBuffer.UV3Kind
  33775. * - VertexBuffer.UV4Kind
  33776. * - VertexBuffer.UV5Kind
  33777. * - VertexBuffer.UV6Kind
  33778. * - VertexBuffer.ColorKind
  33779. * - VertexBuffer.MatricesIndicesKind
  33780. * - VertexBuffer.MatricesIndicesExtraKind
  33781. * - VertexBuffer.MatricesWeightsKind
  33782. * - VertexBuffer.MatricesWeightsExtraKind
  33783. * @param data defines the data source
  33784. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33785. * @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)
  33786. * @returns the current mesh
  33787. */
  33788. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33789. /**
  33790. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33791. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33792. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33793. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33794. * @returns the current mesh
  33795. */
  33796. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33797. /**
  33798. * Creates a un-shared specific occurence of the geometry for the mesh.
  33799. * @returns the current mesh
  33800. */
  33801. makeGeometryUnique(): Mesh;
  33802. /**
  33803. * Set the index buffer of this mesh
  33804. * @param indices defines the source data
  33805. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33806. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33807. * @returns the current mesh
  33808. */
  33809. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33810. /**
  33811. * Update the current index buffer
  33812. * @param indices defines the source data
  33813. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33814. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  33815. * @returns the current mesh
  33816. */
  33817. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33818. /**
  33819. * Invert the geometry to move from a right handed system to a left handed one.
  33820. * @returns the current mesh
  33821. */
  33822. toLeftHanded(): Mesh;
  33823. /** @hidden */
  33824. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33825. /** @hidden */
  33826. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33827. /**
  33828. * Registers for this mesh a javascript function called just before the rendering process
  33829. * @param func defines the function to call before rendering this mesh
  33830. * @returns the current mesh
  33831. */
  33832. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33833. /**
  33834. * Disposes a previously registered javascript function called before the rendering
  33835. * @param func defines the function to remove
  33836. * @returns the current mesh
  33837. */
  33838. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33839. /**
  33840. * Registers for this mesh a javascript function called just after the rendering is complete
  33841. * @param func defines the function to call after rendering this mesh
  33842. * @returns the current mesh
  33843. */
  33844. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33845. /**
  33846. * Disposes a previously registered javascript function called after the rendering.
  33847. * @param func defines the function to remove
  33848. * @returns the current mesh
  33849. */
  33850. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33851. /** @hidden */
  33852. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33853. /** @hidden */
  33854. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33855. /** @hidden */
  33856. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33857. /** @hidden */
  33858. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33859. /** @hidden */
  33860. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33861. /** @hidden */
  33862. _rebuild(): void;
  33863. /** @hidden */
  33864. _freeze(): void;
  33865. /** @hidden */
  33866. _unFreeze(): void;
  33867. /**
  33868. * 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
  33869. * @param subMesh defines the subMesh to render
  33870. * @param enableAlphaMode defines if alpha mode can be changed
  33871. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33872. * @returns the current mesh
  33873. */
  33874. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33875. private _onBeforeDraw;
  33876. /**
  33877. * Renormalize the mesh and patch it up if there are no weights
  33878. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33879. * However in the case of zero weights then we set just a single influence to 1.
  33880. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33881. */
  33882. cleanMatrixWeights(): void;
  33883. private normalizeSkinFourWeights;
  33884. private normalizeSkinWeightsAndExtra;
  33885. /**
  33886. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33887. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33888. * the user know there was an issue with importing the mesh
  33889. * @returns a validation object with skinned, valid and report string
  33890. */
  33891. validateSkinning(): {
  33892. skinned: boolean;
  33893. valid: boolean;
  33894. report: string;
  33895. };
  33896. /** @hidden */
  33897. _checkDelayState(): Mesh;
  33898. private _queueLoad;
  33899. /**
  33900. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33901. * A mesh is in the frustum if its bounding box intersects the frustum
  33902. * @param frustumPlanes defines the frustum to test
  33903. * @returns true if the mesh is in the frustum planes
  33904. */
  33905. isInFrustum(frustumPlanes: Plane[]): boolean;
  33906. /**
  33907. * Sets the mesh material by the material or multiMaterial `id` property
  33908. * @param id is a string identifying the material or the multiMaterial
  33909. * @returns the current mesh
  33910. */
  33911. setMaterialByID(id: string): Mesh;
  33912. /**
  33913. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33914. * @returns an array of IAnimatable
  33915. */
  33916. getAnimatables(): IAnimatable[];
  33917. /**
  33918. * Modifies the mesh geometry according to the passed transformation matrix.
  33919. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33920. * The mesh normals are modified using the same transformation.
  33921. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33922. * @param transform defines the transform matrix to use
  33923. * @see https://doc.babylonjs.com/resources/baking_transformations
  33924. * @returns the current mesh
  33925. */
  33926. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33927. /**
  33928. * Modifies the mesh geometry according to its own current World Matrix.
  33929. * The mesh World Matrix is then reset.
  33930. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33931. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33932. * @see https://doc.babylonjs.com/resources/baking_transformations
  33933. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33934. * @returns the current mesh
  33935. */
  33936. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33937. /** @hidden */
  33938. get _positions(): Nullable<Vector3[]>;
  33939. /** @hidden */
  33940. _resetPointsArrayCache(): Mesh;
  33941. /** @hidden */
  33942. _generatePointsArray(): boolean;
  33943. /**
  33944. * Returns a new Mesh object generated from the current mesh properties.
  33945. * This method must not get confused with createInstance()
  33946. * @param name is a string, the name given to the new mesh
  33947. * @param newParent can be any Node object (default `null`)
  33948. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33949. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33950. * @returns a new mesh
  33951. */
  33952. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33953. /**
  33954. * Releases resources associated with this mesh.
  33955. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33956. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33957. */
  33958. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33959. /** @hidden */
  33960. _disposeInstanceSpecificData(): void;
  33961. /** @hidden */
  33962. _disposeThinInstanceSpecificData(): void;
  33963. /**
  33964. * Modifies the mesh geometry according to a displacement map.
  33965. * 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.
  33966. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33967. * @param url is a string, the URL from the image file is to be downloaded.
  33968. * @param minHeight is the lower limit of the displacement.
  33969. * @param maxHeight is the upper limit of the displacement.
  33970. * @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.
  33971. * @param uvOffset is an optional vector2 used to offset UV.
  33972. * @param uvScale is an optional vector2 used to scale UV.
  33973. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  33974. * @returns the Mesh.
  33975. */
  33976. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33977. /**
  33978. * Modifies the mesh geometry according to a displacementMap buffer.
  33979. * 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.
  33980. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33981. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33982. * @param heightMapWidth is the width of the buffer image.
  33983. * @param heightMapHeight is the height of the buffer image.
  33984. * @param minHeight is the lower limit of the displacement.
  33985. * @param maxHeight is the upper limit of the displacement.
  33986. * @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.
  33987. * @param uvOffset is an optional vector2 used to offset UV.
  33988. * @param uvScale is an optional vector2 used to scale UV.
  33989. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  33990. * @returns the Mesh.
  33991. */
  33992. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33993. /**
  33994. * Modify the mesh to get a flat shading rendering.
  33995. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33996. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33997. * @returns current mesh
  33998. */
  33999. convertToFlatShadedMesh(): Mesh;
  34000. /**
  34001. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34002. * In other words, more vertices, no more indices and a single bigger VBO.
  34003. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34004. * @returns current mesh
  34005. */
  34006. convertToUnIndexedMesh(): Mesh;
  34007. /**
  34008. * Inverses facet orientations.
  34009. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34010. * @param flipNormals will also inverts the normals
  34011. * @returns current mesh
  34012. */
  34013. flipFaces(flipNormals?: boolean): Mesh;
  34014. /**
  34015. * Increase the number of facets and hence vertices in a mesh
  34016. * Vertex normals are interpolated from existing vertex normals
  34017. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34018. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34019. */
  34020. increaseVertices(numberPerEdge: number): void;
  34021. /**
  34022. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34023. * This will undo any application of covertToFlatShadedMesh
  34024. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34025. */
  34026. forceSharedVertices(): void;
  34027. /** @hidden */
  34028. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34029. /** @hidden */
  34030. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34031. /**
  34032. * Creates a new InstancedMesh object from the mesh model.
  34033. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34034. * @param name defines the name of the new instance
  34035. * @returns a new InstancedMesh
  34036. */
  34037. createInstance(name: string): InstancedMesh;
  34038. /**
  34039. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34040. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34041. * @returns the current mesh
  34042. */
  34043. synchronizeInstances(): Mesh;
  34044. /**
  34045. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34046. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34047. * This should be used together with the simplification to avoid disappearing triangles.
  34048. * @param successCallback an optional success callback to be called after the optimization finished.
  34049. * @returns the current mesh
  34050. */
  34051. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34052. /**
  34053. * Serialize current mesh
  34054. * @param serializationObject defines the object which will receive the serialization data
  34055. */
  34056. serialize(serializationObject: any): void;
  34057. /** @hidden */
  34058. _syncGeometryWithMorphTargetManager(): void;
  34059. /** @hidden */
  34060. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34061. /**
  34062. * Returns a new Mesh object parsed from the source provided.
  34063. * @param parsedMesh is the source
  34064. * @param scene defines the hosting scene
  34065. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34066. * @returns a new Mesh
  34067. */
  34068. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34069. /**
  34070. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34071. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34072. * @param name defines the name of the mesh to create
  34073. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34074. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34075. * @param closePath creates a seam between the first and the last points of each path of the path array
  34076. * @param offset is taken in account only if the `pathArray` is containing a single path
  34077. * @param scene defines the hosting scene
  34078. * @param updatable defines if the mesh must be flagged as updatable
  34079. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34080. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  34081. * @returns a new Mesh
  34082. */
  34083. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34084. /**
  34085. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34086. * @param name defines the name of the mesh to create
  34087. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34088. * @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
  34089. * @param scene defines the hosting scene
  34090. * @param updatable defines if the mesh must be flagged as updatable
  34091. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34092. * @returns a new Mesh
  34093. */
  34094. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34095. /**
  34096. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34097. * @param name defines the name of the mesh to create
  34098. * @param size sets the size (float) of each box side (default 1)
  34099. * @param scene defines the hosting scene
  34100. * @param updatable defines if the mesh must be flagged as updatable
  34101. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34102. * @returns a new Mesh
  34103. */
  34104. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34105. /**
  34106. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34107. * @param name defines the name of the mesh to create
  34108. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34109. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34110. * @param scene defines the hosting scene
  34111. * @param updatable defines if the mesh must be flagged as updatable
  34112. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34113. * @returns a new Mesh
  34114. */
  34115. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34116. /**
  34117. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34118. * @param name defines the name of the mesh to create
  34119. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34120. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34121. * @param scene defines the hosting scene
  34122. * @returns a new Mesh
  34123. */
  34124. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34125. /**
  34126. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34127. * @param name defines the name of the mesh to create
  34128. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34129. * @param diameterTop set the top cap diameter (floats, default 1)
  34130. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34131. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34132. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34133. * @param scene defines the hosting scene
  34134. * @param updatable defines if the mesh must be flagged as updatable
  34135. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34136. * @returns a new Mesh
  34137. */
  34138. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34139. /**
  34140. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34141. * @param name defines the name of the mesh to create
  34142. * @param diameter sets the diameter size (float) of the torus (default 1)
  34143. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34144. * @param tessellation sets the number of torus sides (positive integer, default 16)
  34145. * @param scene defines the hosting scene
  34146. * @param updatable defines if the mesh must be flagged as updatable
  34147. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34148. * @returns a new Mesh
  34149. */
  34150. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34151. /**
  34152. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34153. * @param name defines the name of the mesh to create
  34154. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34155. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34156. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34157. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34158. * @param p the number of windings on X axis (positive integers, default 2)
  34159. * @param q the number of windings on Y axis (positive integers, default 3)
  34160. * @param scene defines the hosting scene
  34161. * @param updatable defines if the mesh must be flagged as updatable
  34162. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34163. * @returns a new Mesh
  34164. */
  34165. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34166. /**
  34167. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34168. * @param name defines the name of the mesh to create
  34169. * @param points is an array successive Vector3
  34170. * @param scene defines the hosting scene
  34171. * @param updatable defines if the mesh must be flagged as updatable
  34172. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  34173. * @returns a new Mesh
  34174. */
  34175. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34176. /**
  34177. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34178. * @param name defines the name of the mesh to create
  34179. * @param points is an array successive Vector3
  34180. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34181. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34182. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34183. * @param scene defines the hosting scene
  34184. * @param updatable defines if the mesh must be flagged as updatable
  34185. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  34186. * @returns a new Mesh
  34187. */
  34188. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34189. /**
  34190. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34191. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34192. * 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.
  34193. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34194. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34195. * Remember you can only change the shape positions, not their number when updating a polygon.
  34196. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34197. * @param name defines the name of the mesh to create
  34198. * @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
  34199. * @param scene defines the hosting scene
  34200. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34201. * @param updatable defines if the mesh must be flagged as updatable
  34202. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34203. * @param earcutInjection can be used to inject your own earcut reference
  34204. * @returns a new Mesh
  34205. */
  34206. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34207. /**
  34208. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34209. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34210. * @param name defines the name of the mesh to create
  34211. * @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
  34212. * @param depth defines the height of extrusion
  34213. * @param scene defines the hosting scene
  34214. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34215. * @param updatable defines if the mesh must be flagged as updatable
  34216. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34217. * @param earcutInjection can be used to inject your own earcut reference
  34218. * @returns a new Mesh
  34219. */
  34220. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34221. /**
  34222. * Creates an extruded shape mesh.
  34223. * 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
  34224. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34226. * @param name defines the name of the mesh to create
  34227. * @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
  34228. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34229. * @param scale is the value to scale the shape
  34230. * @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
  34231. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  34232. * @param scene defines the hosting scene
  34233. * @param updatable defines if the mesh must be flagged as updatable
  34234. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34235. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  34236. * @returns a new Mesh
  34237. */
  34238. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34239. /**
  34240. * Creates an custom extruded shape mesh.
  34241. * The custom extrusion is a parametric shape.
  34242. * It has no predefined shape. Its final shape will depend on the input parameters.
  34243. * Please consider using the same method from the MeshBuilder class instead
  34244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34245. * @param name defines the name of the mesh to create
  34246. * @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
  34247. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34248. * @param scaleFunction is a custom Javascript function called on each path point
  34249. * @param rotationFunction is a custom Javascript function called on each path point
  34250. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34251. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34252. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  34253. * @param scene defines the hosting scene
  34254. * @param updatable defines if the mesh must be flagged as updatable
  34255. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34256. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  34257. * @returns a new Mesh
  34258. */
  34259. 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;
  34260. /**
  34261. * Creates lathe mesh.
  34262. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34263. * Please consider using the same method from the MeshBuilder class instead
  34264. * @param name defines the name of the mesh to create
  34265. * @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
  34266. * @param radius is the radius value of the lathe
  34267. * @param tessellation is the side number of the lathe.
  34268. * @param scene defines the hosting scene
  34269. * @param updatable defines if the mesh must be flagged as updatable
  34270. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34271. * @returns a new Mesh
  34272. */
  34273. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34274. /**
  34275. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34276. * @param name defines the name of the mesh to create
  34277. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34278. * @param scene defines the hosting scene
  34279. * @param updatable defines if the mesh must be flagged as updatable
  34280. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34281. * @returns a new Mesh
  34282. */
  34283. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34284. /**
  34285. * Creates a ground mesh.
  34286. * Please consider using the same method from the MeshBuilder class instead
  34287. * @param name defines the name of the mesh to create
  34288. * @param width set the width of the ground
  34289. * @param height set the height of the ground
  34290. * @param subdivisions sets the number of subdivisions per side
  34291. * @param scene defines the hosting scene
  34292. * @param updatable defines if the mesh must be flagged as updatable
  34293. * @returns a new Mesh
  34294. */
  34295. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34296. /**
  34297. * Creates a tiled ground mesh.
  34298. * Please consider using the same method from the MeshBuilder class instead
  34299. * @param name defines the name of the mesh to create
  34300. * @param xmin set the ground minimum X coordinate
  34301. * @param zmin set the ground minimum Y coordinate
  34302. * @param xmax set the ground maximum X coordinate
  34303. * @param zmax set the ground maximum Z coordinate
  34304. * @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
  34305. * @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
  34306. * @param scene defines the hosting scene
  34307. * @param updatable defines if the mesh must be flagged as updatable
  34308. * @returns a new Mesh
  34309. */
  34310. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34311. w: number;
  34312. h: number;
  34313. }, precision: {
  34314. w: number;
  34315. h: number;
  34316. }, scene: Scene, updatable?: boolean): Mesh;
  34317. /**
  34318. * Creates a ground mesh from a height map.
  34319. * Please consider using the same method from the MeshBuilder class instead
  34320. * @see https://doc.babylonjs.com/babylon101/height_map
  34321. * @param name defines the name of the mesh to create
  34322. * @param url sets the URL of the height map image resource
  34323. * @param width set the ground width size
  34324. * @param height set the ground height size
  34325. * @param subdivisions sets the number of subdivision per side
  34326. * @param minHeight is the minimum altitude on the ground
  34327. * @param maxHeight is the maximum altitude on the ground
  34328. * @param scene defines the hosting scene
  34329. * @param updatable defines if the mesh must be flagged as updatable
  34330. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34331. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34332. * @returns a new Mesh
  34333. */
  34334. 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;
  34335. /**
  34336. * Creates a tube mesh.
  34337. * The tube is a parametric shape.
  34338. * It has no predefined shape. Its final shape will depend on the input parameters.
  34339. * Please consider using the same method from the MeshBuilder class instead
  34340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34341. * @param name defines the name of the mesh to create
  34342. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34343. * @param radius sets the tube radius size
  34344. * @param tessellation is the number of sides on the tubular surface
  34345. * @param radiusFunction is a custom function. If it is not null, it overrides 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
  34346. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  34347. * @param scene defines the hosting scene
  34348. * @param updatable defines if the mesh must be flagged as updatable
  34349. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34350. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  34351. * @returns a new Mesh
  34352. */
  34353. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34354. (i: number, distance: number): number;
  34355. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34356. /**
  34357. * Creates a polyhedron mesh.
  34358. * Please consider using the same method from the MeshBuilder class instead.
  34359. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embedded types. Please refer to the type sheet in the tutorial to choose the wanted type
  34360. * * The parameter `size` (positive float, default 1) sets the polygon size
  34361. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34362. * * 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`
  34363. * * 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
  34364. * * 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)`)
  34365. * * 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 : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  34366. * * 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
  34367. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34368. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34370. * @param name defines the name of the mesh to create
  34371. * @param options defines the options used to create the mesh
  34372. * @param scene defines the hosting scene
  34373. * @returns a new Mesh
  34374. */
  34375. static CreatePolyhedron(name: string, options: {
  34376. type?: number;
  34377. size?: number;
  34378. sizeX?: number;
  34379. sizeY?: number;
  34380. sizeZ?: number;
  34381. custom?: any;
  34382. faceUV?: Vector4[];
  34383. faceColors?: Color4[];
  34384. updatable?: boolean;
  34385. sideOrientation?: number;
  34386. }, scene: Scene): Mesh;
  34387. /**
  34388. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34389. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34390. * * 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`)
  34391. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34392. * * 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
  34393. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34394. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34396. * @param name defines the name of the mesh
  34397. * @param options defines the options used to create the mesh
  34398. * @param scene defines the hosting scene
  34399. * @returns a new Mesh
  34400. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34401. */
  34402. static CreateIcoSphere(name: string, options: {
  34403. radius?: number;
  34404. flat?: boolean;
  34405. subdivisions?: number;
  34406. sideOrientation?: number;
  34407. updatable?: boolean;
  34408. }, scene: Scene): Mesh;
  34409. /**
  34410. * Creates a decal mesh.
  34411. * Please consider using the same method from the MeshBuilder class instead.
  34412. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34413. * @param name defines the name of the mesh
  34414. * @param sourceMesh defines the mesh receiving the decal
  34415. * @param position sets the position of the decal in world coordinates
  34416. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34417. * @param size sets the decal scaling
  34418. * @param angle sets the angle to rotate the decal
  34419. * @returns a new Mesh
  34420. */
  34421. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34422. /** Creates a Capsule Mesh
  34423. * @param name defines the name of the mesh.
  34424. * @param options the constructors options used to shape the mesh.
  34425. * @param scene defines the scene the mesh is scoped to.
  34426. * @returns the capsule mesh
  34427. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34428. */
  34429. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34430. /**
  34431. * Prepare internal position array for software CPU skinning
  34432. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34433. */
  34434. setPositionsForCPUSkinning(): Float32Array;
  34435. /**
  34436. * Prepare internal normal array for software CPU skinning
  34437. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34438. */
  34439. setNormalsForCPUSkinning(): Float32Array;
  34440. /**
  34441. * Updates the vertex buffer by applying transformation from the bones
  34442. * @param skeleton defines the skeleton to apply to current mesh
  34443. * @returns the current mesh
  34444. */
  34445. applySkeleton(skeleton: Skeleton): Mesh;
  34446. /**
  34447. * 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
  34448. * @param meshes defines the list of meshes to scan
  34449. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34450. */
  34451. static MinMax(meshes: AbstractMesh[]): {
  34452. min: Vector3;
  34453. max: Vector3;
  34454. };
  34455. /**
  34456. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34457. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34458. * @returns a vector3
  34459. */
  34460. static Center(meshesOrMinMaxVector: {
  34461. min: Vector3;
  34462. max: Vector3;
  34463. } | AbstractMesh[]): Vector3;
  34464. /**
  34465. * Merge the array of meshes into a single mesh for performance reasons.
  34466. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34467. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34468. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34469. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34470. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34471. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34472. * @returns a new mesh
  34473. */
  34474. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34475. /** @hidden */
  34476. addInstance(instance: InstancedMesh): void;
  34477. /** @hidden */
  34478. removeInstance(instance: InstancedMesh): void;
  34479. }
  34480. }
  34481. declare module BABYLON {
  34482. /**
  34483. * The options Interface for creating a Capsule Mesh
  34484. */
  34485. export interface ICreateCapsuleOptions {
  34486. /** The Orientation of the capsule. Default : Vector3.Up() */
  34487. orientation?: Vector3;
  34488. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34489. subdivisions: number;
  34490. /** Number of cylindrical segments on the capsule. */
  34491. tessellation: number;
  34492. /** Height or Length of the capsule. */
  34493. height: number;
  34494. /** Radius of the capsule. */
  34495. radius: number;
  34496. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34497. capSubdivisions: number;
  34498. /** Overwrite for the top radius. */
  34499. radiusTop?: number;
  34500. /** Overwrite for the bottom radius. */
  34501. radiusBottom?: number;
  34502. /** Overwrite for the top capSubdivisions. */
  34503. topCapSubdivisions?: number;
  34504. /** Overwrite for the bottom capSubdivisions. */
  34505. bottomCapSubdivisions?: number;
  34506. }
  34507. /**
  34508. * Class containing static functions to help procedurally build meshes
  34509. */
  34510. export class CapsuleBuilder {
  34511. /**
  34512. * Creates a capsule or a pill mesh
  34513. * @param name defines the name of the mesh
  34514. * @param options The constructors options.
  34515. * @param scene The scene the mesh is scoped to.
  34516. * @returns Capsule Mesh
  34517. */
  34518. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34519. }
  34520. }
  34521. declare module BABYLON {
  34522. /**
  34523. * Define an interface for all classes that will get and set the data on vertices
  34524. */
  34525. export interface IGetSetVerticesData {
  34526. /**
  34527. * Gets a boolean indicating if specific vertex data is present
  34528. * @param kind defines the vertex data kind to use
  34529. * @returns true is data kind is present
  34530. */
  34531. isVerticesDataPresent(kind: string): boolean;
  34532. /**
  34533. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34534. * @param kind defines the data kind (Position, normal, etc...)
  34535. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34536. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34537. * @returns a float array containing vertex data
  34538. */
  34539. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34540. /**
  34541. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34542. * @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.
  34543. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34544. * @returns the indices array or an empty array if the mesh has no geometry
  34545. */
  34546. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34547. /**
  34548. * Set specific vertex data
  34549. * @param kind defines the data kind (Position, normal, etc...)
  34550. * @param data defines the vertex data to use
  34551. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34552. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34553. */
  34554. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34555. /**
  34556. * Update a specific associated vertex buffer
  34557. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34558. * - VertexBuffer.PositionKind
  34559. * - VertexBuffer.UVKind
  34560. * - VertexBuffer.UV2Kind
  34561. * - VertexBuffer.UV3Kind
  34562. * - VertexBuffer.UV4Kind
  34563. * - VertexBuffer.UV5Kind
  34564. * - VertexBuffer.UV6Kind
  34565. * - VertexBuffer.ColorKind
  34566. * - VertexBuffer.MatricesIndicesKind
  34567. * - VertexBuffer.MatricesIndicesExtraKind
  34568. * - VertexBuffer.MatricesWeightsKind
  34569. * - VertexBuffer.MatricesWeightsExtraKind
  34570. * @param data defines the data source
  34571. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34572. * @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)
  34573. */
  34574. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34575. /**
  34576. * Creates a new index buffer
  34577. * @param indices defines the indices to store in the index buffer
  34578. * @param totalVertices defines the total number of vertices (could be null)
  34579. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34580. */
  34581. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34582. }
  34583. /**
  34584. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34585. */
  34586. export class VertexData {
  34587. /**
  34588. * Mesh side orientation : usually the external or front surface
  34589. */
  34590. static readonly FRONTSIDE: number;
  34591. /**
  34592. * Mesh side orientation : usually the internal or back surface
  34593. */
  34594. static readonly BACKSIDE: number;
  34595. /**
  34596. * Mesh side orientation : both internal and external or front and back surfaces
  34597. */
  34598. static readonly DOUBLESIDE: number;
  34599. /**
  34600. * Mesh side orientation : by default, `FRONTSIDE`
  34601. */
  34602. static readonly DEFAULTSIDE: number;
  34603. /**
  34604. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34605. */
  34606. positions: Nullable<FloatArray>;
  34607. /**
  34608. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34609. */
  34610. normals: Nullable<FloatArray>;
  34611. /**
  34612. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34613. */
  34614. tangents: Nullable<FloatArray>;
  34615. /**
  34616. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34617. */
  34618. uvs: Nullable<FloatArray>;
  34619. /**
  34620. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34621. */
  34622. uvs2: Nullable<FloatArray>;
  34623. /**
  34624. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34625. */
  34626. uvs3: Nullable<FloatArray>;
  34627. /**
  34628. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34629. */
  34630. uvs4: Nullable<FloatArray>;
  34631. /**
  34632. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34633. */
  34634. uvs5: Nullable<FloatArray>;
  34635. /**
  34636. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34637. */
  34638. uvs6: Nullable<FloatArray>;
  34639. /**
  34640. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34641. */
  34642. colors: Nullable<FloatArray>;
  34643. /**
  34644. * 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).
  34645. */
  34646. matricesIndices: Nullable<FloatArray>;
  34647. /**
  34648. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34649. */
  34650. matricesWeights: Nullable<FloatArray>;
  34651. /**
  34652. * An array extending the number of possible indices
  34653. */
  34654. matricesIndicesExtra: Nullable<FloatArray>;
  34655. /**
  34656. * An array extending the number of possible weights when the number of indices is extended
  34657. */
  34658. matricesWeightsExtra: Nullable<FloatArray>;
  34659. /**
  34660. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34661. */
  34662. indices: Nullable<IndicesArray>;
  34663. /**
  34664. * Uses the passed data array to set the set the values for the specified kind of data
  34665. * @param data a linear array of floating numbers
  34666. * @param kind the type of data that is being set, eg positions, colors etc
  34667. */
  34668. set(data: FloatArray, kind: string): void;
  34669. /**
  34670. * Associates the vertexData to the passed Mesh.
  34671. * Sets it as updatable or not (default `false`)
  34672. * @param mesh the mesh the vertexData is applied to
  34673. * @param updatable when used and having the value true allows new data to update the vertexData
  34674. * @returns the VertexData
  34675. */
  34676. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34677. /**
  34678. * Associates the vertexData to the passed Geometry.
  34679. * Sets it as updatable or not (default `false`)
  34680. * @param geometry the geometry the vertexData is applied to
  34681. * @param updatable when used and having the value true allows new data to update the vertexData
  34682. * @returns VertexData
  34683. */
  34684. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34685. /**
  34686. * Updates the associated mesh
  34687. * @param mesh the mesh to be updated
  34688. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34689. * @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
  34690. * @returns VertexData
  34691. */
  34692. updateMesh(mesh: Mesh): VertexData;
  34693. /**
  34694. * Updates the associated geometry
  34695. * @param geometry the geometry to be updated
  34696. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34697. * @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
  34698. * @returns VertexData.
  34699. */
  34700. updateGeometry(geometry: Geometry): VertexData;
  34701. private _applyTo;
  34702. private _update;
  34703. /**
  34704. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34705. * @param matrix the transforming matrix
  34706. * @returns the VertexData
  34707. */
  34708. transform(matrix: Matrix): VertexData;
  34709. /**
  34710. * Merges the passed VertexData into the current one
  34711. * @param other the VertexData to be merged into the current one
  34712. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34713. * @returns the modified VertexData
  34714. */
  34715. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34716. private _mergeElement;
  34717. private _validate;
  34718. /**
  34719. * Serializes the VertexData
  34720. * @returns a serialized object
  34721. */
  34722. serialize(): any;
  34723. /**
  34724. * Extracts the vertexData from a mesh
  34725. * @param mesh the mesh from which to extract the VertexData
  34726. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34727. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34728. * @returns the object VertexData associated to the passed mesh
  34729. */
  34730. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34731. /**
  34732. * Extracts the vertexData from the geometry
  34733. * @param geometry the geometry from which to extract the VertexData
  34734. * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
  34735. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34736. * @returns the object VertexData associated to the passed mesh
  34737. */
  34738. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34739. private static _ExtractFrom;
  34740. /**
  34741. * Creates the VertexData for a Ribbon
  34742. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34743. * * pathArray array of paths, each of which an array of successive Vector3
  34744. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34745. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34746. * * 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
  34747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34748. * * 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)
  34749. * * 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)
  34750. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34751. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34752. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34753. * @returns the VertexData of the ribbon
  34754. */
  34755. static CreateRibbon(options: {
  34756. pathArray: Vector3[][];
  34757. closeArray?: boolean;
  34758. closePath?: boolean;
  34759. offset?: number;
  34760. sideOrientation?: number;
  34761. frontUVs?: Vector4;
  34762. backUVs?: Vector4;
  34763. invertUV?: boolean;
  34764. uvs?: Vector2[];
  34765. colors?: Color4[];
  34766. }): VertexData;
  34767. /**
  34768. * Creates the VertexData for a box
  34769. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34770. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34771. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34772. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34773. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34774. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34775. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34776. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34777. * * 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)
  34778. * * 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)
  34779. * @returns the VertexData of the box
  34780. */
  34781. static CreateBox(options: {
  34782. size?: number;
  34783. width?: number;
  34784. height?: number;
  34785. depth?: number;
  34786. faceUV?: Vector4[];
  34787. faceColors?: Color4[];
  34788. sideOrientation?: number;
  34789. frontUVs?: Vector4;
  34790. backUVs?: Vector4;
  34791. }): VertexData;
  34792. /**
  34793. * Creates the VertexData for a tiled box
  34794. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34795. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34796. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34797. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34798. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34799. * @returns the VertexData of the box
  34800. */
  34801. static CreateTiledBox(options: {
  34802. pattern?: number;
  34803. width?: number;
  34804. height?: number;
  34805. depth?: number;
  34806. tileSize?: number;
  34807. tileWidth?: number;
  34808. tileHeight?: number;
  34809. alignHorizontal?: number;
  34810. alignVertical?: number;
  34811. faceUV?: Vector4[];
  34812. faceColors?: Color4[];
  34813. sideOrientation?: number;
  34814. }): VertexData;
  34815. /**
  34816. * Creates the VertexData for a tiled plane
  34817. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34818. * * pattern a limited pattern arrangement depending on the number
  34819. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34820. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34821. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34822. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34823. * * 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)
  34824. * * 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)
  34825. * @returns the VertexData of the tiled plane
  34826. */
  34827. static CreateTiledPlane(options: {
  34828. pattern?: number;
  34829. tileSize?: number;
  34830. tileWidth?: number;
  34831. tileHeight?: number;
  34832. size?: number;
  34833. width?: number;
  34834. height?: number;
  34835. alignHorizontal?: number;
  34836. alignVertical?: number;
  34837. sideOrientation?: number;
  34838. frontUVs?: Vector4;
  34839. backUVs?: Vector4;
  34840. }): VertexData;
  34841. /**
  34842. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34843. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34844. * * segments sets the number of horizontal strips optional, default 32
  34845. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34846. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34847. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34848. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34849. * * 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
  34850. * * 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
  34851. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34852. * * 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)
  34853. * * 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)
  34854. * @returns the VertexData of the ellipsoid
  34855. */
  34856. static CreateSphere(options: {
  34857. segments?: number;
  34858. diameter?: number;
  34859. diameterX?: number;
  34860. diameterY?: number;
  34861. diameterZ?: number;
  34862. arc?: number;
  34863. slice?: number;
  34864. sideOrientation?: number;
  34865. frontUVs?: Vector4;
  34866. backUVs?: Vector4;
  34867. }): VertexData;
  34868. /**
  34869. * Creates the VertexData for a cylinder, cone or prism
  34870. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34871. * * height sets the height (y direction) of the cylinder, optional, default 2
  34872. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34873. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34874. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34875. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34876. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34877. * * 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
  34878. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34879. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34880. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34881. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34882. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34883. * * 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)
  34884. * * 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)
  34885. * @returns the VertexData of the cylinder, cone or prism
  34886. */
  34887. static CreateCylinder(options: {
  34888. height?: number;
  34889. diameterTop?: number;
  34890. diameterBottom?: number;
  34891. diameter?: number;
  34892. tessellation?: number;
  34893. subdivisions?: number;
  34894. arc?: number;
  34895. faceColors?: Color4[];
  34896. faceUV?: Vector4[];
  34897. hasRings?: boolean;
  34898. enclose?: boolean;
  34899. sideOrientation?: number;
  34900. frontUVs?: Vector4;
  34901. backUVs?: Vector4;
  34902. }): VertexData;
  34903. /**
  34904. * Creates the VertexData for a torus
  34905. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34906. * * diameter the diameter of the torus, optional default 1
  34907. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34908. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34910. * * 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)
  34911. * * 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)
  34912. * @returns the VertexData of the torus
  34913. */
  34914. static CreateTorus(options: {
  34915. diameter?: number;
  34916. thickness?: number;
  34917. tessellation?: number;
  34918. sideOrientation?: number;
  34919. frontUVs?: Vector4;
  34920. backUVs?: Vector4;
  34921. }): VertexData;
  34922. /**
  34923. * Creates the VertexData of the LineSystem
  34924. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  34925. * - lines an array of lines, each line being an array of successive Vector3
  34926. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  34927. * @returns the VertexData of the LineSystem
  34928. */
  34929. static CreateLineSystem(options: {
  34930. lines: Vector3[][];
  34931. colors?: Nullable<Color4[][]>;
  34932. }): VertexData;
  34933. /**
  34934. * Create the VertexData for a DashedLines
  34935. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  34936. * - points an array successive Vector3
  34937. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  34938. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  34939. * - dashNb the intended total number of dashes, optional, default 200
  34940. * @returns the VertexData for the DashedLines
  34941. */
  34942. static CreateDashedLines(options: {
  34943. points: Vector3[];
  34944. dashSize?: number;
  34945. gapSize?: number;
  34946. dashNb?: number;
  34947. }): VertexData;
  34948. /**
  34949. * Creates the VertexData for a Ground
  34950. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34951. * - width the width (x direction) of the ground, optional, default 1
  34952. * - height the height (z direction) of the ground, optional, default 1
  34953. * - subdivisions the number of subdivisions per side, optional, default 1
  34954. * @returns the VertexData of the Ground
  34955. */
  34956. static CreateGround(options: {
  34957. width?: number;
  34958. height?: number;
  34959. subdivisions?: number;
  34960. subdivisionsX?: number;
  34961. subdivisionsY?: number;
  34962. }): VertexData;
  34963. /**
  34964. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  34965. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34966. * * xmin the ground minimum X coordinate, optional, default -1
  34967. * * zmin the ground minimum Z coordinate, optional, default -1
  34968. * * xmax the ground maximum X coordinate, optional, default 1
  34969. * * zmax the ground maximum Z coordinate, optional, default 1
  34970. * * 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}
  34971. * * 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}
  34972. * @returns the VertexData of the TiledGround
  34973. */
  34974. static CreateTiledGround(options: {
  34975. xmin: number;
  34976. zmin: number;
  34977. xmax: number;
  34978. zmax: number;
  34979. subdivisions?: {
  34980. w: number;
  34981. h: number;
  34982. };
  34983. precision?: {
  34984. w: number;
  34985. h: number;
  34986. };
  34987. }): VertexData;
  34988. /**
  34989. * Creates the VertexData of the Ground designed from a heightmap
  34990. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  34991. * * width the width (x direction) of the ground
  34992. * * height the height (z direction) of the ground
  34993. * * subdivisions the number of subdivisions per side
  34994. * * minHeight the minimum altitude on the ground, optional, default 0
  34995. * * maxHeight the maximum altitude on the ground, optional default 1
  34996. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  34997. * * buffer the array holding the image color data
  34998. * * bufferWidth the width of image
  34999. * * bufferHeight the height of image
  35000. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35001. * @returns the VertexData of the Ground designed from a heightmap
  35002. */
  35003. static CreateGroundFromHeightMap(options: {
  35004. width: number;
  35005. height: number;
  35006. subdivisions: number;
  35007. minHeight: number;
  35008. maxHeight: number;
  35009. colorFilter: Color3;
  35010. buffer: Uint8Array;
  35011. bufferWidth: number;
  35012. bufferHeight: number;
  35013. alphaFilter: number;
  35014. }): VertexData;
  35015. /**
  35016. * Creates the VertexData for a Plane
  35017. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35018. * * size sets the width and height of the plane to the value of size, optional default 1
  35019. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35020. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35022. * * 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)
  35023. * * 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)
  35024. * @returns the VertexData of the box
  35025. */
  35026. static CreatePlane(options: {
  35027. size?: number;
  35028. width?: number;
  35029. height?: number;
  35030. sideOrientation?: number;
  35031. frontUVs?: Vector4;
  35032. backUVs?: Vector4;
  35033. }): VertexData;
  35034. /**
  35035. * Creates the VertexData of the Disc or regular Polygon
  35036. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35037. * * radius the radius of the disc, optional default 0.5
  35038. * * tessellation the number of polygon sides, optional, default 64
  35039. * * 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
  35040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35041. * * 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)
  35042. * * 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)
  35043. * @returns the VertexData of the box
  35044. */
  35045. static CreateDisc(options: {
  35046. radius?: number;
  35047. tessellation?: number;
  35048. arc?: number;
  35049. sideOrientation?: number;
  35050. frontUVs?: Vector4;
  35051. backUVs?: Vector4;
  35052. }): VertexData;
  35053. /**
  35054. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35055. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35056. * @param polygon a mesh built from polygonTriangulation.build()
  35057. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35058. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35059. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35060. * @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)
  35061. * @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)
  35062. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35063. * @returns the VertexData of the Polygon
  35064. */
  35065. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35066. /**
  35067. * Creates the VertexData of the IcoSphere
  35068. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35069. * * radius the radius of the IcoSphere, optional default 1
  35070. * * radiusX allows stretching in the x direction, optional, default radius
  35071. * * radiusY allows stretching in the y direction, optional, default radius
  35072. * * radiusZ allows stretching in the z direction, optional, default radius
  35073. * * flat when true creates a flat shaded mesh, optional, default true
  35074. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35075. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35076. * * 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)
  35077. * * 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)
  35078. * @returns the VertexData of the IcoSphere
  35079. */
  35080. static CreateIcoSphere(options: {
  35081. radius?: number;
  35082. radiusX?: number;
  35083. radiusY?: number;
  35084. radiusZ?: number;
  35085. flat?: boolean;
  35086. subdivisions?: number;
  35087. sideOrientation?: number;
  35088. frontUVs?: Vector4;
  35089. backUVs?: Vector4;
  35090. }): VertexData;
  35091. /**
  35092. * Creates the VertexData for a Polyhedron
  35093. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35094. * * type provided types are:
  35095. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35096. * * 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)
  35097. * * size the size of the IcoSphere, optional default 1
  35098. * * sizeX allows stretching in the x direction, optional, default size
  35099. * * sizeY allows stretching in the y direction, optional, default size
  35100. * * sizeZ allows stretching in the z direction, optional, default size
  35101. * * 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
  35102. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35103. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35104. * * flat when true creates a flat shaded mesh, optional, default true
  35105. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35106. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35107. * * 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)
  35108. * * 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)
  35109. * @returns the VertexData of the Polyhedron
  35110. */
  35111. static CreatePolyhedron(options: {
  35112. type?: number;
  35113. size?: number;
  35114. sizeX?: number;
  35115. sizeY?: number;
  35116. sizeZ?: number;
  35117. custom?: any;
  35118. faceUV?: Vector4[];
  35119. faceColors?: Color4[];
  35120. flat?: boolean;
  35121. sideOrientation?: number;
  35122. frontUVs?: Vector4;
  35123. backUVs?: Vector4;
  35124. }): VertexData;
  35125. /**
  35126. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35127. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35128. * @returns the VertexData of the Capsule
  35129. */
  35130. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35131. /**
  35132. * Creates the VertexData for a TorusKnot
  35133. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35134. * * radius the radius of the torus knot, optional, default 2
  35135. * * tube the thickness of the tube, optional, default 0.5
  35136. * * radialSegments the number of sides on each tube segments, optional, default 32
  35137. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35138. * * p the number of windings around the z axis, optional, default 2
  35139. * * q the number of windings around the x axis, optional, default 3
  35140. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35141. * * 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)
  35142. * * 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)
  35143. * @returns the VertexData of the Torus Knot
  35144. */
  35145. static CreateTorusKnot(options: {
  35146. radius?: number;
  35147. tube?: number;
  35148. radialSegments?: number;
  35149. tubularSegments?: number;
  35150. p?: number;
  35151. q?: number;
  35152. sideOrientation?: number;
  35153. frontUVs?: Vector4;
  35154. backUVs?: Vector4;
  35155. }): VertexData;
  35156. /**
  35157. * Compute normals for given positions and indices
  35158. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35159. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35160. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35161. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35162. * * facetNormals : optional array of facet normals (vector3)
  35163. * * facetPositions : optional array of facet positions (vector3)
  35164. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35165. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35166. * * bInfo : optional bounding info, required for facetPartitioning computation
  35167. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35168. * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
  35169. * * useRightHandedSystem: optional boolean to for right handed system computation
  35170. * * depthSort : optional boolean to enable the facet depth sort computation
  35171. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35172. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35173. */
  35174. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35175. facetNormals?: any;
  35176. facetPositions?: any;
  35177. facetPartitioning?: any;
  35178. ratio?: number;
  35179. bInfo?: any;
  35180. bbSize?: Vector3;
  35181. subDiv?: any;
  35182. useRightHandedSystem?: boolean;
  35183. depthSort?: boolean;
  35184. distanceTo?: Vector3;
  35185. depthSortedFacets?: any;
  35186. }): void;
  35187. /** @hidden */
  35188. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35189. /**
  35190. * Applies VertexData created from the imported parameters to the geometry
  35191. * @param parsedVertexData the parsed data from an imported file
  35192. * @param geometry the geometry to apply the VertexData to
  35193. */
  35194. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35195. }
  35196. }
  35197. declare module BABYLON {
  35198. /**
  35199. * Class containing static functions to help procedurally build meshes
  35200. */
  35201. export class DiscBuilder {
  35202. /**
  35203. * Creates a plane polygonal mesh. By default, this is a disc
  35204. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35205. * * 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
  35206. * * 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
  35207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35208. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35210. * @param name defines the name of the mesh
  35211. * @param options defines the options used to create the mesh
  35212. * @param scene defines the hosting scene
  35213. * @returns the plane polygonal mesh
  35214. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35215. */
  35216. static CreateDisc(name: string, options: {
  35217. radius?: number;
  35218. tessellation?: number;
  35219. arc?: number;
  35220. updatable?: boolean;
  35221. sideOrientation?: number;
  35222. frontUVs?: Vector4;
  35223. backUVs?: Vector4;
  35224. }, scene?: Nullable<Scene>): Mesh;
  35225. }
  35226. }
  35227. declare module BABYLON {
  35228. /**
  35229. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35230. *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.
  35231. * The SPS is also a particle system. It provides some methods to manage the particles.
  35232. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35233. *
  35234. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35235. */
  35236. export class SolidParticleSystem implements IDisposable {
  35237. /**
  35238. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35239. * Example : var p = SPS.particles[i];
  35240. */
  35241. particles: SolidParticle[];
  35242. /**
  35243. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35244. */
  35245. nbParticles: number;
  35246. /**
  35247. * If the particles must ever face the camera (default false). Useful for planar particles.
  35248. */
  35249. billboard: boolean;
  35250. /**
  35251. * Recompute normals when adding a shape
  35252. */
  35253. recomputeNormals: boolean;
  35254. /**
  35255. * This a counter ofr your own usage. It's not set by any SPS functions.
  35256. */
  35257. counter: number;
  35258. /**
  35259. * The SPS name. This name is also given to the underlying mesh.
  35260. */
  35261. name: string;
  35262. /**
  35263. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  35264. */
  35265. mesh: Mesh;
  35266. /**
  35267. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35268. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35269. */
  35270. vars: any;
  35271. /**
  35272. * This array is populated when the SPS is set as 'pickable'.
  35273. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35274. * Each element of this array is an object `{idx: int, faceId: int}`.
  35275. * `idx` is the picked particle index in the `SPS.particles` array
  35276. * `faceId` is the picked face index counted within this particle.
  35277. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35278. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35279. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35280. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35281. */
  35282. pickedParticles: {
  35283. idx: number;
  35284. faceId: number;
  35285. }[];
  35286. /**
  35287. * This array is populated when the SPS is set as 'pickable'
  35288. * Each key of this array is a submesh index.
  35289. * Each element of this array is a second array defined like this :
  35290. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35291. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35292. * `idx` is the picked particle index in the `SPS.particles` array
  35293. * `faceId` is the picked face index counted within this particle.
  35294. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35295. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35296. */
  35297. pickedBySubMesh: {
  35298. idx: number;
  35299. faceId: number;
  35300. }[][];
  35301. /**
  35302. * This array is populated when `enableDepthSort` is set to true.
  35303. * Each element of this array is an instance of the class DepthSortedParticle.
  35304. */
  35305. depthSortedParticles: DepthSortedParticle[];
  35306. /**
  35307. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35308. * @hidden
  35309. */
  35310. _bSphereOnly: boolean;
  35311. /**
  35312. * A number to multiply the bounding sphere radius by in order to reduce it for instance. (Internal use only)
  35313. * @hidden
  35314. */
  35315. _bSphereRadiusFactor: number;
  35316. private _scene;
  35317. private _positions;
  35318. private _indices;
  35319. private _normals;
  35320. private _colors;
  35321. private _uvs;
  35322. private _indices32;
  35323. private _positions32;
  35324. private _normals32;
  35325. private _fixedNormal32;
  35326. private _colors32;
  35327. private _uvs32;
  35328. private _index;
  35329. private _updatable;
  35330. private _pickable;
  35331. private _isVisibilityBoxLocked;
  35332. private _alwaysVisible;
  35333. private _depthSort;
  35334. private _expandable;
  35335. private _shapeCounter;
  35336. private _copy;
  35337. private _color;
  35338. private _computeParticleColor;
  35339. private _computeParticleTexture;
  35340. private _computeParticleRotation;
  35341. private _computeParticleVertex;
  35342. private _computeBoundingBox;
  35343. private _depthSortParticles;
  35344. private _camera;
  35345. private _mustUnrotateFixedNormals;
  35346. private _particlesIntersect;
  35347. private _needs32Bits;
  35348. private _isNotBuilt;
  35349. private _lastParticleId;
  35350. private _idxOfId;
  35351. private _multimaterialEnabled;
  35352. private _useModelMaterial;
  35353. private _indicesByMaterial;
  35354. private _materialIndexes;
  35355. private _depthSortFunction;
  35356. private _materialSortFunction;
  35357. private _materials;
  35358. private _multimaterial;
  35359. private _materialIndexesById;
  35360. private _defaultMaterial;
  35361. private _autoUpdateSubMeshes;
  35362. private _tmpVertex;
  35363. /**
  35364. * Creates a SPS (Solid Particle System) object.
  35365. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35366. * @param scene (Scene) is the scene in which the SPS is added.
  35367. * @param options defines the options of the sps e.g.
  35368. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35369. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35370. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35371. * * useModelMaterial (optional boolean, default false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  35372. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35373. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35374. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35375. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35376. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the bounding sphere radius by in order to reduce it for instance.
  35377. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35378. */
  35379. constructor(name: string, scene: Scene, options?: {
  35380. updatable?: boolean;
  35381. isPickable?: boolean;
  35382. enableDepthSort?: boolean;
  35383. particleIntersection?: boolean;
  35384. boundingSphereOnly?: boolean;
  35385. bSphereRadiusFactor?: number;
  35386. expandable?: boolean;
  35387. useModelMaterial?: boolean;
  35388. enableMultiMaterial?: boolean;
  35389. });
  35390. /**
  35391. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35392. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35393. * @returns the created mesh
  35394. */
  35395. buildMesh(): Mesh;
  35396. /**
  35397. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35398. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35399. * Thus the particles generated from `digest()` have their property `position` set yet.
  35400. * @param mesh ( Mesh ) is the mesh to be digested
  35401. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overridden by the parameter `number` if any
  35402. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35403. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35404. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35405. * @returns the current SPS
  35406. */
  35407. digest(mesh: Mesh, options?: {
  35408. facetNb?: number;
  35409. number?: number;
  35410. delta?: number;
  35411. storage?: [];
  35412. }): SolidParticleSystem;
  35413. /**
  35414. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35415. * @hidden
  35416. */
  35417. private _unrotateFixedNormals;
  35418. /**
  35419. * Resets the temporary working copy particle
  35420. * @hidden
  35421. */
  35422. private _resetCopy;
  35423. /**
  35424. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35425. * @param p the current index in the positions array to be updated
  35426. * @param ind the current index in the indices array
  35427. * @param shape a Vector3 array, the shape geometry
  35428. * @param positions the positions array to be updated
  35429. * @param meshInd the shape indices array
  35430. * @param indices the indices array to be updated
  35431. * @param meshUV the shape uv array
  35432. * @param uvs the uv array to be updated
  35433. * @param meshCol the shape color array
  35434. * @param colors the color array to be updated
  35435. * @param meshNor the shape normals array
  35436. * @param normals the normals array to be updated
  35437. * @param idx the particle index
  35438. * @param idxInShape the particle index in its shape
  35439. * @param options the addShape() method passed options
  35440. * @model the particle model
  35441. * @hidden
  35442. */
  35443. private _meshBuilder;
  35444. /**
  35445. * Returns a shape Vector3 array from positions float array
  35446. * @param positions float array
  35447. * @returns a vector3 array
  35448. * @hidden
  35449. */
  35450. private _posToShape;
  35451. /**
  35452. * Returns a shapeUV array from a float uvs (array deep copy)
  35453. * @param uvs as a float array
  35454. * @returns a shapeUV array
  35455. * @hidden
  35456. */
  35457. private _uvsToShapeUV;
  35458. /**
  35459. * Adds a new particle object in the particles array
  35460. * @param idx particle index in particles array
  35461. * @param id particle id
  35462. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35463. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35464. * @param model particle ModelShape object
  35465. * @param shapeId model shape identifier
  35466. * @param idxInShape index of the particle in the current model
  35467. * @param bInfo model bounding info object
  35468. * @param storage target storage array, if any
  35469. * @hidden
  35470. */
  35471. private _addParticle;
  35472. /**
  35473. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35474. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35475. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35476. * @param nb (positive integer) the number of particles to be created from this model
  35477. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35478. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35479. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35480. * @returns the number of shapes in the system
  35481. */
  35482. addShape(mesh: Mesh, nb: number, options?: {
  35483. positionFunction?: any;
  35484. vertexFunction?: any;
  35485. storage?: [];
  35486. }): number;
  35487. /**
  35488. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35489. * @hidden
  35490. */
  35491. private _rebuildParticle;
  35492. /**
  35493. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35494. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  35495. * @returns the SPS.
  35496. */
  35497. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35498. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35499. * Returns an array with the removed particles.
  35500. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  35501. * The SPS can't be empty so at least one particle needs to remain in place.
  35502. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35503. * @param start index of the first particle to remove
  35504. * @param end index of the last particle to remove (included)
  35505. * @returns an array populated with the removed particles
  35506. */
  35507. removeParticles(start: number, end: number): SolidParticle[];
  35508. /**
  35509. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35510. * @param solidParticleArray an array populated with Solid Particles objects
  35511. * @returns the SPS
  35512. */
  35513. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35514. /**
  35515. * Creates a new particle and modifies the SPS mesh geometry :
  35516. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35517. * - calls _addParticle() to populate the particle array
  35518. * factorized code from addShape() and insertParticlesFromArray()
  35519. * @param idx particle index in the particles array
  35520. * @param i particle index in its shape
  35521. * @param modelShape particle ModelShape object
  35522. * @param shape shape vertex array
  35523. * @param meshInd shape indices array
  35524. * @param meshUV shape uv array
  35525. * @param meshCol shape color array
  35526. * @param meshNor shape normals array
  35527. * @param bbInfo shape bounding info
  35528. * @param storage target particle storage
  35529. * @options addShape() passed options
  35530. * @hidden
  35531. */
  35532. private _insertNewParticle;
  35533. /**
  35534. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35535. * This method calls `updateParticle()` for each particle of the SPS.
  35536. * For an animated SPS, it is usually called within the render loop.
  35537. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  35538. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35539. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35540. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35541. * @returns the SPS.
  35542. */
  35543. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35544. /**
  35545. * Disposes the SPS.
  35546. */
  35547. dispose(): void;
  35548. /** Returns an object {idx: number faceId: number} for the picked particle from the passed pickingInfo object.
  35549. * idx is the particle index in the SPS
  35550. * faceId is the picked face index counted within this particle.
  35551. * Returns null if the pickInfo can't identify a picked particle.
  35552. * @param pickingInfo (PickingInfo object)
  35553. * @returns {idx: number, faceId: number} or null
  35554. */
  35555. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35556. idx: number;
  35557. faceId: number;
  35558. }>;
  35559. /**
  35560. * Returns a SolidParticle object from its identifier : particle.id
  35561. * @param id (integer) the particle Id
  35562. * @returns the searched particle or null if not found in the SPS.
  35563. */
  35564. getParticleById(id: number): Nullable<SolidParticle>;
  35565. /**
  35566. * Returns a new array populated with the particles having the passed shapeId.
  35567. * @param shapeId (integer) the shape identifier
  35568. * @returns a new solid particle array
  35569. */
  35570. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35571. /**
  35572. * Populates the passed array "ref" with the particles having the passed shapeId.
  35573. * @param shapeId the shape identifier
  35574. * @returns the SPS
  35575. * @param ref
  35576. */
  35577. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35578. /**
  35579. * Computes the required SubMeshes according the materials assigned to the particles.
  35580. * @returns the solid particle system.
  35581. * Does nothing if called before the SPS mesh is built.
  35582. */
  35583. computeSubMeshes(): SolidParticleSystem;
  35584. /**
  35585. * Sorts the solid particles by material when MultiMaterial is enabled.
  35586. * Updates the indices32 array.
  35587. * Updates the indicesByMaterial array.
  35588. * Updates the mesh indices array.
  35589. * @returns the SPS
  35590. * @hidden
  35591. */
  35592. private _sortParticlesByMaterial;
  35593. /**
  35594. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35595. * @hidden
  35596. */
  35597. private _setMaterialIndexesById;
  35598. /**
  35599. * Returns an array with unique values of Materials from the passed array
  35600. * @param array the material array to be checked and filtered
  35601. * @hidden
  35602. */
  35603. private _filterUniqueMaterialId;
  35604. /**
  35605. * Sets a new Standard Material as _defaultMaterial if not already set.
  35606. * @hidden
  35607. */
  35608. private _setDefaultMaterial;
  35609. /**
  35610. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  35611. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35612. * @returns the SPS.
  35613. */
  35614. refreshVisibleSize(): SolidParticleSystem;
  35615. /**
  35616. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35617. * @param size the size (float) of the visibility box
  35618. * note : this doesn't lock the SPS mesh bounding box.
  35619. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35620. */
  35621. setVisibilityBox(size: number): void;
  35622. /**
  35623. * Gets whether the SPS as always visible or not
  35624. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35625. */
  35626. get isAlwaysVisible(): boolean;
  35627. /**
  35628. * Sets the SPS as always visible or not
  35629. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35630. */
  35631. set isAlwaysVisible(val: boolean);
  35632. /**
  35633. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35634. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35635. */
  35636. set isVisibilityBoxLocked(val: boolean);
  35637. /**
  35638. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35639. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35640. */
  35641. get isVisibilityBoxLocked(): boolean;
  35642. /**
  35643. * Tells to `setParticles()` to compute the particle rotations or not.
  35644. * Default value : true. The SPS is faster when it's set to false.
  35645. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35646. */
  35647. set computeParticleRotation(val: boolean);
  35648. /**
  35649. * Tells to `setParticles()` to compute the particle colors or not.
  35650. * Default value : true. The SPS is faster when it's set to false.
  35651. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35652. */
  35653. set computeParticleColor(val: boolean);
  35654. set computeParticleTexture(val: boolean);
  35655. /**
  35656. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35657. * Default value : false. The SPS is faster when it's set to false.
  35658. * Note : the particle custom vertex positions aren't stored values.
  35659. */
  35660. set computeParticleVertex(val: boolean);
  35661. /**
  35662. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35663. */
  35664. set computeBoundingBox(val: boolean);
  35665. /**
  35666. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35667. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35668. * Default : `true`
  35669. */
  35670. set depthSortParticles(val: boolean);
  35671. /**
  35672. * Gets if `setParticles()` computes the particle rotations or not.
  35673. * Default value : true. The SPS is faster when it's set to false.
  35674. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35675. */
  35676. get computeParticleRotation(): boolean;
  35677. /**
  35678. * Gets if `setParticles()` computes the particle colors or not.
  35679. * Default value : true. The SPS is faster when it's set to false.
  35680. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35681. */
  35682. get computeParticleColor(): boolean;
  35683. /**
  35684. * Gets if `setParticles()` computes the particle textures or not.
  35685. * Default value : true. The SPS is faster when it's set to false.
  35686. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35687. */
  35688. get computeParticleTexture(): boolean;
  35689. /**
  35690. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35691. * Default value : false. The SPS is faster when it's set to false.
  35692. * Note : the particle custom vertex positions aren't stored values.
  35693. */
  35694. get computeParticleVertex(): boolean;
  35695. /**
  35696. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35697. */
  35698. get computeBoundingBox(): boolean;
  35699. /**
  35700. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35701. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35702. * Default : `true`
  35703. */
  35704. get depthSortParticles(): boolean;
  35705. /**
  35706. * Gets if the SPS is created as expandable at construction time.
  35707. * Default : `false`
  35708. */
  35709. get expandable(): boolean;
  35710. /**
  35711. * Gets if the SPS supports the Multi Materials
  35712. */
  35713. get multimaterialEnabled(): boolean;
  35714. /**
  35715. * Gets if the SPS uses the model materials for its own multimaterial.
  35716. */
  35717. get useModelMaterial(): boolean;
  35718. /**
  35719. * The SPS used material array.
  35720. */
  35721. get materials(): Material[];
  35722. /**
  35723. * Sets the SPS MultiMaterial from the passed materials.
  35724. * Note : the passed array is internally copied and not used then by reference.
  35725. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35726. */
  35727. setMultiMaterial(materials: Material[]): void;
  35728. /**
  35729. * The SPS computed multimaterial object
  35730. */
  35731. get multimaterial(): MultiMaterial;
  35732. set multimaterial(mm: MultiMaterial);
  35733. /**
  35734. * If the subMeshes must be updated on the next call to setParticles()
  35735. */
  35736. get autoUpdateSubMeshes(): boolean;
  35737. set autoUpdateSubMeshes(val: boolean);
  35738. /**
  35739. * This function does nothing. It may be overwritten to set all the particle first values.
  35740. * The SPS doesn't call this function, you may have to call it by your own.
  35741. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35742. */
  35743. initParticles(): void;
  35744. /**
  35745. * This function does nothing. It may be overwritten to recycle a particle.
  35746. * The SPS doesn't call this function, you may have to call it by your own.
  35747. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35748. * @param particle The particle to recycle
  35749. * @returns the recycled particle
  35750. */
  35751. recycleParticle(particle: SolidParticle): SolidParticle;
  35752. /**
  35753. * Updates a particle : this function should be overwritten by the user.
  35754. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35755. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35756. * @example : just set a particle position or velocity and recycle conditions
  35757. * @param particle The particle to update
  35758. * @returns the updated particle
  35759. */
  35760. updateParticle(particle: SolidParticle): SolidParticle;
  35761. /**
  35762. * Updates a vertex of a particle : it can be overwritten by the user.
  35763. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35764. * @param particle the current particle
  35765. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35766. * @param pt the index of the current vertex in the particle shape
  35767. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35768. * @example : just set a vertex particle position or color
  35769. * @returns the sps
  35770. */
  35771. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35772. /**
  35773. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35774. * This does nothing and may be overwritten by the user.
  35775. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35776. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35777. * @param update the boolean update value actually passed to setParticles()
  35778. */
  35779. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35780. /**
  35781. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35782. * This will be passed three parameters.
  35783. * This does nothing and may be overwritten by the user.
  35784. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35785. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35786. * @param update the boolean update value actually passed to setParticles()
  35787. */
  35788. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35789. }
  35790. }
  35791. declare module BABYLON {
  35792. /**
  35793. * Represents one particle of a solid particle system.
  35794. */
  35795. export class SolidParticle {
  35796. /**
  35797. * particle global index
  35798. */
  35799. idx: number;
  35800. /**
  35801. * particle identifier
  35802. */
  35803. id: number;
  35804. /**
  35805. * The color of the particle
  35806. */
  35807. color: Nullable<Color4>;
  35808. /**
  35809. * The world space position of the particle.
  35810. */
  35811. position: Vector3;
  35812. /**
  35813. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35814. */
  35815. rotation: Vector3;
  35816. /**
  35817. * The world space rotation quaternion of the particle.
  35818. */
  35819. rotationQuaternion: Nullable<Quaternion>;
  35820. /**
  35821. * The scaling of the particle.
  35822. */
  35823. scaling: Vector3;
  35824. /**
  35825. * The uvs of the particle.
  35826. */
  35827. uvs: Vector4;
  35828. /**
  35829. * The current speed of the particle.
  35830. */
  35831. velocity: Vector3;
  35832. /**
  35833. * The pivot point in the particle local space.
  35834. */
  35835. pivot: Vector3;
  35836. /**
  35837. * Must the particle be translated from its pivot point in its local space ?
  35838. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35839. * Default : false
  35840. */
  35841. translateFromPivot: boolean;
  35842. /**
  35843. * Is the particle active or not ?
  35844. */
  35845. alive: boolean;
  35846. /**
  35847. * Is the particle visible or not ?
  35848. */
  35849. isVisible: boolean;
  35850. /**
  35851. * Index of this particle in the global "positions" array (Internal use)
  35852. * @hidden
  35853. */
  35854. _pos: number;
  35855. /**
  35856. * @hidden Index of this particle in the global "indices" array (Internal use)
  35857. */
  35858. _ind: number;
  35859. /**
  35860. * @hidden ModelShape of this particle (Internal use)
  35861. */
  35862. _model: ModelShape;
  35863. /**
  35864. * ModelShape id of this particle
  35865. */
  35866. shapeId: number;
  35867. /**
  35868. * Index of the particle in its shape id
  35869. */
  35870. idxInShape: number;
  35871. /**
  35872. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35873. */
  35874. _modelBoundingInfo: BoundingInfo;
  35875. /**
  35876. * @hidden Particle BoundingInfo object (Internal use)
  35877. */
  35878. _boundingInfo: BoundingInfo;
  35879. /**
  35880. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35881. */
  35882. _sps: SolidParticleSystem;
  35883. /**
  35884. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35885. */
  35886. _stillInvisible: boolean;
  35887. /**
  35888. * @hidden Last computed particle rotation matrix
  35889. */
  35890. _rotationMatrix: number[];
  35891. /**
  35892. * Parent particle Id, if any.
  35893. * Default null.
  35894. */
  35895. parentId: Nullable<number>;
  35896. /**
  35897. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35898. */
  35899. materialIndex: Nullable<number>;
  35900. /**
  35901. * Custom object or properties.
  35902. */
  35903. props: Nullable<any>;
  35904. /**
  35905. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35906. * The possible values are :
  35907. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35908. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35909. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35910. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35911. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35912. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35913. * */
  35914. cullingStrategy: number;
  35915. /**
  35916. * @hidden Internal global position in the SPS.
  35917. */
  35918. _globalPosition: Vector3;
  35919. /**
  35920. * Creates a Solid Particle object.
  35921. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35922. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35923. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35924. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35925. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35926. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35927. * @param shapeId (integer) is the model shape identifier in the SPS.
  35928. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35929. * @param sps defines the sps it is associated to
  35930. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35931. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35932. */
  35933. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35934. /**
  35935. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35936. * @param target the particle target
  35937. * @returns the current particle
  35938. */
  35939. copyToRef(target: SolidParticle): SolidParticle;
  35940. /**
  35941. * Legacy support, changed scale to scaling
  35942. */
  35943. get scale(): Vector3;
  35944. /**
  35945. * Legacy support, changed scale to scaling
  35946. */
  35947. set scale(scale: Vector3);
  35948. /**
  35949. * Legacy support, changed quaternion to rotationQuaternion
  35950. */
  35951. get quaternion(): Nullable<Quaternion>;
  35952. /**
  35953. * Legacy support, changed quaternion to rotationQuaternion
  35954. */
  35955. set quaternion(q: Nullable<Quaternion>);
  35956. /**
  35957. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35958. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35959. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35960. * @returns true if it intersects
  35961. */
  35962. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35963. /**
  35964. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35965. * A particle is in the frustum if its bounding box intersects the frustum
  35966. * @param frustumPlanes defines the frustum to test
  35967. * @returns true if the particle is in the frustum planes
  35968. */
  35969. isInFrustum(frustumPlanes: Plane[]): boolean;
  35970. /**
  35971. * get the rotation matrix of the particle
  35972. * @hidden
  35973. */
  35974. getRotationMatrix(m: Matrix): void;
  35975. }
  35976. /**
  35977. * Represents the shape of the model used by one particle of a solid particle system.
  35978. * SPS internal tool, don't use it manually.
  35979. */
  35980. export class ModelShape {
  35981. /**
  35982. * The shape id
  35983. * @hidden
  35984. */
  35985. shapeID: number;
  35986. /**
  35987. * flat array of model positions (internal use)
  35988. * @hidden
  35989. */
  35990. _shape: Vector3[];
  35991. /**
  35992. * flat array of model UVs (internal use)
  35993. * @hidden
  35994. */
  35995. _shapeUV: number[];
  35996. /**
  35997. * color array of the model
  35998. * @hidden
  35999. */
  36000. _shapeColors: number[];
  36001. /**
  36002. * indices array of the model
  36003. * @hidden
  36004. */
  36005. _indices: number[];
  36006. /**
  36007. * normals array of the model
  36008. * @hidden
  36009. */
  36010. _normals: number[];
  36011. /**
  36012. * length of the shape in the model indices array (internal use)
  36013. * @hidden
  36014. */
  36015. _indicesLength: number;
  36016. /**
  36017. * Custom position function (internal use)
  36018. * @hidden
  36019. */
  36020. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36021. /**
  36022. * Custom vertex function (internal use)
  36023. * @hidden
  36024. */
  36025. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36026. /**
  36027. * Model material (internal use)
  36028. * @hidden
  36029. */
  36030. _material: Nullable<Material>;
  36031. /**
  36032. * 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.
  36033. * SPS internal tool, don't use it manually.
  36034. * @hidden
  36035. */
  36036. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  36037. }
  36038. /**
  36039. * Represents a Depth Sorted Particle in the solid particle system.
  36040. * @hidden
  36041. */
  36042. export class DepthSortedParticle {
  36043. /**
  36044. * Particle index
  36045. */
  36046. idx: number;
  36047. /**
  36048. * Index of the particle in the "indices" array
  36049. */
  36050. ind: number;
  36051. /**
  36052. * Length of the particle shape in the "indices" array
  36053. */
  36054. indicesLength: number;
  36055. /**
  36056. * Squared distance from the particle to the camera
  36057. */
  36058. sqDistance: number;
  36059. /**
  36060. * Material index when used with MultiMaterials
  36061. */
  36062. materialIndex: number;
  36063. /**
  36064. * Creates a new sorted particle
  36065. * @param materialIndex
  36066. */
  36067. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36068. }
  36069. /**
  36070. * Represents a solid particle vertex
  36071. */
  36072. export class SolidParticleVertex {
  36073. /**
  36074. * Vertex position
  36075. */
  36076. position: Vector3;
  36077. /**
  36078. * Vertex color
  36079. */
  36080. color: Color4;
  36081. /**
  36082. * Vertex UV
  36083. */
  36084. uv: Vector2;
  36085. /**
  36086. * Creates a new solid particle vertex
  36087. */
  36088. constructor();
  36089. /** Vertex x coordinate */
  36090. get x(): number;
  36091. set x(val: number);
  36092. /** Vertex y coordinate */
  36093. get y(): number;
  36094. set y(val: number);
  36095. /** Vertex z coordinate */
  36096. get z(): number;
  36097. set z(val: number);
  36098. }
  36099. }
  36100. declare module BABYLON {
  36101. /**
  36102. * @hidden
  36103. */
  36104. export class _MeshCollisionData {
  36105. _checkCollisions: boolean;
  36106. _collisionMask: number;
  36107. _collisionGroup: number;
  36108. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36109. _collider: Nullable<Collider>;
  36110. _oldPositionForCollisions: Vector3;
  36111. _diffPositionForCollisions: Vector3;
  36112. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36113. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36114. _collisionResponse: boolean;
  36115. }
  36116. }
  36117. declare module BABYLON {
  36118. /** @hidden */
  36119. class _FacetDataStorage {
  36120. facetPositions: Vector3[];
  36121. facetNormals: Vector3[];
  36122. facetPartitioning: number[][];
  36123. facetNb: number;
  36124. partitioningSubdivisions: number;
  36125. partitioningBBoxRatio: number;
  36126. facetDataEnabled: boolean;
  36127. facetParameters: any;
  36128. bbSize: Vector3;
  36129. subDiv: {
  36130. max: number;
  36131. X: number;
  36132. Y: number;
  36133. Z: number;
  36134. };
  36135. facetDepthSort: boolean;
  36136. facetDepthSortEnabled: boolean;
  36137. depthSortedIndices: IndicesArray;
  36138. depthSortedFacets: {
  36139. ind: number;
  36140. sqDistance: number;
  36141. }[];
  36142. facetDepthSortFunction: (f1: {
  36143. ind: number;
  36144. sqDistance: number;
  36145. }, f2: {
  36146. ind: number;
  36147. sqDistance: number;
  36148. }) => number;
  36149. facetDepthSortFrom: Vector3;
  36150. facetDepthSortOrigin: Vector3;
  36151. invertedMatrix: Matrix;
  36152. }
  36153. /**
  36154. * @hidden
  36155. **/
  36156. class _InternalAbstractMeshDataInfo {
  36157. _hasVertexAlpha: boolean;
  36158. _useVertexColors: boolean;
  36159. _numBoneInfluencers: number;
  36160. _applyFog: boolean;
  36161. _receiveShadows: boolean;
  36162. _facetData: _FacetDataStorage;
  36163. _visibility: number;
  36164. _skeleton: Nullable<Skeleton>;
  36165. _layerMask: number;
  36166. _computeBonesUsingShaders: boolean;
  36167. _isActive: boolean;
  36168. _onlyForInstances: boolean;
  36169. _isActiveIntermediate: boolean;
  36170. _onlyForInstancesIntermediate: boolean;
  36171. _actAsRegularMesh: boolean;
  36172. _currentLOD: Nullable<AbstractMesh>;
  36173. _currentLODIsUpToDate: boolean;
  36174. }
  36175. /**
  36176. * Class used to store all common mesh properties
  36177. */
  36178. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36179. /** No occlusion */
  36180. static OCCLUSION_TYPE_NONE: number;
  36181. /** Occlusion set to optimistic */
  36182. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36183. /** Occlusion set to strict */
  36184. static OCCLUSION_TYPE_STRICT: number;
  36185. /** Use an accurate occlusion algorithm */
  36186. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36187. /** Use a conservative occlusion algorithm */
  36188. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36189. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36190. * Test order :
  36191. * Is the bounding sphere outside the frustum ?
  36192. * If not, are the bounding box vertices outside the frustum ?
  36193. * It not, then the cullable object is in the frustum.
  36194. */
  36195. static readonly CULLINGSTRATEGY_STANDARD: number;
  36196. /** Culling strategy : Bounding Sphere Only.
  36197. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36198. * It's also less accurate than the standard because some not visible objects can still be selected.
  36199. * Test : is the bounding sphere outside the frustum ?
  36200. * If not, then the cullable object is in the frustum.
  36201. */
  36202. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36203. /** Culling strategy : Optimistic Inclusion.
  36204. * This in an inclusion test first, then the standard exclusion test.
  36205. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36206. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  36207. * Anyway, it's as accurate as the standard strategy.
  36208. * Test :
  36209. * Is the cullable object bounding sphere center in the frustum ?
  36210. * If not, apply the default culling strategy.
  36211. */
  36212. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36213. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36214. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36215. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36216. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  36217. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36218. * Test :
  36219. * Is the cullable object bounding sphere center in the frustum ?
  36220. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36221. */
  36222. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36223. /**
  36224. * No billboard
  36225. */
  36226. static get BILLBOARDMODE_NONE(): number;
  36227. /** Billboard on X axis */
  36228. static get BILLBOARDMODE_X(): number;
  36229. /** Billboard on Y axis */
  36230. static get BILLBOARDMODE_Y(): number;
  36231. /** Billboard on Z axis */
  36232. static get BILLBOARDMODE_Z(): number;
  36233. /** Billboard on all axes */
  36234. static get BILLBOARDMODE_ALL(): number;
  36235. /** Billboard on using position instead of orientation */
  36236. static get BILLBOARDMODE_USE_POSITION(): number;
  36237. /** @hidden */
  36238. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36239. /**
  36240. * The culling strategy to use to check whether the mesh must be rendered or not.
  36241. * This value can be changed at any time and will be used on the next render mesh selection.
  36242. * The possible values are :
  36243. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36244. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36245. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36246. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36247. * Please read each static variable documentation to get details about the culling process.
  36248. * */
  36249. cullingStrategy: number;
  36250. /**
  36251. * Gets the number of facets in the mesh
  36252. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36253. */
  36254. get facetNb(): number;
  36255. /**
  36256. * Gets or set the number (integer) of subdivisions per axis in the partitioning space
  36257. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36258. */
  36259. get partitioningSubdivisions(): number;
  36260. set partitioningSubdivisions(nb: number);
  36261. /**
  36262. * The ratio (float) to apply to the bounding box size to set to the partitioning space.
  36263. * Ex : 1.01 (default) the partitioning space is 1% bigger than the bounding box
  36264. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36265. */
  36266. get partitioningBBoxRatio(): number;
  36267. set partitioningBBoxRatio(ratio: number);
  36268. /**
  36269. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36270. * Works only for updatable meshes.
  36271. * Doesn't work with multi-materials
  36272. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36273. */
  36274. get mustDepthSortFacets(): boolean;
  36275. set mustDepthSortFacets(sort: boolean);
  36276. /**
  36277. * The location (Vector3) where the facet depth sort must be computed from.
  36278. * By default, the active camera position.
  36279. * Used only when facet depth sort is enabled
  36280. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36281. */
  36282. get facetDepthSortFrom(): Vector3;
  36283. set facetDepthSortFrom(location: Vector3);
  36284. /**
  36285. * gets a boolean indicating if facetData is enabled
  36286. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36287. */
  36288. get isFacetDataEnabled(): boolean;
  36289. /** @hidden */
  36290. _updateNonUniformScalingState(value: boolean): boolean;
  36291. /**
  36292. * An event triggered when this mesh collides with another one
  36293. */
  36294. onCollideObservable: Observable<AbstractMesh>;
  36295. /** Set a function to call when this mesh collides with another one */
  36296. set onCollide(callback: () => void);
  36297. /**
  36298. * An event triggered when the collision's position changes
  36299. */
  36300. onCollisionPositionChangeObservable: Observable<Vector3>;
  36301. /** Set a function to call when the collision's position changes */
  36302. set onCollisionPositionChange(callback: () => void);
  36303. /**
  36304. * An event triggered when material is changed
  36305. */
  36306. onMaterialChangedObservable: Observable<AbstractMesh>;
  36307. /**
  36308. * Gets or sets the orientation for POV movement & rotation
  36309. */
  36310. definedFacingForward: boolean;
  36311. /** @hidden */
  36312. _occlusionQuery: Nullable<WebGLQuery>;
  36313. /** @hidden */
  36314. _renderingGroup: Nullable<RenderingGroup>;
  36315. /**
  36316. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36317. */
  36318. get visibility(): number;
  36319. /**
  36320. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36321. */
  36322. set visibility(value: number);
  36323. /** Gets or sets the alpha index used to sort transparent meshes
  36324. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36325. */
  36326. alphaIndex: number;
  36327. /**
  36328. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36329. */
  36330. isVisible: boolean;
  36331. /**
  36332. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36333. */
  36334. isPickable: boolean;
  36335. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36336. showSubMeshesBoundingBox: boolean;
  36337. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36338. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36339. */
  36340. isBlocker: boolean;
  36341. /**
  36342. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36343. */
  36344. enablePointerMoveEvents: boolean;
  36345. private _renderingGroupId;
  36346. /**
  36347. * Specifies the rendering group id for this mesh (0 by default)
  36348. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36349. */
  36350. get renderingGroupId(): number;
  36351. set renderingGroupId(value: number);
  36352. private _material;
  36353. /** Gets or sets current material */
  36354. get material(): Nullable<Material>;
  36355. set material(value: Nullable<Material>);
  36356. /**
  36357. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36358. * @see https://doc.babylonjs.com/babylon101/shadows
  36359. */
  36360. get receiveShadows(): boolean;
  36361. set receiveShadows(value: boolean);
  36362. /** Defines color to use when rendering outline */
  36363. outlineColor: Color3;
  36364. /** Define width to use when rendering outline */
  36365. outlineWidth: number;
  36366. /** Defines color to use when rendering overlay */
  36367. overlayColor: Color3;
  36368. /** Defines alpha to use when rendering overlay */
  36369. overlayAlpha: number;
  36370. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36371. get hasVertexAlpha(): boolean;
  36372. set hasVertexAlpha(value: boolean);
  36373. /** 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) */
  36374. get useVertexColors(): boolean;
  36375. set useVertexColors(value: boolean);
  36376. /**
  36377. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36378. */
  36379. get computeBonesUsingShaders(): boolean;
  36380. set computeBonesUsingShaders(value: boolean);
  36381. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36382. get numBoneInfluencers(): number;
  36383. set numBoneInfluencers(value: number);
  36384. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36385. get applyFog(): boolean;
  36386. set applyFog(value: boolean);
  36387. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36388. useOctreeForRenderingSelection: boolean;
  36389. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36390. useOctreeForPicking: boolean;
  36391. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36392. useOctreeForCollisions: boolean;
  36393. /**
  36394. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36395. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36396. */
  36397. get layerMask(): number;
  36398. set layerMask(value: number);
  36399. /**
  36400. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36401. */
  36402. alwaysSelectAsActiveMesh: boolean;
  36403. /**
  36404. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36405. */
  36406. doNotSyncBoundingInfo: boolean;
  36407. /**
  36408. * Gets or sets the current action manager
  36409. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36410. */
  36411. actionManager: Nullable<AbstractActionManager>;
  36412. private _meshCollisionData;
  36413. /**
  36414. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36415. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36416. */
  36417. ellipsoid: Vector3;
  36418. /**
  36419. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36420. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36421. */
  36422. ellipsoidOffset: Vector3;
  36423. /**
  36424. * Gets or sets a collision mask used to mask collisions (default is -1).
  36425. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36426. */
  36427. get collisionMask(): number;
  36428. set collisionMask(mask: number);
  36429. /**
  36430. * Gets or sets a collision response flag (default is true).
  36431. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36432. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36433. * to respond to the collision.
  36434. */
  36435. get collisionResponse(): boolean;
  36436. set collisionResponse(response: boolean);
  36437. /**
  36438. * Gets or sets the current collision group mask (-1 by default).
  36439. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36440. */
  36441. get collisionGroup(): number;
  36442. set collisionGroup(mask: number);
  36443. /**
  36444. * Gets or sets current surrounding meshes (null by default).
  36445. *
  36446. * By default collision detection is tested against every mesh in the scene.
  36447. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36448. * meshes will be tested for the collision.
  36449. *
  36450. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36451. */
  36452. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36453. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36454. /**
  36455. * Defines edge width used when edgesRenderer is enabled
  36456. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36457. */
  36458. edgesWidth: number;
  36459. /**
  36460. * Defines edge color used when edgesRenderer is enabled
  36461. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36462. */
  36463. edgesColor: Color4;
  36464. /** @hidden */
  36465. _edgesRenderer: Nullable<IEdgesRenderer>;
  36466. /** @hidden */
  36467. _masterMesh: Nullable<AbstractMesh>;
  36468. /** @hidden */
  36469. _boundingInfo: Nullable<BoundingInfo>;
  36470. /** @hidden */
  36471. _renderId: number;
  36472. /**
  36473. * Gets or sets the list of subMeshes
  36474. * @see https://doc.babylonjs.com/how_to/multi_materials
  36475. */
  36476. subMeshes: SubMesh[];
  36477. /** @hidden */
  36478. _intersectionsInProgress: AbstractMesh[];
  36479. /** @hidden */
  36480. _unIndexed: boolean;
  36481. /** @hidden */
  36482. _lightSources: Light[];
  36483. /** Gets the list of lights affecting that mesh */
  36484. get lightSources(): Light[];
  36485. /** @hidden */
  36486. get _positions(): Nullable<Vector3[]>;
  36487. /** @hidden */
  36488. _waitingData: {
  36489. lods: Nullable<any>;
  36490. actions: Nullable<any>;
  36491. freezeWorldMatrix: Nullable<boolean>;
  36492. };
  36493. /** @hidden */
  36494. _bonesTransformMatrices: Nullable<Float32Array>;
  36495. /** @hidden */
  36496. _transformMatrixTexture: Nullable<RawTexture>;
  36497. /**
  36498. * Gets or sets a skeleton to apply skinning transformations
  36499. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36500. */
  36501. set skeleton(value: Nullable<Skeleton>);
  36502. get skeleton(): Nullable<Skeleton>;
  36503. /**
  36504. * An event triggered when the mesh is rebuilt.
  36505. */
  36506. onRebuildObservable: Observable<AbstractMesh>;
  36507. /**
  36508. * The current mesh uniform buffer.
  36509. * @hidden Internal use only.
  36510. */
  36511. _uniformBuffer: UniformBuffer;
  36512. /**
  36513. * Creates a new AbstractMesh
  36514. * @param name defines the name of the mesh
  36515. * @param scene defines the hosting scene
  36516. */
  36517. constructor(name: string, scene?: Nullable<Scene>);
  36518. protected _buildUniformLayout(): void;
  36519. /**
  36520. * Transfer the mesh values to its UBO.
  36521. * @param world The world matrix associated with the mesh
  36522. */
  36523. transferToEffect(world: Matrix): void;
  36524. /**
  36525. * Gets the mesh uniform buffer.
  36526. * @return the uniform buffer of the mesh.
  36527. */
  36528. getMeshUniformBuffer(): UniformBuffer;
  36529. /**
  36530. * Returns the string "AbstractMesh"
  36531. * @returns "AbstractMesh"
  36532. */
  36533. getClassName(): string;
  36534. /**
  36535. * Gets a string representation of the current mesh
  36536. * @param fullDetails defines a boolean indicating if full details must be included
  36537. * @returns a string representation of the current mesh
  36538. */
  36539. toString(fullDetails?: boolean): string;
  36540. /**
  36541. * @hidden
  36542. */
  36543. protected _getEffectiveParent(): Nullable<Node>;
  36544. /** @hidden */
  36545. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36546. /** @hidden */
  36547. _rebuild(): void;
  36548. /** @hidden */
  36549. _resyncLightSources(): void;
  36550. /** @hidden */
  36551. _resyncLightSource(light: Light): void;
  36552. /** @hidden */
  36553. _unBindEffect(): void;
  36554. /** @hidden */
  36555. _removeLightSource(light: Light, dispose: boolean): void;
  36556. private _markSubMeshesAsDirty;
  36557. /** @hidden */
  36558. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36559. /** @hidden */
  36560. _markSubMeshesAsAttributesDirty(): void;
  36561. /** @hidden */
  36562. _markSubMeshesAsMiscDirty(): void;
  36563. /**
  36564. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36565. */
  36566. get scaling(): Vector3;
  36567. set scaling(newScaling: Vector3);
  36568. /**
  36569. * Returns true if the mesh is blocked. Implemented by child classes
  36570. */
  36571. get isBlocked(): boolean;
  36572. /**
  36573. * Returns the mesh itself by default. Implemented by child classes
  36574. * @param camera defines the camera to use to pick the right LOD level
  36575. * @returns the currentAbstractMesh
  36576. */
  36577. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36578. /**
  36579. * Returns 0 by default. Implemented by child classes
  36580. * @returns an integer
  36581. */
  36582. getTotalVertices(): number;
  36583. /**
  36584. * Returns a positive integer : the total number of indices in this mesh geometry.
  36585. * @returns the number of indices or zero if the mesh has no geometry.
  36586. */
  36587. getTotalIndices(): number;
  36588. /**
  36589. * Returns null by default. Implemented by child classes
  36590. * @returns null
  36591. */
  36592. getIndices(): Nullable<IndicesArray>;
  36593. /**
  36594. * Returns the array of the requested vertex data kind. Implemented by child classes
  36595. * @param kind defines the vertex data kind to use
  36596. * @returns null
  36597. */
  36598. getVerticesData(kind: string): Nullable<FloatArray>;
  36599. /**
  36600. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36601. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36602. * Note that a new underlying VertexBuffer object is created each call.
  36603. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36604. * @param kind defines vertex data kind:
  36605. * * VertexBuffer.PositionKind
  36606. * * VertexBuffer.UVKind
  36607. * * VertexBuffer.UV2Kind
  36608. * * VertexBuffer.UV3Kind
  36609. * * VertexBuffer.UV4Kind
  36610. * * VertexBuffer.UV5Kind
  36611. * * VertexBuffer.UV6Kind
  36612. * * VertexBuffer.ColorKind
  36613. * * VertexBuffer.MatricesIndicesKind
  36614. * * VertexBuffer.MatricesIndicesExtraKind
  36615. * * VertexBuffer.MatricesWeightsKind
  36616. * * VertexBuffer.MatricesWeightsExtraKind
  36617. * @param data defines the data source
  36618. * @param updatable defines if the data must be flagged as updatable (or static)
  36619. * @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
  36620. * @returns the current mesh
  36621. */
  36622. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36623. /**
  36624. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36625. * If the mesh has no geometry, it is simply returned as it is.
  36626. * @param kind defines vertex data kind:
  36627. * * VertexBuffer.PositionKind
  36628. * * VertexBuffer.UVKind
  36629. * * VertexBuffer.UV2Kind
  36630. * * VertexBuffer.UV3Kind
  36631. * * VertexBuffer.UV4Kind
  36632. * * VertexBuffer.UV5Kind
  36633. * * VertexBuffer.UV6Kind
  36634. * * VertexBuffer.ColorKind
  36635. * * VertexBuffer.MatricesIndicesKind
  36636. * * VertexBuffer.MatricesIndicesExtraKind
  36637. * * VertexBuffer.MatricesWeightsKind
  36638. * * VertexBuffer.MatricesWeightsExtraKind
  36639. * @param data defines the data source
  36640. * @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
  36641. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36642. * @returns the current mesh
  36643. */
  36644. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36645. /**
  36646. * Sets the mesh indices,
  36647. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36648. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36649. * @param totalVertices Defines the total number of vertices
  36650. * @returns the current mesh
  36651. */
  36652. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36653. /**
  36654. * Gets a boolean indicating if specific vertex data is present
  36655. * @param kind defines the vertex data kind to use
  36656. * @returns true is data kind is present
  36657. */
  36658. isVerticesDataPresent(kind: string): boolean;
  36659. /**
  36660. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36661. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36662. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36663. * @returns a BoundingInfo
  36664. */
  36665. getBoundingInfo(): BoundingInfo;
  36666. /**
  36667. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36668. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36669. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36670. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36671. * @returns the current mesh
  36672. */
  36673. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36674. /**
  36675. * Overwrite the current bounding info
  36676. * @param boundingInfo defines the new bounding info
  36677. * @returns the current mesh
  36678. */
  36679. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36680. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36681. get useBones(): boolean;
  36682. /** @hidden */
  36683. _preActivate(): void;
  36684. /** @hidden */
  36685. _preActivateForIntermediateRendering(renderId: number): void;
  36686. /** @hidden */
  36687. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36688. /** @hidden */
  36689. _postActivate(): void;
  36690. /** @hidden */
  36691. _freeze(): void;
  36692. /** @hidden */
  36693. _unFreeze(): void;
  36694. /**
  36695. * Gets the current world matrix
  36696. * @returns a Matrix
  36697. */
  36698. getWorldMatrix(): Matrix;
  36699. /** @hidden */
  36700. _getWorldMatrixDeterminant(): number;
  36701. /**
  36702. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36703. */
  36704. get isAnInstance(): boolean;
  36705. /**
  36706. * Gets a boolean indicating if this mesh has instances
  36707. */
  36708. get hasInstances(): boolean;
  36709. /**
  36710. * Gets a boolean indicating if this mesh has thin instances
  36711. */
  36712. get hasThinInstances(): boolean;
  36713. /**
  36714. * Perform relative position change from the point of view of behind the front of the mesh.
  36715. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36716. * Supports definition of mesh facing forward or backward
  36717. * @param amountRight defines the distance on the right axis
  36718. * @param amountUp defines the distance on the up axis
  36719. * @param amountForward defines the distance on the forward axis
  36720. * @returns the current mesh
  36721. */
  36722. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36723. /**
  36724. * Calculate relative position change from the point of view of behind the front of the mesh.
  36725. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36726. * Supports definition of mesh facing forward or backward
  36727. * @param amountRight defines the distance on the right axis
  36728. * @param amountUp defines the distance on the up axis
  36729. * @param amountForward defines the distance on the forward axis
  36730. * @returns the new displacement vector
  36731. */
  36732. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36733. /**
  36734. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36735. * Supports definition of mesh facing forward or backward
  36736. * @param flipBack defines the flip
  36737. * @param twirlClockwise defines the twirl
  36738. * @param tiltRight defines the tilt
  36739. * @returns the current mesh
  36740. */
  36741. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36742. /**
  36743. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36744. * Supports definition of mesh facing forward or backward.
  36745. * @param flipBack defines the flip
  36746. * @param twirlClockwise defines the twirl
  36747. * @param tiltRight defines the tilt
  36748. * @returns the new rotation vector
  36749. */
  36750. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36751. /**
  36752. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36753. * This means the mesh underlying bounding box and sphere are recomputed.
  36754. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36755. * @returns the current mesh
  36756. */
  36757. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36758. /** @hidden */
  36759. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36760. /** @hidden */
  36761. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36762. /** @hidden */
  36763. _updateBoundingInfo(): AbstractMesh;
  36764. /** @hidden */
  36765. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36766. /** @hidden */
  36767. protected _afterComputeWorldMatrix(): void;
  36768. /** @hidden */
  36769. get _effectiveMesh(): AbstractMesh;
  36770. /**
  36771. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36772. * A mesh is in the frustum if its bounding box intersects the frustum
  36773. * @param frustumPlanes defines the frustum to test
  36774. * @returns true if the mesh is in the frustum planes
  36775. */
  36776. isInFrustum(frustumPlanes: Plane[]): boolean;
  36777. /**
  36778. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36779. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36780. * @param frustumPlanes defines the frustum to test
  36781. * @returns true if the mesh is completely in the frustum planes
  36782. */
  36783. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36784. /**
  36785. * True if the mesh intersects another mesh or a SolidParticle object
  36786. * @param mesh defines a target mesh or SolidParticle to test
  36787. * @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)
  36788. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36789. * @returns true if there is an intersection
  36790. */
  36791. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36792. /**
  36793. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36794. * @param point defines the point to test
  36795. * @returns true if there is an intersection
  36796. */
  36797. intersectsPoint(point: Vector3): boolean;
  36798. /**
  36799. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36800. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36801. */
  36802. get checkCollisions(): boolean;
  36803. set checkCollisions(collisionEnabled: boolean);
  36804. /**
  36805. * Gets Collider object used to compute collisions (not physics)
  36806. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36807. */
  36808. get collider(): Nullable<Collider>;
  36809. /**
  36810. * Move the mesh using collision engine
  36811. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36812. * @param displacement defines the requested displacement vector
  36813. * @returns the current mesh
  36814. */
  36815. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36816. private _onCollisionPositionChange;
  36817. /** @hidden */
  36818. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36819. /** @hidden */
  36820. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36821. /** @hidden */
  36822. _checkCollision(collider: Collider): AbstractMesh;
  36823. /** @hidden */
  36824. _generatePointsArray(): boolean;
  36825. /**
  36826. * Checks if the passed Ray intersects with the mesh
  36827. * @param ray defines the ray to use
  36828. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36829. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36830. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36831. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36832. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36833. * @returns the picking info
  36834. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36835. */
  36836. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36837. /**
  36838. * Clones the current mesh
  36839. * @param name defines the mesh name
  36840. * @param newParent defines the new mesh parent
  36841. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36842. * @returns the new mesh
  36843. */
  36844. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36845. /**
  36846. * Disposes all the submeshes of the current meshnp
  36847. * @returns the current mesh
  36848. */
  36849. releaseSubMeshes(): AbstractMesh;
  36850. /**
  36851. * Releases resources associated with this abstract mesh.
  36852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36854. */
  36855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36856. /**
  36857. * Adds the passed mesh as a child to the current mesh
  36858. * @param mesh defines the child mesh
  36859. * @returns the current mesh
  36860. */
  36861. addChild(mesh: AbstractMesh): AbstractMesh;
  36862. /**
  36863. * Removes the passed mesh from the current mesh children list
  36864. * @param mesh defines the child mesh
  36865. * @returns the current mesh
  36866. */
  36867. removeChild(mesh: AbstractMesh): AbstractMesh;
  36868. /** @hidden */
  36869. private _initFacetData;
  36870. /**
  36871. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36872. * This method can be called within the render loop.
  36873. * 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
  36874. * @returns the current mesh
  36875. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36876. */
  36877. updateFacetData(): AbstractMesh;
  36878. /**
  36879. * Returns the facetLocalNormals array.
  36880. * The normals are expressed in the mesh local spac
  36881. * @returns an array of Vector3
  36882. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36883. */
  36884. getFacetLocalNormals(): Vector3[];
  36885. /**
  36886. * Returns the facetLocalPositions array.
  36887. * The facet positions are expressed in the mesh local space
  36888. * @returns an array of Vector3
  36889. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36890. */
  36891. getFacetLocalPositions(): Vector3[];
  36892. /**
  36893. * Returns the facetLocalPartitioning array
  36894. * @returns an array of array of numbers
  36895. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36896. */
  36897. getFacetLocalPartitioning(): number[][];
  36898. /**
  36899. * Returns the i-th facet position in the world system.
  36900. * This method allocates a new Vector3 per call
  36901. * @param i defines the facet index
  36902. * @returns a new Vector3
  36903. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36904. */
  36905. getFacetPosition(i: number): Vector3;
  36906. /**
  36907. * Sets the reference Vector3 with the i-th facet position in the world system
  36908. * @param i defines the facet index
  36909. * @param ref defines the target vector
  36910. * @returns the current mesh
  36911. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36912. */
  36913. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36914. /**
  36915. * Returns the i-th facet normal in the world system.
  36916. * This method allocates a new Vector3 per call
  36917. * @param i defines the facet index
  36918. * @returns a new Vector3
  36919. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36920. */
  36921. getFacetNormal(i: number): Vector3;
  36922. /**
  36923. * Sets the reference Vector3 with the i-th facet normal in the world system
  36924. * @param i defines the facet index
  36925. * @param ref defines the target vector
  36926. * @returns the current mesh
  36927. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36928. */
  36929. getFacetNormalToRef(i: number, ref: Vector3): this;
  36930. /**
  36931. * 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)
  36932. * @param x defines x coordinate
  36933. * @param y defines y coordinate
  36934. * @param z defines z coordinate
  36935. * @returns the array of facet indexes
  36936. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36937. */
  36938. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36939. /**
  36940. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36941. * @param projected sets as the (x,y,z) world projection on the facet
  36942. * @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
  36943. * @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
  36944. * @param x defines x coordinate
  36945. * @param y defines y coordinate
  36946. * @param z defines z coordinate
  36947. * @returns the face index if found (or null instead)
  36948. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36949. */
  36950. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36951. /**
  36952. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36953. * @param projected sets as the (x,y,z) local projection on the facet
  36954. * @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
  36955. * @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
  36956. * @param x defines x coordinate
  36957. * @param y defines y coordinate
  36958. * @param z defines z coordinate
  36959. * @returns the face index if found (or null instead)
  36960. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36961. */
  36962. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36963. /**
  36964. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36965. * @returns the parameters
  36966. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36967. */
  36968. getFacetDataParameters(): any;
  36969. /**
  36970. * Disables the feature FacetData and frees the related memory
  36971. * @returns the current mesh
  36972. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36973. */
  36974. disableFacetData(): AbstractMesh;
  36975. /**
  36976. * Updates the AbstractMesh indices array
  36977. * @param indices defines the data source
  36978. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36979. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  36980. * @returns the current mesh
  36981. */
  36982. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36983. /**
  36984. * Creates new normals data for the mesh
  36985. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36986. * @returns the current mesh
  36987. */
  36988. createNormals(updatable: boolean): AbstractMesh;
  36989. /**
  36990. * Align the mesh with a normal
  36991. * @param normal defines the normal to use
  36992. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36993. * @returns the current mesh
  36994. */
  36995. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36996. /** @hidden */
  36997. _checkOcclusionQuery(): boolean;
  36998. /**
  36999. * Disables the mesh edge rendering mode
  37000. * @returns the currentAbstractMesh
  37001. */
  37002. disableEdgesRendering(): AbstractMesh;
  37003. /**
  37004. * Enables the edge rendering mode on the mesh.
  37005. * This mode makes the mesh edges visible
  37006. * @param epsilon defines the maximal distance between two angles to detect a face
  37007. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37008. * @param options options to the edge renderer
  37009. * @returns the currentAbstractMesh
  37010. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37011. */
  37012. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37013. /**
  37014. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37015. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37016. */
  37017. getConnectedParticleSystems(): IParticleSystem[];
  37018. }
  37019. }
  37020. declare module BABYLON {
  37021. /**
  37022. * Interface used to define ActionEvent
  37023. */
  37024. export interface IActionEvent {
  37025. /** The mesh or sprite that triggered the action */
  37026. source: any;
  37027. /** The X mouse cursor position at the time of the event */
  37028. pointerX: number;
  37029. /** The Y mouse cursor position at the time of the event */
  37030. pointerY: number;
  37031. /** The mesh that is currently pointed at (can be null) */
  37032. meshUnderPointer: Nullable<AbstractMesh>;
  37033. /** the original (browser) event that triggered the ActionEvent */
  37034. sourceEvent?: any;
  37035. /** additional data for the event */
  37036. additionalData?: any;
  37037. }
  37038. /**
  37039. * ActionEvent is the event being sent when an action is triggered.
  37040. */
  37041. export class ActionEvent implements IActionEvent {
  37042. /** The mesh or sprite that triggered the action */
  37043. source: any;
  37044. /** The X mouse cursor position at the time of the event */
  37045. pointerX: number;
  37046. /** The Y mouse cursor position at the time of the event */
  37047. pointerY: number;
  37048. /** The mesh that is currently pointed at (can be null) */
  37049. meshUnderPointer: Nullable<AbstractMesh>;
  37050. /** the original (browser) event that triggered the ActionEvent */
  37051. sourceEvent?: any;
  37052. /** additional data for the event */
  37053. additionalData?: any;
  37054. /**
  37055. * Creates a new ActionEvent
  37056. * @param source The mesh or sprite that triggered the action
  37057. * @param pointerX The X mouse cursor position at the time of the event
  37058. * @param pointerY The Y mouse cursor position at the time of the event
  37059. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37060. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37061. * @param additionalData additional data for the event
  37062. */
  37063. constructor(
  37064. /** The mesh or sprite that triggered the action */
  37065. source: any,
  37066. /** The X mouse cursor position at the time of the event */
  37067. pointerX: number,
  37068. /** The Y mouse cursor position at the time of the event */
  37069. pointerY: number,
  37070. /** The mesh that is currently pointed at (can be null) */
  37071. meshUnderPointer: Nullable<AbstractMesh>,
  37072. /** the original (browser) event that triggered the ActionEvent */
  37073. sourceEvent?: any,
  37074. /** additional data for the event */
  37075. additionalData?: any);
  37076. /**
  37077. * Helper function to auto-create an ActionEvent from a source mesh.
  37078. * @param source The source mesh that triggered the event
  37079. * @param evt The original (browser) event
  37080. * @param additionalData additional data for the event
  37081. * @returns the new ActionEvent
  37082. */
  37083. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37084. /**
  37085. * Helper function to auto-create an ActionEvent from a source sprite
  37086. * @param source The source sprite that triggered the event
  37087. * @param scene Scene associated with the sprite
  37088. * @param evt The original (browser) event
  37089. * @param additionalData additional data for the event
  37090. * @returns the new ActionEvent
  37091. */
  37092. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37093. /**
  37094. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37095. * @param scene the scene where the event occurred
  37096. * @param evt The original (browser) event
  37097. * @returns the new ActionEvent
  37098. */
  37099. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37100. /**
  37101. * Helper function to auto-create an ActionEvent from a primitive
  37102. * @param prim defines the target primitive
  37103. * @param pointerPos defines the pointer position
  37104. * @param evt The original (browser) event
  37105. * @param additionalData additional data for the event
  37106. * @returns the new ActionEvent
  37107. */
  37108. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37109. }
  37110. }
  37111. declare module BABYLON {
  37112. /**
  37113. * Abstract class used to decouple action Manager from scene and meshes.
  37114. * Do not instantiate.
  37115. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37116. */
  37117. export abstract class AbstractActionManager implements IDisposable {
  37118. /** Gets the list of active triggers */
  37119. static Triggers: {
  37120. [key: string]: number;
  37121. };
  37122. /** Gets the cursor to use when hovering items */
  37123. hoverCursor: string;
  37124. /** Gets the list of actions */
  37125. actions: IAction[];
  37126. /**
  37127. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37128. */
  37129. isRecursive: boolean;
  37130. /**
  37131. * Releases all associated resources
  37132. */
  37133. abstract dispose(): void;
  37134. /**
  37135. * Does this action manager has pointer triggers
  37136. */
  37137. abstract get hasPointerTriggers(): boolean;
  37138. /**
  37139. * Does this action manager has pick triggers
  37140. */
  37141. abstract get hasPickTriggers(): boolean;
  37142. /**
  37143. * Process a specific trigger
  37144. * @param trigger defines the trigger to process
  37145. * @param evt defines the event details to be processed
  37146. */
  37147. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37148. /**
  37149. * Does this action manager handles actions of any of the given triggers
  37150. * @param triggers defines the triggers to be tested
  37151. * @return a boolean indicating whether one (or more) of the triggers is handled
  37152. */
  37153. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37154. /**
  37155. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37156. * speed.
  37157. * @param triggerA defines the trigger to be tested
  37158. * @param triggerB defines the trigger to be tested
  37159. * @return a boolean indicating whether one (or more) of the triggers is handled
  37160. */
  37161. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37162. /**
  37163. * Does this action manager handles actions of a given trigger
  37164. * @param trigger defines the trigger to be tested
  37165. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37166. * @return whether the trigger is handled
  37167. */
  37168. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37169. /**
  37170. * Serialize this manager to a JSON object
  37171. * @param name defines the property name to store this manager
  37172. * @returns a JSON representation of this manager
  37173. */
  37174. abstract serialize(name: string): any;
  37175. /**
  37176. * Registers an action to this action manager
  37177. * @param action defines the action to be registered
  37178. * @return the action amended (prepared) after registration
  37179. */
  37180. abstract registerAction(action: IAction): Nullable<IAction>;
  37181. /**
  37182. * Unregisters an action to this action manager
  37183. * @param action defines the action to be unregistered
  37184. * @return a boolean indicating whether the action has been unregistered
  37185. */
  37186. abstract unregisterAction(action: IAction): Boolean;
  37187. /**
  37188. * Does exist one action manager with at least one trigger
  37189. **/
  37190. static get HasTriggers(): boolean;
  37191. /**
  37192. * Does exist one action manager with at least one pick trigger
  37193. **/
  37194. static get HasPickTriggers(): boolean;
  37195. /**
  37196. * Does exist one action manager that handles actions of a given trigger
  37197. * @param trigger defines the trigger to be tested
  37198. * @return a boolean indicating whether the trigger is handled by at least one action manager
  37199. **/
  37200. static HasSpecificTrigger(trigger: number): boolean;
  37201. }
  37202. }
  37203. declare module BABYLON {
  37204. /**
  37205. * Defines how a node can be built from a string name.
  37206. */
  37207. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37208. /**
  37209. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37210. */
  37211. export class Node implements IBehaviorAware<Node> {
  37212. /** @hidden */
  37213. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37214. private static _NodeConstructors;
  37215. /**
  37216. * Add a new node constructor
  37217. * @param type defines the type name of the node to construct
  37218. * @param constructorFunc defines the constructor function
  37219. */
  37220. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37221. /**
  37222. * Returns a node constructor based on type name
  37223. * @param type defines the type name
  37224. * @param name defines the new node name
  37225. * @param scene defines the hosting scene
  37226. * @param options defines optional options to transmit to constructors
  37227. * @returns the new constructor or null
  37228. */
  37229. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37230. /**
  37231. * Gets or sets the name of the node
  37232. */
  37233. name: string;
  37234. /**
  37235. * Gets or sets the id of the node
  37236. */
  37237. id: string;
  37238. /**
  37239. * Gets or sets the unique id of the node
  37240. */
  37241. uniqueId: number;
  37242. /**
  37243. * Gets or sets a string used to store user defined state for the node
  37244. */
  37245. state: string;
  37246. /**
  37247. * Gets or sets an object used to store user defined information for the node
  37248. */
  37249. metadata: any;
  37250. /**
  37251. * For internal use only. Please do not use.
  37252. */
  37253. reservedDataStore: any;
  37254. /**
  37255. * List of inspectable custom properties (used by the Inspector)
  37256. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37257. */
  37258. inspectableCustomProperties: IInspectable[];
  37259. private _doNotSerialize;
  37260. /**
  37261. * Gets or sets a boolean used to define if the node must be serialized
  37262. */
  37263. get doNotSerialize(): boolean;
  37264. set doNotSerialize(value: boolean);
  37265. /** @hidden */
  37266. _isDisposed: boolean;
  37267. /**
  37268. * Gets a list of Animations associated with the node
  37269. */
  37270. animations: Animation[];
  37271. protected _ranges: {
  37272. [name: string]: Nullable<AnimationRange>;
  37273. };
  37274. /**
  37275. * Callback raised when the node is ready to be used
  37276. */
  37277. onReady: Nullable<(node: Node) => void>;
  37278. private _isEnabled;
  37279. private _isParentEnabled;
  37280. private _isReady;
  37281. /** @hidden */
  37282. _currentRenderId: number;
  37283. private _parentUpdateId;
  37284. /** @hidden */
  37285. _childUpdateId: number;
  37286. /** @hidden */
  37287. _waitingParentId: Nullable<string>;
  37288. /** @hidden */
  37289. _scene: Scene;
  37290. /** @hidden */
  37291. _cache: any;
  37292. private _parentNode;
  37293. private _children;
  37294. /** @hidden */
  37295. _worldMatrix: Matrix;
  37296. /** @hidden */
  37297. _worldMatrixDeterminant: number;
  37298. /** @hidden */
  37299. _worldMatrixDeterminantIsDirty: boolean;
  37300. /** @hidden */
  37301. private _sceneRootNodesIndex;
  37302. /**
  37303. * Gets a boolean indicating if the node has been disposed
  37304. * @returns true if the node was disposed
  37305. */
  37306. isDisposed(): boolean;
  37307. /**
  37308. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37309. * @see https://doc.babylonjs.com/how_to/parenting
  37310. */
  37311. set parent(parent: Nullable<Node>);
  37312. get parent(): Nullable<Node>;
  37313. /** @hidden */
  37314. _addToSceneRootNodes(): void;
  37315. /** @hidden */
  37316. _removeFromSceneRootNodes(): void;
  37317. private _animationPropertiesOverride;
  37318. /**
  37319. * Gets or sets the animation properties override
  37320. */
  37321. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37322. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37323. /**
  37324. * Gets a string identifying the name of the class
  37325. * @returns "Node" string
  37326. */
  37327. getClassName(): string;
  37328. /** @hidden */
  37329. readonly _isNode: boolean;
  37330. /**
  37331. * An event triggered when the mesh is disposed
  37332. */
  37333. onDisposeObservable: Observable<Node>;
  37334. private _onDisposeObserver;
  37335. /**
  37336. * Sets a callback that will be raised when the node will be disposed
  37337. */
  37338. set onDispose(callback: () => void);
  37339. /**
  37340. * Creates a new Node
  37341. * @param name the name and id to be given to this node
  37342. * @param scene the scene this node will be added to
  37343. */
  37344. constructor(name: string, scene?: Nullable<Scene>);
  37345. /**
  37346. * Gets the scene of the node
  37347. * @returns a scene
  37348. */
  37349. getScene(): Scene;
  37350. /**
  37351. * Gets the engine of the node
  37352. * @returns a Engine
  37353. */
  37354. getEngine(): Engine;
  37355. private _behaviors;
  37356. /**
  37357. * Attach a behavior to the node
  37358. * @see https://doc.babylonjs.com/features/behaviour
  37359. * @param behavior defines the behavior to attach
  37360. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37361. * @returns the current Node
  37362. */
  37363. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37364. /**
  37365. * Remove an attached behavior
  37366. * @see https://doc.babylonjs.com/features/behaviour
  37367. * @param behavior defines the behavior to attach
  37368. * @returns the current Node
  37369. */
  37370. removeBehavior(behavior: Behavior<Node>): Node;
  37371. /**
  37372. * Gets the list of attached behaviors
  37373. * @see https://doc.babylonjs.com/features/behaviour
  37374. */
  37375. get behaviors(): Behavior<Node>[];
  37376. /**
  37377. * Gets an attached behavior by name
  37378. * @param name defines the name of the behavior to look for
  37379. * @see https://doc.babylonjs.com/features/behaviour
  37380. * @returns null if behavior was not found else the requested behavior
  37381. */
  37382. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37383. /**
  37384. * Returns the latest update of the World matrix
  37385. * @returns a Matrix
  37386. */
  37387. getWorldMatrix(): Matrix;
  37388. /** @hidden */
  37389. _getWorldMatrixDeterminant(): number;
  37390. /**
  37391. * Returns directly the latest state of the mesh World matrix.
  37392. * A Matrix is returned.
  37393. */
  37394. get worldMatrixFromCache(): Matrix;
  37395. /** @hidden */
  37396. _initCache(): void;
  37397. /** @hidden */
  37398. updateCache(force?: boolean): void;
  37399. /** @hidden */
  37400. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37401. /** @hidden */
  37402. _updateCache(ignoreParentClass?: boolean): void;
  37403. /** @hidden */
  37404. _isSynchronized(): boolean;
  37405. /** @hidden */
  37406. _markSyncedWithParent(): void;
  37407. /** @hidden */
  37408. isSynchronizedWithParent(): boolean;
  37409. /** @hidden */
  37410. isSynchronized(): boolean;
  37411. /**
  37412. * Is this node ready to be used/rendered
  37413. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37414. * @return true if the node is ready
  37415. */
  37416. isReady(completeCheck?: boolean): boolean;
  37417. /**
  37418. * Is this node enabled?
  37419. * 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
  37420. * @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
  37421. * @return whether this node (and its parent) is enabled
  37422. */
  37423. isEnabled(checkAncestors?: boolean): boolean;
  37424. /** @hidden */
  37425. protected _syncParentEnabledState(): void;
  37426. /**
  37427. * Set the enabled state of this node
  37428. * @param value defines the new enabled state
  37429. */
  37430. setEnabled(value: boolean): void;
  37431. /**
  37432. * Is this node a descendant of the given node?
  37433. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37434. * @param ancestor defines the parent node to inspect
  37435. * @returns a boolean indicating if this node is a descendant of the given node
  37436. */
  37437. isDescendantOf(ancestor: Node): boolean;
  37438. /** @hidden */
  37439. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37440. /**
  37441. * Will return all nodes that have this node as ascendant
  37442. * @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
  37443. * @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
  37444. * @return all children nodes of all types
  37445. */
  37446. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37447. /**
  37448. * Get all child-meshes of this node
  37449. * @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 (Default: false)
  37450. * @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
  37451. * @returns an array of AbstractMesh
  37452. */
  37453. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37454. /**
  37455. * Get all direct children of this node
  37456. * @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
  37457. * @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 (Default: true)
  37458. * @returns an array of Node
  37459. */
  37460. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37461. /** @hidden */
  37462. _setReady(state: boolean): void;
  37463. /**
  37464. * Get an animation by name
  37465. * @param name defines the name of the animation to look for
  37466. * @returns null if not found else the requested animation
  37467. */
  37468. getAnimationByName(name: string): Nullable<Animation>;
  37469. /**
  37470. * Creates an animation range for this node
  37471. * @param name defines the name of the range
  37472. * @param from defines the starting key
  37473. * @param to defines the end key
  37474. */
  37475. createAnimationRange(name: string, from: number, to: number): void;
  37476. /**
  37477. * Delete a specific animation range
  37478. * @param name defines the name of the range to delete
  37479. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37480. */
  37481. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37482. /**
  37483. * Get an animation range by name
  37484. * @param name defines the name of the animation range to look for
  37485. * @returns null if not found else the requested animation range
  37486. */
  37487. getAnimationRange(name: string): Nullable<AnimationRange>;
  37488. /**
  37489. * Gets the list of all animation ranges defined on this node
  37490. * @returns an array
  37491. */
  37492. getAnimationRanges(): Nullable<AnimationRange>[];
  37493. /**
  37494. * Will start the animation sequence
  37495. * @param name defines the range frames for animation sequence
  37496. * @param loop defines if the animation should loop (false by default)
  37497. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37498. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37499. * @returns the object created for this animation. If range does not exist, it will return null
  37500. */
  37501. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37502. /**
  37503. * Serialize animation ranges into a JSON compatible object
  37504. * @returns serialization object
  37505. */
  37506. serializeAnimationRanges(): any;
  37507. /**
  37508. * Computes the world matrix of the node
  37509. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37510. * @returns the world matrix
  37511. */
  37512. computeWorldMatrix(force?: boolean): Matrix;
  37513. /**
  37514. * Releases resources associated with this node.
  37515. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37516. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37517. */
  37518. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37519. /**
  37520. * Parse animation range data from a serialization object and store them into a given node
  37521. * @param node defines where to store the animation ranges
  37522. * @param parsedNode defines the serialization object to read data from
  37523. * @param scene defines the hosting scene
  37524. */
  37525. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37526. /**
  37527. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37528. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37529. * @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
  37530. * @returns the new bounding vectors
  37531. */
  37532. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37533. min: Vector3;
  37534. max: Vector3;
  37535. };
  37536. }
  37537. }
  37538. declare module BABYLON {
  37539. /**
  37540. * @hidden
  37541. */
  37542. export class _IAnimationState {
  37543. key: number;
  37544. repeatCount: number;
  37545. workValue?: any;
  37546. loopMode?: number;
  37547. offsetValue?: any;
  37548. highLimitValue?: any;
  37549. }
  37550. /**
  37551. * Class used to store any kind of animation
  37552. */
  37553. export class Animation {
  37554. /**Name of the animation */
  37555. name: string;
  37556. /**Property to animate */
  37557. targetProperty: string;
  37558. /**The frames per second of the animation */
  37559. framePerSecond: number;
  37560. /**The data type of the animation */
  37561. dataType: number;
  37562. /**The loop mode of the animation */
  37563. loopMode?: number | undefined;
  37564. /**Specifies if blending should be enabled */
  37565. enableBlending?: boolean | undefined;
  37566. /**
  37567. * Use matrix interpolation instead of using direct key value when animating matrices
  37568. */
  37569. static AllowMatricesInterpolation: boolean;
  37570. /**
  37571. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37572. */
  37573. static AllowMatrixDecomposeForInterpolation: boolean;
  37574. /** Define the Url to load snippets */
  37575. static SnippetUrl: string;
  37576. /** Snippet ID if the animation was created from the snippet server */
  37577. snippetId: string;
  37578. /**
  37579. * Stores the key frames of the animation
  37580. */
  37581. private _keys;
  37582. /**
  37583. * Stores the easing function of the animation
  37584. */
  37585. private _easingFunction;
  37586. /**
  37587. * @hidden Internal use only
  37588. */
  37589. _runtimeAnimations: RuntimeAnimation[];
  37590. /**
  37591. * The set of event that will be linked to this animation
  37592. */
  37593. private _events;
  37594. /**
  37595. * Stores an array of target property paths
  37596. */
  37597. targetPropertyPath: string[];
  37598. /**
  37599. * Stores the blending speed of the animation
  37600. */
  37601. blendingSpeed: number;
  37602. /**
  37603. * Stores the animation ranges for the animation
  37604. */
  37605. private _ranges;
  37606. /**
  37607. * @hidden Internal use
  37608. */
  37609. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37610. /**
  37611. * Sets up an animation
  37612. * @param property The property to animate
  37613. * @param animationType The animation type to apply
  37614. * @param framePerSecond The frames per second of the animation
  37615. * @param easingFunction The easing function used in the animation
  37616. * @returns The created animation
  37617. */
  37618. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37619. /**
  37620. * Create and start an animation on a node
  37621. * @param name defines the name of the global animation that will be run on all nodes
  37622. * @param node defines the root node where the animation will take place
  37623. * @param targetProperty defines property to animate
  37624. * @param framePerSecond defines the number of frame per second yo use
  37625. * @param totalFrame defines the number of frames in total
  37626. * @param from defines the initial value
  37627. * @param to defines the final value
  37628. * @param loopMode defines which loop mode you want to use (off by default)
  37629. * @param easingFunction defines the easing function to use (linear by default)
  37630. * @param onAnimationEnd defines the callback to call when animation end
  37631. * @returns the animatable created for this animation
  37632. */
  37633. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37634. /**
  37635. * Create and start an animation on a node and its descendants
  37636. * @param name defines the name of the global animation that will be run on all nodes
  37637. * @param node defines the root node where the animation will take place
  37638. * @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
  37639. * @param targetProperty defines property to animate
  37640. * @param framePerSecond defines the number of frame per second to use
  37641. * @param totalFrame defines the number of frames in total
  37642. * @param from defines the initial value
  37643. * @param to defines the final value
  37644. * @param loopMode defines which loop mode you want to use (off by default)
  37645. * @param easingFunction defines the easing function to use (linear by default)
  37646. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37647. * @returns the list of animatables created for all nodes
  37648. * @example https://www.babylonjs-playground.com/#MH0VLI
  37649. */
  37650. 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[]>;
  37651. /**
  37652. * Creates a new animation, merges it with the existing animations and starts it
  37653. * @param name Name of the animation
  37654. * @param node Node which contains the scene that begins the animations
  37655. * @param targetProperty Specifies which property to animate
  37656. * @param framePerSecond The frames per second of the animation
  37657. * @param totalFrame The total number of frames
  37658. * @param from The frame at the beginning of the animation
  37659. * @param to The frame at the end of the animation
  37660. * @param loopMode Specifies the loop mode of the animation
  37661. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37662. * @param onAnimationEnd Callback to run once the animation is complete
  37663. * @returns Nullable animation
  37664. */
  37665. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37666. /**
  37667. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37668. * @param sourceAnimation defines the Animation containing keyframes to convert
  37669. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37670. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37671. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37672. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37673. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37674. */
  37675. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37676. /**
  37677. * Transition property of an host to the target Value
  37678. * @param property The property to transition
  37679. * @param targetValue The target Value of the property
  37680. * @param host The object where the property to animate belongs
  37681. * @param scene Scene used to run the animation
  37682. * @param frameRate Framerate (in frame/s) to use
  37683. * @param transition The transition type we want to use
  37684. * @param duration The duration of the animation, in milliseconds
  37685. * @param onAnimationEnd Callback trigger at the end of the animation
  37686. * @returns Nullable animation
  37687. */
  37688. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37689. /**
  37690. * Return the array of runtime animations currently using this animation
  37691. */
  37692. get runtimeAnimations(): RuntimeAnimation[];
  37693. /**
  37694. * Specifies if any of the runtime animations are currently running
  37695. */
  37696. get hasRunningRuntimeAnimations(): boolean;
  37697. /**
  37698. * Initializes the animation
  37699. * @param name Name of the animation
  37700. * @param targetProperty Property to animate
  37701. * @param framePerSecond The frames per second of the animation
  37702. * @param dataType The data type of the animation
  37703. * @param loopMode The loop mode of the animation
  37704. * @param enableBlending Specifies if blending should be enabled
  37705. */
  37706. constructor(
  37707. /**Name of the animation */
  37708. name: string,
  37709. /**Property to animate */
  37710. targetProperty: string,
  37711. /**The frames per second of the animation */
  37712. framePerSecond: number,
  37713. /**The data type of the animation */
  37714. dataType: number,
  37715. /**The loop mode of the animation */
  37716. loopMode?: number | undefined,
  37717. /**Specifies if blending should be enabled */
  37718. enableBlending?: boolean | undefined);
  37719. /**
  37720. * Converts the animation to a string
  37721. * @param fullDetails support for multiple levels of logging within scene loading
  37722. * @returns String form of the animation
  37723. */
  37724. toString(fullDetails?: boolean): string;
  37725. /**
  37726. * Add an event to this animation
  37727. * @param event Event to add
  37728. */
  37729. addEvent(event: AnimationEvent): void;
  37730. /**
  37731. * Remove all events found at the given frame
  37732. * @param frame The frame to remove events from
  37733. */
  37734. removeEvents(frame: number): void;
  37735. /**
  37736. * Retrieves all the events from the animation
  37737. * @returns Events from the animation
  37738. */
  37739. getEvents(): AnimationEvent[];
  37740. /**
  37741. * Creates an animation range
  37742. * @param name Name of the animation range
  37743. * @param from Starting frame of the animation range
  37744. * @param to Ending frame of the animation
  37745. */
  37746. createRange(name: string, from: number, to: number): void;
  37747. /**
  37748. * Deletes an animation range by name
  37749. * @param name Name of the animation range to delete
  37750. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37751. */
  37752. deleteRange(name: string, deleteFrames?: boolean): void;
  37753. /**
  37754. * Gets the animation range by name, or null if not defined
  37755. * @param name Name of the animation range
  37756. * @returns Nullable animation range
  37757. */
  37758. getRange(name: string): Nullable<AnimationRange>;
  37759. /**
  37760. * Gets the key frames from the animation
  37761. * @returns The key frames of the animation
  37762. */
  37763. getKeys(): Array<IAnimationKey>;
  37764. /**
  37765. * Gets the highest frame rate of the animation
  37766. * @returns Highest frame rate of the animation
  37767. */
  37768. getHighestFrame(): number;
  37769. /**
  37770. * Gets the easing function of the animation
  37771. * @returns Easing function of the animation
  37772. */
  37773. getEasingFunction(): IEasingFunction;
  37774. /**
  37775. * Sets the easing function of the animation
  37776. * @param easingFunction A custom mathematical formula for animation
  37777. */
  37778. setEasingFunction(easingFunction: EasingFunction): void;
  37779. /**
  37780. * Interpolates a scalar linearly
  37781. * @param startValue Start value of the animation curve
  37782. * @param endValue End value of the animation curve
  37783. * @param gradient Scalar amount to interpolate
  37784. * @returns Interpolated scalar value
  37785. */
  37786. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37787. /**
  37788. * Interpolates a scalar cubically
  37789. * @param startValue Start value of the animation curve
  37790. * @param outTangent End tangent of the animation
  37791. * @param endValue End value of the animation curve
  37792. * @param inTangent Start tangent of the animation curve
  37793. * @param gradient Scalar amount to interpolate
  37794. * @returns Interpolated scalar value
  37795. */
  37796. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37797. /**
  37798. * Interpolates a quaternion using a spherical linear interpolation
  37799. * @param startValue Start value of the animation curve
  37800. * @param endValue End value of the animation curve
  37801. * @param gradient Scalar amount to interpolate
  37802. * @returns Interpolated quaternion value
  37803. */
  37804. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37805. /**
  37806. * Interpolates a quaternion cubically
  37807. * @param startValue Start value of the animation curve
  37808. * @param outTangent End tangent of the animation curve
  37809. * @param endValue End value of the animation curve
  37810. * @param inTangent Start tangent of the animation curve
  37811. * @param gradient Scalar amount to interpolate
  37812. * @returns Interpolated quaternion value
  37813. */
  37814. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37815. /**
  37816. * Interpolates a Vector3 linearly
  37817. * @param startValue Start value of the animation curve
  37818. * @param endValue End value of the animation curve
  37819. * @param gradient Scalar amount to interpolate
  37820. * @returns Interpolated scalar value
  37821. */
  37822. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37823. /**
  37824. * Interpolates a Vector3 cubically
  37825. * @param startValue Start value of the animation curve
  37826. * @param outTangent End tangent of the animation
  37827. * @param endValue End value of the animation curve
  37828. * @param inTangent Start tangent of the animation curve
  37829. * @param gradient Scalar amount to interpolate
  37830. * @returns InterpolatedVector3 value
  37831. */
  37832. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37833. /**
  37834. * Interpolates a Vector2 linearly
  37835. * @param startValue Start value of the animation curve
  37836. * @param endValue End value of the animation curve
  37837. * @param gradient Scalar amount to interpolate
  37838. * @returns Interpolated Vector2 value
  37839. */
  37840. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37841. /**
  37842. * Interpolates a Vector2 cubically
  37843. * @param startValue Start value of the animation curve
  37844. * @param outTangent End tangent of the animation
  37845. * @param endValue End value of the animation curve
  37846. * @param inTangent Start tangent of the animation curve
  37847. * @param gradient Scalar amount to interpolate
  37848. * @returns Interpolated Vector2 value
  37849. */
  37850. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37851. /**
  37852. * Interpolates a size linearly
  37853. * @param startValue Start value of the animation curve
  37854. * @param endValue End value of the animation curve
  37855. * @param gradient Scalar amount to interpolate
  37856. * @returns Interpolated Size value
  37857. */
  37858. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37859. /**
  37860. * Interpolates a Color3 linearly
  37861. * @param startValue Start value of the animation curve
  37862. * @param endValue End value of the animation curve
  37863. * @param gradient Scalar amount to interpolate
  37864. * @returns Interpolated Color3 value
  37865. */
  37866. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37867. /**
  37868. * Interpolates a Color4 linearly
  37869. * @param startValue Start value of the animation curve
  37870. * @param endValue End value of the animation curve
  37871. * @param gradient Scalar amount to interpolate
  37872. * @returns Interpolated Color3 value
  37873. */
  37874. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37875. /**
  37876. * @hidden Internal use only
  37877. */
  37878. _getKeyValue(value: any): any;
  37879. /**
  37880. * @hidden Internal use only
  37881. */
  37882. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37883. /**
  37884. * Defines the function to use to interpolate matrices
  37885. * @param startValue defines the start matrix
  37886. * @param endValue defines the end matrix
  37887. * @param gradient defines the gradient between both matrices
  37888. * @param result defines an optional target matrix where to store the interpolation
  37889. * @returns the interpolated matrix
  37890. */
  37891. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37892. /**
  37893. * Makes a copy of the animation
  37894. * @returns Cloned animation
  37895. */
  37896. clone(): Animation;
  37897. /**
  37898. * Sets the key frames of the animation
  37899. * @param values The animation key frames to set
  37900. */
  37901. setKeys(values: Array<IAnimationKey>): void;
  37902. /**
  37903. * Serializes the animation to an object
  37904. * @returns Serialized object
  37905. */
  37906. serialize(): any;
  37907. /**
  37908. * Float animation type
  37909. */
  37910. static readonly ANIMATIONTYPE_FLOAT: number;
  37911. /**
  37912. * Vector3 animation type
  37913. */
  37914. static readonly ANIMATIONTYPE_VECTOR3: number;
  37915. /**
  37916. * Quaternion animation type
  37917. */
  37918. static readonly ANIMATIONTYPE_QUATERNION: number;
  37919. /**
  37920. * Matrix animation type
  37921. */
  37922. static readonly ANIMATIONTYPE_MATRIX: number;
  37923. /**
  37924. * Color3 animation type
  37925. */
  37926. static readonly ANIMATIONTYPE_COLOR3: number;
  37927. /**
  37928. * Color3 animation type
  37929. */
  37930. static readonly ANIMATIONTYPE_COLOR4: number;
  37931. /**
  37932. * Vector2 animation type
  37933. */
  37934. static readonly ANIMATIONTYPE_VECTOR2: number;
  37935. /**
  37936. * Size animation type
  37937. */
  37938. static readonly ANIMATIONTYPE_SIZE: number;
  37939. /**
  37940. * Relative Loop Mode
  37941. */
  37942. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37943. /**
  37944. * Cycle Loop Mode
  37945. */
  37946. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37947. /**
  37948. * Constant Loop Mode
  37949. */
  37950. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37951. /** @hidden */
  37952. static _UniversalLerp(left: any, right: any, amount: number): any;
  37953. /**
  37954. * Parses an animation object and creates an animation
  37955. * @param parsedAnimation Parsed animation object
  37956. * @returns Animation object
  37957. */
  37958. static Parse(parsedAnimation: any): Animation;
  37959. /**
  37960. * Appends the serialized animations from the source animations
  37961. * @param source Source containing the animations
  37962. * @param destination Target to store the animations
  37963. */
  37964. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37965. /**
  37966. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37967. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37968. * @param url defines the url to load from
  37969. * @returns a promise that will resolve to the new animation or an array of animations
  37970. */
  37971. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37972. /**
  37973. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37974. * @param snippetId defines the snippet to load
  37975. * @returns a promise that will resolve to the new animation or a new array of animations
  37976. */
  37977. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37978. }
  37979. }
  37980. declare module BABYLON {
  37981. /**
  37982. * Interface containing an array of animations
  37983. */
  37984. export interface IAnimatable {
  37985. /**
  37986. * Array of animations
  37987. */
  37988. animations: Nullable<Array<Animation>>;
  37989. }
  37990. }
  37991. declare module BABYLON {
  37992. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37993. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37994. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37995. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37996. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37997. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37998. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37999. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38000. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38001. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38002. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38003. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38004. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38005. /**
  38006. * Decorator used to define property that can be serialized as reference to a camera
  38007. * @param sourceName defines the name of the property to decorate
  38008. */
  38009. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38010. /**
  38011. * Class used to help serialization objects
  38012. */
  38013. export class SerializationHelper {
  38014. /** @hidden */
  38015. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38016. /** @hidden */
  38017. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38018. /** @hidden */
  38019. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38020. /** @hidden */
  38021. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38022. /**
  38023. * Appends the serialized animations from the source animations
  38024. * @param source Source containing the animations
  38025. * @param destination Target to store the animations
  38026. */
  38027. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38028. /**
  38029. * Static function used to serialized a specific entity
  38030. * @param entity defines the entity to serialize
  38031. * @param serializationObject defines the optional target object where serialization data will be stored
  38032. * @returns a JSON compatible object representing the serialization of the entity
  38033. */
  38034. static Serialize<T>(entity: T, serializationObject?: any): any;
  38035. /**
  38036. * Creates a new entity from a serialization data object
  38037. * @param creationFunction defines a function used to instanciated the new entity
  38038. * @param source defines the source serialization data
  38039. * @param scene defines the hosting scene
  38040. * @param rootUrl defines the root url for resources
  38041. * @returns a new entity
  38042. */
  38043. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38044. /**
  38045. * Clones an object
  38046. * @param creationFunction defines the function used to instanciate the new object
  38047. * @param source defines the source object
  38048. * @returns the cloned object
  38049. */
  38050. static Clone<T>(creationFunction: () => T, source: T): T;
  38051. /**
  38052. * Instanciates a new object based on a source one (some data will be shared between both object)
  38053. * @param creationFunction defines the function used to instanciate the new object
  38054. * @param source defines the source object
  38055. * @returns the new object
  38056. */
  38057. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38058. }
  38059. }
  38060. declare module BABYLON {
  38061. /**
  38062. * This is the base class of all the camera used in the application.
  38063. * @see https://doc.babylonjs.com/features/cameras
  38064. */
  38065. export class Camera extends Node {
  38066. /** @hidden */
  38067. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38068. /**
  38069. * This is the default projection mode used by the cameras.
  38070. * It helps recreating a feeling of perspective and better appreciate depth.
  38071. * This is the best way to simulate real life cameras.
  38072. */
  38073. static readonly PERSPECTIVE_CAMERA: number;
  38074. /**
  38075. * This helps creating camera with an orthographic mode.
  38076. * 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.
  38077. */
  38078. static readonly ORTHOGRAPHIC_CAMERA: number;
  38079. /**
  38080. * This is the default FOV mode for perspective cameras.
  38081. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38082. */
  38083. static readonly FOVMODE_VERTICAL_FIXED: number;
  38084. /**
  38085. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38086. */
  38087. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38088. /**
  38089. * This specifies there is no need for a camera rig.
  38090. * Basically only one eye is rendered corresponding to the camera.
  38091. */
  38092. static readonly RIG_MODE_NONE: number;
  38093. /**
  38094. * Simulates a camera Rig with one blue eye and one red eye.
  38095. * This can be use with 3d blue and red glasses.
  38096. */
  38097. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38098. /**
  38099. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38100. */
  38101. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38102. /**
  38103. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38104. */
  38105. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38106. /**
  38107. * Defines that both eyes of the camera will be rendered over under each other.
  38108. */
  38109. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38110. /**
  38111. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38112. */
  38113. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38114. /**
  38115. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38116. */
  38117. static readonly RIG_MODE_VR: number;
  38118. /**
  38119. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38120. */
  38121. static readonly RIG_MODE_WEBVR: number;
  38122. /**
  38123. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38124. */
  38125. static readonly RIG_MODE_CUSTOM: number;
  38126. /**
  38127. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38128. */
  38129. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38130. /**
  38131. * Define the input manager associated with the camera.
  38132. */
  38133. inputs: CameraInputsManager<Camera>;
  38134. /** @hidden */
  38135. _position: Vector3;
  38136. /**
  38137. * Define the current local position of the camera in the scene
  38138. */
  38139. get position(): Vector3;
  38140. set position(newPosition: Vector3);
  38141. protected _upVector: Vector3;
  38142. /**
  38143. * The vector the camera should consider as up.
  38144. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38145. */
  38146. set upVector(vec: Vector3);
  38147. get upVector(): Vector3;
  38148. /**
  38149. * Define the current limit on the left side for an orthographic camera
  38150. * In scene unit
  38151. */
  38152. orthoLeft: Nullable<number>;
  38153. /**
  38154. * Define the current limit on the right side for an orthographic camera
  38155. * In scene unit
  38156. */
  38157. orthoRight: Nullable<number>;
  38158. /**
  38159. * Define the current limit on the bottom side for an orthographic camera
  38160. * In scene unit
  38161. */
  38162. orthoBottom: Nullable<number>;
  38163. /**
  38164. * Define the current limit on the top side for an orthographic camera
  38165. * In scene unit
  38166. */
  38167. orthoTop: Nullable<number>;
  38168. /**
  38169. * Field Of View is set in Radians. (default is 0.8)
  38170. */
  38171. fov: number;
  38172. /**
  38173. * Define the minimum distance the camera can see from.
  38174. * This is important to note that the depth buffer are not infinite and the closer it starts
  38175. * the more your scene might encounter depth fighting issue.
  38176. */
  38177. minZ: number;
  38178. /**
  38179. * Define the maximum distance the camera can see to.
  38180. * This is important to note that the depth buffer are not infinite and the further it end
  38181. * the more your scene might encounter depth fighting issue.
  38182. */
  38183. maxZ: number;
  38184. /**
  38185. * Define the default inertia of the camera.
  38186. * This helps giving a smooth feeling to the camera movement.
  38187. */
  38188. inertia: number;
  38189. /**
  38190. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38191. */
  38192. mode: number;
  38193. /**
  38194. * Define whether the camera is intermediate.
  38195. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38196. */
  38197. isIntermediate: boolean;
  38198. /**
  38199. * Define the viewport of the camera.
  38200. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38201. */
  38202. viewport: Viewport;
  38203. /**
  38204. * Restricts the camera to viewing objects with the same layerMask.
  38205. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38206. */
  38207. layerMask: number;
  38208. /**
  38209. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38210. */
  38211. fovMode: number;
  38212. /**
  38213. * Rig mode of the camera.
  38214. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38215. * This is normally controlled byt the camera themselves as internal use.
  38216. */
  38217. cameraRigMode: number;
  38218. /**
  38219. * Defines the distance between both "eyes" in case of a RIG
  38220. */
  38221. interaxialDistance: number;
  38222. /**
  38223. * Defines if stereoscopic rendering is done side by side or over under.
  38224. */
  38225. isStereoscopicSideBySide: boolean;
  38226. /**
  38227. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  38228. * This is pretty helpful if you wish to make a camera render to a texture you could reuse somewhere
  38229. * else in the scene. (Eg. security camera)
  38230. *
  38231. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corresponding to an HMD)
  38232. */
  38233. customRenderTargets: RenderTargetTexture[];
  38234. /**
  38235. * When set, the camera will render to this render target instead of the default canvas
  38236. *
  38237. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38238. */
  38239. outputRenderTarget: Nullable<RenderTargetTexture>;
  38240. /**
  38241. * Observable triggered when the camera view matrix has changed.
  38242. */
  38243. onViewMatrixChangedObservable: Observable<Camera>;
  38244. /**
  38245. * Observable triggered when the camera Projection matrix has changed.
  38246. */
  38247. onProjectionMatrixChangedObservable: Observable<Camera>;
  38248. /**
  38249. * Observable triggered when the inputs have been processed.
  38250. */
  38251. onAfterCheckInputsObservable: Observable<Camera>;
  38252. /**
  38253. * Observable triggered when reset has been called and applied to the camera.
  38254. */
  38255. onRestoreStateObservable: Observable<Camera>;
  38256. /**
  38257. * Is this camera a part of a rig system?
  38258. */
  38259. isRigCamera: boolean;
  38260. /**
  38261. * If isRigCamera set to true this will be set with the parent camera.
  38262. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38263. */
  38264. rigParent?: Camera;
  38265. /** @hidden */
  38266. _cameraRigParams: any;
  38267. /** @hidden */
  38268. _rigCameras: Camera[];
  38269. /** @hidden */
  38270. _rigPostProcess: Nullable<PostProcess>;
  38271. protected _webvrViewMatrix: Matrix;
  38272. /** @hidden */
  38273. _skipRendering: boolean;
  38274. /** @hidden */
  38275. _projectionMatrix: Matrix;
  38276. /** @hidden */
  38277. _postProcesses: Nullable<PostProcess>[];
  38278. /** @hidden */
  38279. _activeMeshes: SmartArray<AbstractMesh>;
  38280. protected _globalPosition: Vector3;
  38281. /** @hidden */
  38282. _computedViewMatrix: Matrix;
  38283. private _doNotComputeProjectionMatrix;
  38284. private _transformMatrix;
  38285. private _frustumPlanes;
  38286. private _refreshFrustumPlanes;
  38287. private _storedFov;
  38288. private _stateStored;
  38289. /**
  38290. * Instantiates a new camera object.
  38291. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38292. * @see https://doc.babylonjs.com/features/cameras
  38293. * @param name Defines the name of the camera in the scene
  38294. * @param position Defines the position of the camera
  38295. * @param scene Defines the scene the camera belongs too
  38296. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38297. */
  38298. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38299. /**
  38300. * Store current camera state (fov, position, etc..)
  38301. * @returns the camera
  38302. */
  38303. storeState(): Camera;
  38304. /**
  38305. * Restores the camera state values if it has been stored. You must call storeState() first
  38306. */
  38307. protected _restoreStateValues(): boolean;
  38308. /**
  38309. * Restored camera state. You must call storeState() first.
  38310. * @returns true if restored and false otherwise
  38311. */
  38312. restoreState(): boolean;
  38313. /**
  38314. * Gets the class name of the camera.
  38315. * @returns the class name
  38316. */
  38317. getClassName(): string;
  38318. /** @hidden */
  38319. readonly _isCamera: boolean;
  38320. /**
  38321. * Gets a string representation of the camera useful for debug purpose.
  38322. * @param fullDetails Defines that a more verboe level of logging is required
  38323. * @returns the string representation
  38324. */
  38325. toString(fullDetails?: boolean): string;
  38326. /**
  38327. * Gets the current world space position of the camera.
  38328. */
  38329. get globalPosition(): Vector3;
  38330. /**
  38331. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38332. * @returns the active meshe list
  38333. */
  38334. getActiveMeshes(): SmartArray<AbstractMesh>;
  38335. /**
  38336. * Check whether a mesh is part of the current active mesh list of the camera
  38337. * @param mesh Defines the mesh to check
  38338. * @returns true if active, false otherwise
  38339. */
  38340. isActiveMesh(mesh: Mesh): boolean;
  38341. /**
  38342. * Is this camera ready to be used/rendered
  38343. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38344. * @return true if the camera is ready
  38345. */
  38346. isReady(completeCheck?: boolean): boolean;
  38347. /** @hidden */
  38348. _initCache(): void;
  38349. /** @hidden */
  38350. _updateCache(ignoreParentClass?: boolean): void;
  38351. /** @hidden */
  38352. _isSynchronized(): boolean;
  38353. /** @hidden */
  38354. _isSynchronizedViewMatrix(): boolean;
  38355. /** @hidden */
  38356. _isSynchronizedProjectionMatrix(): boolean;
  38357. /**
  38358. * Attach the input controls to a specific dom element to get the input from.
  38359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38360. */
  38361. attachControl(noPreventDefault?: boolean): void;
  38362. /**
  38363. * Attach the input controls to a specific dom element to get the input from.
  38364. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38366. * BACK COMPAT SIGNATURE ONLY.
  38367. */
  38368. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38369. /**
  38370. * Detach the current controls from the specified dom element.
  38371. */
  38372. detachControl(): void;
  38373. /**
  38374. * Detach the current controls from the specified dom element.
  38375. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38376. */
  38377. detachControl(ignored: any): void;
  38378. /**
  38379. * Update the camera state according to the different inputs gathered during the frame.
  38380. */
  38381. update(): void;
  38382. /** @hidden */
  38383. _checkInputs(): void;
  38384. /** @hidden */
  38385. get rigCameras(): Camera[];
  38386. /**
  38387. * Gets the post process used by the rig cameras
  38388. */
  38389. get rigPostProcess(): Nullable<PostProcess>;
  38390. /**
  38391. * Internal, gets the first post process.
  38392. * @returns the first post process to be run on this camera.
  38393. */
  38394. _getFirstPostProcess(): Nullable<PostProcess>;
  38395. private _cascadePostProcessesToRigCams;
  38396. /**
  38397. * Attach a post process to the camera.
  38398. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38399. * @param postProcess The post process to attach to the camera
  38400. * @param insertAt The position of the post process in case several of them are in use in the scene
  38401. * @returns the position the post process has been inserted at
  38402. */
  38403. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38404. /**
  38405. * Detach a post process to the camera.
  38406. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38407. * @param postProcess The post process to detach from the camera
  38408. */
  38409. detachPostProcess(postProcess: PostProcess): void;
  38410. /**
  38411. * Gets the current world matrix of the camera
  38412. */
  38413. getWorldMatrix(): Matrix;
  38414. /** @hidden */
  38415. _getViewMatrix(): Matrix;
  38416. /**
  38417. * Gets the current view matrix of the camera.
  38418. * @param force forces the camera to recompute the matrix without looking at the cached state
  38419. * @returns the view matrix
  38420. */
  38421. getViewMatrix(force?: boolean): Matrix;
  38422. /**
  38423. * Freeze the projection matrix.
  38424. * It will prevent the cache check of the camera projection compute and can speed up perf
  38425. * if no parameter of the camera are meant to change
  38426. * @param projection Defines manually a projection if necessary
  38427. */
  38428. freezeProjectionMatrix(projection?: Matrix): void;
  38429. /**
  38430. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38431. */
  38432. unfreezeProjectionMatrix(): void;
  38433. /**
  38434. * Gets the current projection matrix of the camera.
  38435. * @param force forces the camera to recompute the matrix without looking at the cached state
  38436. * @returns the projection matrix
  38437. */
  38438. getProjectionMatrix(force?: boolean): Matrix;
  38439. /**
  38440. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38441. * @returns a Matrix
  38442. */
  38443. getTransformationMatrix(): Matrix;
  38444. private _updateFrustumPlanes;
  38445. /**
  38446. * Checks if a cullable object (mesh...) is in the camera frustum
  38447. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38448. * @param target The object to check
  38449. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38450. * @returns true if the object is in frustum otherwise false
  38451. */
  38452. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38453. /**
  38454. * Checks if a cullable object (mesh...) is in the camera frustum
  38455. * Unlike isInFrustum this checks the full bounding box
  38456. * @param target The object to check
  38457. * @returns true if the object is in frustum otherwise false
  38458. */
  38459. isCompletelyInFrustum(target: ICullable): boolean;
  38460. /**
  38461. * Gets a ray in the forward direction from the camera.
  38462. * @param length Defines the length of the ray to create
  38463. * @param transform Defines the transform to apply to the ray, by default the world matrix is used to create a workd space ray
  38464. * @param origin Defines the start point of the ray which defaults to the camera position
  38465. * @returns the forward ray
  38466. */
  38467. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38468. /**
  38469. * Gets a ray in the forward direction from the camera.
  38470. * @param refRay the ray to (re)use when setting the values
  38471. * @param length Defines the length of the ray to create
  38472. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38473. * @param origin Defines the start point of the ray which defaults to the camera position
  38474. * @returns the forward ray
  38475. */
  38476. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38477. /**
  38478. * Releases resources associated with this node.
  38479. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38480. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38481. */
  38482. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38483. /** @hidden */
  38484. _isLeftCamera: boolean;
  38485. /**
  38486. * Gets the left camera of a rig setup in case of Rigged Camera
  38487. */
  38488. get isLeftCamera(): boolean;
  38489. /** @hidden */
  38490. _isRightCamera: boolean;
  38491. /**
  38492. * Gets the right camera of a rig setup in case of Rigged Camera
  38493. */
  38494. get isRightCamera(): boolean;
  38495. /**
  38496. * Gets the left camera of a rig setup in case of Rigged Camera
  38497. */
  38498. get leftCamera(): Nullable<FreeCamera>;
  38499. /**
  38500. * Gets the right camera of a rig setup in case of Rigged Camera
  38501. */
  38502. get rightCamera(): Nullable<FreeCamera>;
  38503. /**
  38504. * Gets the left camera target of a rig setup in case of Rigged Camera
  38505. * @returns the target position
  38506. */
  38507. getLeftTarget(): Nullable<Vector3>;
  38508. /**
  38509. * Gets the right camera target of a rig setup in case of Rigged Camera
  38510. * @returns the target position
  38511. */
  38512. getRightTarget(): Nullable<Vector3>;
  38513. /**
  38514. * @hidden
  38515. */
  38516. setCameraRigMode(mode: number, rigParams: any): void;
  38517. /** @hidden */
  38518. static _setStereoscopicRigMode(camera: Camera): void;
  38519. /** @hidden */
  38520. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38521. /** @hidden */
  38522. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38523. /** @hidden */
  38524. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38525. /** @hidden */
  38526. _getVRProjectionMatrix(): Matrix;
  38527. protected _updateCameraRotationMatrix(): void;
  38528. protected _updateWebVRCameraRotationMatrix(): void;
  38529. /**
  38530. * This function MUST be overwritten by the different WebVR cameras available.
  38531. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38532. * @hidden
  38533. */
  38534. _getWebVRProjectionMatrix(): Matrix;
  38535. /**
  38536. * This function MUST be overwritten by the different WebVR cameras available.
  38537. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38538. * @hidden
  38539. */
  38540. _getWebVRViewMatrix(): Matrix;
  38541. /** @hidden */
  38542. setCameraRigParameter(name: string, value: any): void;
  38543. /**
  38544. * needs to be overridden by children so sub has required properties to be copied
  38545. * @hidden
  38546. */
  38547. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38548. /**
  38549. * May need to be overridden by children
  38550. * @hidden
  38551. */
  38552. _updateRigCameras(): void;
  38553. /** @hidden */
  38554. _setupInputs(): void;
  38555. /**
  38556. * Serialiaze the camera setup to a json representation
  38557. * @returns the JSON representation
  38558. */
  38559. serialize(): any;
  38560. /**
  38561. * Clones the current camera.
  38562. * @param name The cloned camera name
  38563. * @returns the cloned camera
  38564. */
  38565. clone(name: string): Camera;
  38566. /**
  38567. * Gets the direction of the camera relative to a given local axis.
  38568. * @param localAxis Defines the reference axis to provide a relative direction.
  38569. * @return the direction
  38570. */
  38571. getDirection(localAxis: Vector3): Vector3;
  38572. /**
  38573. * Returns the current camera absolute rotation
  38574. */
  38575. get absoluteRotation(): Quaternion;
  38576. /**
  38577. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38578. * @param localAxis Defines the reference axis to provide a relative direction.
  38579. * @param result Defines the vector to store the result in
  38580. */
  38581. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38582. /**
  38583. * Gets a camera constructor for a given camera type
  38584. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38585. * @param name The name of the camera the result will be able to instantiate
  38586. * @param scene The scene the result will construct the camera in
  38587. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38588. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38589. * @returns a factory method to construct the camera
  38590. */
  38591. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38592. /**
  38593. * Compute the world matrix of the camera.
  38594. * @returns the camera world matrix
  38595. */
  38596. computeWorldMatrix(): Matrix;
  38597. /**
  38598. * Parse a JSON and creates the camera from the parsed information
  38599. * @param parsedCamera The JSON to parse
  38600. * @param scene The scene to instantiate the camera in
  38601. * @returns the newly constructed camera
  38602. */
  38603. static Parse(parsedCamera: any, scene: Scene): Camera;
  38604. }
  38605. }
  38606. declare module BABYLON {
  38607. /**
  38608. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38609. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38610. */
  38611. export class PostProcessManager {
  38612. private _scene;
  38613. private _indexBuffer;
  38614. private _vertexBuffers;
  38615. /**
  38616. * Creates a new instance PostProcess
  38617. * @param scene The scene that the post process is associated with.
  38618. */
  38619. constructor(scene: Scene);
  38620. private _prepareBuffers;
  38621. private _buildIndexBuffer;
  38622. /**
  38623. * Rebuilds the vertex buffers of the manager.
  38624. * @hidden
  38625. */
  38626. _rebuild(): void;
  38627. /**
  38628. * Prepares a frame to be run through a post process.
  38629. * @param sourceTexture The input texture to the post processes. (default: null)
  38630. * @param postProcesses An array of post processes to be run. (default: null)
  38631. * @returns True if the post processes were able to be run.
  38632. * @hidden
  38633. */
  38634. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38635. /**
  38636. * Manually render a set of post processes to a texture.
  38637. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38638. * @param postProcesses An array of post processes to be run.
  38639. * @param targetTexture The target texture to render to.
  38640. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38641. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38642. * @param lodLevel defines which lod of the texture to render to
  38643. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38644. */
  38645. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38646. /**
  38647. * Finalize the result of the output of the postprocesses.
  38648. * @param doNotPresent If true the result will not be displayed to the screen.
  38649. * @param targetTexture The target texture to render to.
  38650. * @param faceIndex The index of the face to bind the target texture to.
  38651. * @param postProcesses The array of post processes to render.
  38652. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38653. * @hidden
  38654. */
  38655. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38656. /**
  38657. * Disposes of the post process manager.
  38658. */
  38659. dispose(): void;
  38660. }
  38661. }
  38662. declare module BABYLON {
  38663. /**
  38664. * This Helps creating a texture that will be created from a camera in your scene.
  38665. * It is basically a dynamic texture that could be used to create special effects for instance.
  38666. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38667. */
  38668. export class RenderTargetTexture extends Texture {
  38669. /**
  38670. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38671. */
  38672. static readonly REFRESHRATE_RENDER_ONCE: number;
  38673. /**
  38674. * The texture will only be rendered rendered every frame and is recommended for dynamic contents.
  38675. */
  38676. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38677. /**
  38678. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38679. * the central point of your effect and can save a lot of performances.
  38680. */
  38681. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38682. /**
  38683. * Use this predicate to dynamically define the list of mesh you want to render.
  38684. * If set, the renderList property will be overwritten.
  38685. */
  38686. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38687. private _renderList;
  38688. /**
  38689. * Use this list to define the list of mesh you want to render.
  38690. */
  38691. get renderList(): Nullable<Array<AbstractMesh>>;
  38692. set renderList(value: Nullable<Array<AbstractMesh>>);
  38693. /**
  38694. * Use this function to overload the renderList array at rendering time.
  38695. * Return null to render with the current renderList, else return the list of meshes to use for rendering.
  38696. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38697. * the cube (if the RTT is a cube, else layerOrFace=0).
  38698. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38699. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38700. * hold dummy elements!
  38701. */
  38702. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38703. private _hookArray;
  38704. /**
  38705. * Define if particles should be rendered in your texture.
  38706. */
  38707. renderParticles: boolean;
  38708. /**
  38709. * Define if sprites should be rendered in your texture.
  38710. */
  38711. renderSprites: boolean;
  38712. /**
  38713. * Define the camera used to render the texture.
  38714. */
  38715. activeCamera: Nullable<Camera>;
  38716. /**
  38717. * Override the mesh isReady function with your own one.
  38718. */
  38719. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38720. /**
  38721. * Override the render function of the texture with your own one.
  38722. */
  38723. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38724. /**
  38725. * Define if camera post processes should be use while rendering the texture.
  38726. */
  38727. useCameraPostProcesses: boolean;
  38728. /**
  38729. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38730. */
  38731. ignoreCameraViewport: boolean;
  38732. private _postProcessManager;
  38733. /**
  38734. * Post-processes for this render target
  38735. */
  38736. get postProcesses(): PostProcess[];
  38737. private _postProcesses;
  38738. private _resizeObserver;
  38739. private get _prePassEnabled();
  38740. /**
  38741. * An event triggered when the texture is unbind.
  38742. */
  38743. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38744. /**
  38745. * An event triggered when the texture is unbind.
  38746. */
  38747. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38748. private _onAfterUnbindObserver;
  38749. /**
  38750. * Set a after unbind callback in the texture.
  38751. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38752. */
  38753. set onAfterUnbind(callback: () => void);
  38754. /**
  38755. * An event triggered before rendering the texture
  38756. */
  38757. onBeforeRenderObservable: Observable<number>;
  38758. private _onBeforeRenderObserver;
  38759. /**
  38760. * Set a before render callback in the texture.
  38761. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38762. */
  38763. set onBeforeRender(callback: (faceIndex: number) => void);
  38764. /**
  38765. * An event triggered after rendering the texture
  38766. */
  38767. onAfterRenderObservable: Observable<number>;
  38768. private _onAfterRenderObserver;
  38769. /**
  38770. * Set a after render callback in the texture.
  38771. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38772. */
  38773. set onAfterRender(callback: (faceIndex: number) => void);
  38774. /**
  38775. * An event triggered after the texture clear
  38776. */
  38777. onClearObservable: Observable<Engine>;
  38778. private _onClearObserver;
  38779. /**
  38780. * Set a clear callback in the texture.
  38781. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38782. */
  38783. set onClear(callback: (Engine: Engine) => void);
  38784. /**
  38785. * An event triggered when the texture is resized.
  38786. */
  38787. onResizeObservable: Observable<RenderTargetTexture>;
  38788. /**
  38789. * Define the clear color of the Render Target if it should be different from the scene.
  38790. */
  38791. clearColor: Color4;
  38792. protected _size: number | {
  38793. width: number;
  38794. height: number;
  38795. layers?: number;
  38796. };
  38797. protected _initialSizeParameter: number | {
  38798. width: number;
  38799. height: number;
  38800. } | {
  38801. ratio: number;
  38802. };
  38803. protected _sizeRatio: Nullable<number>;
  38804. /** @hidden */
  38805. _generateMipMaps: boolean;
  38806. protected _renderingManager: RenderingManager;
  38807. /** @hidden */
  38808. _waitingRenderList?: string[];
  38809. protected _doNotChangeAspectRatio: boolean;
  38810. protected _currentRefreshId: number;
  38811. protected _refreshRate: number;
  38812. protected _textureMatrix: Matrix;
  38813. protected _samples: number;
  38814. protected _renderTargetOptions: RenderTargetCreationOptions;
  38815. /**
  38816. * Gets render target creation options that were used.
  38817. */
  38818. get renderTargetOptions(): RenderTargetCreationOptions;
  38819. protected _onRatioRescale(): void;
  38820. /**
  38821. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38822. * It must define where the camera used to render the texture is set
  38823. */
  38824. boundingBoxPosition: Vector3;
  38825. private _boundingBoxSize;
  38826. /**
  38827. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38828. * When defined, the cubemap will switch to local mode
  38829. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38830. * @example https://www.babylonjs-playground.com/#RNASML
  38831. */
  38832. set boundingBoxSize(value: Vector3);
  38833. get boundingBoxSize(): Vector3;
  38834. /**
  38835. * In case the RTT has been created with a depth texture, get the associated
  38836. * depth texture.
  38837. * Otherwise, return null.
  38838. */
  38839. get depthStencilTexture(): Nullable<InternalTexture>;
  38840. /**
  38841. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post process
  38842. * or used a shadow, depth texture...
  38843. * @param name The friendly name of the texture
  38844. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  38845. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38846. * @param generateMipMaps True if mip maps need to be generated after render.
  38847. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38848. * @param type The type of the buffer in the RTT (int, half float, float...)
  38849. * @param isCube True if a cube texture needs to be created
  38850. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38851. * @param generateDepthBuffer True to generate a depth buffer
  38852. * @param generateStencilBuffer True to generate a stencil buffer
  38853. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38854. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38855. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38856. * @param samples sample count to use when creating the RTT
  38857. */
  38858. constructor(name: string, size: number | {
  38859. width: number;
  38860. height: number;
  38861. layers?: number;
  38862. } | {
  38863. ratio: number;
  38864. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean, samples?: number);
  38865. /**
  38866. * Creates a depth stencil texture.
  38867. * This is only available in WebGL 2 or with the depth texture extension available.
  38868. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38869. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38870. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38871. * @param samples sample count of the depth/stencil texture
  38872. */
  38873. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38874. private _processSizeParameter;
  38875. /**
  38876. * Define the number of samples to use in case of MSAA.
  38877. * It defaults to one meaning no MSAA has been enabled.
  38878. */
  38879. get samples(): number;
  38880. set samples(value: number);
  38881. /**
  38882. * Resets the refresh counter of the texture and start bak from scratch.
  38883. * Could be useful to regenerate the texture if it is setup to render only once.
  38884. */
  38885. resetRefreshCounter(): void;
  38886. /**
  38887. * Define the refresh rate of the texture or the rendering frequency.
  38888. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38889. */
  38890. get refreshRate(): number;
  38891. set refreshRate(value: number);
  38892. /**
  38893. * Adds a post process to the render target rendering passes.
  38894. * @param postProcess define the post process to add
  38895. */
  38896. addPostProcess(postProcess: PostProcess): void;
  38897. /**
  38898. * Clear all the post processes attached to the render target
  38899. * @param dispose define if the cleared post processes should also be disposed (false by default)
  38900. */
  38901. clearPostProcesses(dispose?: boolean): void;
  38902. /**
  38903. * Remove one of the post process from the list of attached post processes to the texture
  38904. * @param postProcess define the post process to remove from the list
  38905. */
  38906. removePostProcess(postProcess: PostProcess): void;
  38907. /** @hidden */
  38908. _shouldRender(): boolean;
  38909. /**
  38910. * Gets the actual render size of the texture.
  38911. * @returns the width of the render size
  38912. */
  38913. getRenderSize(): number;
  38914. /**
  38915. * Gets the actual render width of the texture.
  38916. * @returns the width of the render size
  38917. */
  38918. getRenderWidth(): number;
  38919. /**
  38920. * Gets the actual render height of the texture.
  38921. * @returns the height of the render size
  38922. */
  38923. getRenderHeight(): number;
  38924. /**
  38925. * Gets the actual number of layers of the texture.
  38926. * @returns the number of layers
  38927. */
  38928. getRenderLayers(): number;
  38929. /**
  38930. * Get if the texture can be rescaled or not.
  38931. */
  38932. get canRescale(): boolean;
  38933. /**
  38934. * Resize the texture using a ratio.
  38935. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  38936. */
  38937. scale(ratio: number): void;
  38938. /**
  38939. * Get the texture reflection matrix used to rotate/transform the reflection.
  38940. * @returns the reflection matrix
  38941. */
  38942. getReflectionTextureMatrix(): Matrix;
  38943. /**
  38944. * Resize the texture to a new desired size.
  38945. * Be careful as it will recreate all the data in the new texture.
  38946. * @param size Define the new size. It can be:
  38947. * - a number for squared texture,
  38948. * - an object containing { width: number, height: number }
  38949. * - or an object containing a ratio { ratio: number }
  38950. */
  38951. resize(size: number | {
  38952. width: number;
  38953. height: number;
  38954. } | {
  38955. ratio: number;
  38956. }): void;
  38957. private _defaultRenderListPrepared;
  38958. /**
  38959. * Renders all the objects from the render list into the texture.
  38960. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  38961. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  38962. */
  38963. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38964. private _bestReflectionRenderTargetDimension;
  38965. private _prepareRenderingManager;
  38966. /**
  38967. * @hidden
  38968. * @param faceIndex face index to bind to if this is a cubetexture
  38969. * @param layer defines the index of the texture to bind in the array
  38970. */
  38971. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  38972. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38973. /**
  38974. * @hidden
  38975. */
  38976. _prepareFrame(scene: Scene, faceIndex?: number, layer?: number, useCameraPostProcess?: boolean): void;
  38977. private renderToTarget;
  38978. /**
  38979. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  38980. * This allowed control for front to back rendering or reversely depending of the special needs.
  38981. *
  38982. * @param renderingGroupId The rendering group id corresponding to its index
  38983. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38984. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38985. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38986. */
  38987. 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;
  38988. /**
  38989. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38990. *
  38991. * @param renderingGroupId The rendering group id corresponding to its index
  38992. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38993. */
  38994. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38995. /**
  38996. * Clones the texture.
  38997. * @returns the cloned texture
  38998. */
  38999. clone(): RenderTargetTexture;
  39000. /**
  39001. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  39002. * @returns The JSON representation of the texture
  39003. */
  39004. serialize(): any;
  39005. /**
  39006. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39007. */
  39008. disposeFramebufferObjects(): void;
  39009. /**
  39010. * Dispose the texture and release its associated resources.
  39011. */
  39012. dispose(): void;
  39013. /** @hidden */
  39014. _rebuild(): void;
  39015. /**
  39016. * Clear the info related to rendering groups preventing retention point in material dispose.
  39017. */
  39018. freeRenderingGroups(): void;
  39019. /**
  39020. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39021. * @returns the view count
  39022. */
  39023. getViewCount(): number;
  39024. }
  39025. }
  39026. declare module BABYLON {
  39027. /**
  39028. * Options to be used when creating an effect.
  39029. */
  39030. export interface IEffectCreationOptions {
  39031. /**
  39032. * Attributes that will be used in the shader.
  39033. */
  39034. attributes: string[];
  39035. /**
  39036. * Uniform variable names that will be set in the shader.
  39037. */
  39038. uniformsNames: string[];
  39039. /**
  39040. * Uniform buffer variable names that will be set in the shader.
  39041. */
  39042. uniformBuffersNames: string[];
  39043. /**
  39044. * Sampler texture variable names that will be set in the shader.
  39045. */
  39046. samplers: string[];
  39047. /**
  39048. * Define statements that will be set in the shader.
  39049. */
  39050. defines: any;
  39051. /**
  39052. * Possible fallbacks for this effect to improve performance when needed.
  39053. */
  39054. fallbacks: Nullable<IEffectFallbacks>;
  39055. /**
  39056. * Callback that will be called when the shader is compiled.
  39057. */
  39058. onCompiled: Nullable<(effect: Effect) => void>;
  39059. /**
  39060. * Callback that will be called if an error occurs during shader compilation.
  39061. */
  39062. onError: Nullable<(effect: Effect, errors: string) => void>;
  39063. /**
  39064. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39065. */
  39066. indexParameters?: any;
  39067. /**
  39068. * Max number of lights that can be used in the shader.
  39069. */
  39070. maxSimultaneousLights?: number;
  39071. /**
  39072. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39073. */
  39074. transformFeedbackVaryings?: Nullable<string[]>;
  39075. /**
  39076. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  39077. */
  39078. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39079. /**
  39080. * Is this effect rendering to several color attachments ?
  39081. */
  39082. multiTarget?: boolean;
  39083. }
  39084. /**
  39085. * Effect containing vertex and fragment shader that can be executed on an object.
  39086. */
  39087. export class Effect implements IDisposable {
  39088. /**
  39089. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39090. */
  39091. static ShadersRepository: string;
  39092. /**
  39093. * Enable logging of the shader code when a compilation error occurs
  39094. */
  39095. static LogShaderCodeOnCompilationError: boolean;
  39096. /**
  39097. * Name of the effect.
  39098. */
  39099. name: any;
  39100. /**
  39101. * String container all the define statements that should be set on the shader.
  39102. */
  39103. defines: string;
  39104. /**
  39105. * Callback that will be called when the shader is compiled.
  39106. */
  39107. onCompiled: Nullable<(effect: Effect) => void>;
  39108. /**
  39109. * Callback that will be called if an error occurs during shader compilation.
  39110. */
  39111. onError: Nullable<(effect: Effect, errors: string) => void>;
  39112. /**
  39113. * Callback that will be called when effect is bound.
  39114. */
  39115. onBind: Nullable<(effect: Effect) => void>;
  39116. /**
  39117. * Unique ID of the effect.
  39118. */
  39119. uniqueId: number;
  39120. /**
  39121. * Observable that will be called when the shader is compiled.
  39122. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39123. */
  39124. onCompileObservable: Observable<Effect>;
  39125. /**
  39126. * Observable that will be called if an error occurs during shader compilation.
  39127. */
  39128. onErrorObservable: Observable<Effect>;
  39129. /** @hidden */
  39130. _onBindObservable: Nullable<Observable<Effect>>;
  39131. /**
  39132. * @hidden
  39133. * Specifies if the effect was previously ready
  39134. */
  39135. _wasPreviouslyReady: boolean;
  39136. /**
  39137. * Observable that will be called when effect is bound.
  39138. */
  39139. get onBindObservable(): Observable<Effect>;
  39140. /** @hidden */
  39141. _bonesComputationForcedToCPU: boolean;
  39142. /** @hidden */
  39143. _uniformBuffersNames: {
  39144. [key: string]: number;
  39145. };
  39146. /** @hidden */
  39147. _samplerList: string[];
  39148. /** @hidden */
  39149. _multiTarget: boolean;
  39150. private static _uniqueIdSeed;
  39151. private _engine;
  39152. private _uniformBuffersNamesList;
  39153. private _uniformsNames;
  39154. private _samplers;
  39155. private _isReady;
  39156. private _compilationError;
  39157. private _allFallbacksProcessed;
  39158. private _attributesNames;
  39159. private _attributes;
  39160. private _attributeLocationByName;
  39161. private _uniforms;
  39162. /**
  39163. * Key for the effect.
  39164. * @hidden
  39165. */
  39166. _key: string;
  39167. private _indexParameters;
  39168. private _fallbacks;
  39169. private _vertexSourceCodeOverride;
  39170. private _fragmentSourceCodeOverride;
  39171. private _transformFeedbackVaryings;
  39172. /**
  39173. * Compiled shader to webGL program.
  39174. * @hidden
  39175. */
  39176. _pipelineContext: Nullable<IPipelineContext>;
  39177. /** @hidden */
  39178. _vertexSourceCode: string;
  39179. /** @hidden */
  39180. _fragmentSourceCode: string;
  39181. /** @hidden */
  39182. private _rawVertexSourceCode;
  39183. /** @hidden */
  39184. private _rawFragmentSourceCode;
  39185. private static _baseCache;
  39186. private _processingContext;
  39187. /**
  39188. * Instantiates an effect.
  39189. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39190. * @param baseName Name of the effect.
  39191. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39192. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39193. * @param samplers List of sampler variables that will be passed to the shader.
  39194. * @param engine Engine to be used to render the effect
  39195. * @param defines Define statements to be added to the shader.
  39196. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39197. * @param onCompiled Callback that will be called when the shader is compiled.
  39198. * @param onError Callback that will be called if an error occurs during shader compilation.
  39199. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39200. * @param key Effect Key identifying uniquely compiled shader variants
  39201. */
  39202. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any, key?: string);
  39203. private _useFinalCode;
  39204. /**
  39205. * Unique key for this effect
  39206. */
  39207. get key(): string;
  39208. /**
  39209. * If the effect has been compiled and prepared.
  39210. * @returns if the effect is compiled and prepared.
  39211. */
  39212. isReady(): boolean;
  39213. private _isReadyInternal;
  39214. /**
  39215. * The engine the effect was initialized with.
  39216. * @returns the engine.
  39217. */
  39218. getEngine(): Engine;
  39219. /**
  39220. * The pipeline context for this effect
  39221. * @returns the associated pipeline context
  39222. */
  39223. getPipelineContext(): Nullable<IPipelineContext>;
  39224. /**
  39225. * The set of names of attribute variables for the shader.
  39226. * @returns An array of attribute names.
  39227. */
  39228. getAttributesNames(): string[];
  39229. /**
  39230. * Returns the attribute at the given index.
  39231. * @param index The index of the attribute.
  39232. * @returns The location of the attribute.
  39233. */
  39234. getAttributeLocation(index: number): number;
  39235. /**
  39236. * Returns the attribute based on the name of the variable.
  39237. * @param name of the attribute to look up.
  39238. * @returns the attribute location.
  39239. */
  39240. getAttributeLocationByName(name: string): number;
  39241. /**
  39242. * The number of attributes.
  39243. * @returns the number of attributes.
  39244. */
  39245. getAttributesCount(): number;
  39246. /**
  39247. * Gets the index of a uniform variable.
  39248. * @param uniformName of the uniform to look up.
  39249. * @returns the index.
  39250. */
  39251. getUniformIndex(uniformName: string): number;
  39252. /**
  39253. * Returns the attribute based on the name of the variable.
  39254. * @param uniformName of the uniform to look up.
  39255. * @returns the location of the uniform.
  39256. */
  39257. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39258. /**
  39259. * Returns an array of sampler variable names
  39260. * @returns The array of sampler variable names.
  39261. */
  39262. getSamplers(): string[];
  39263. /**
  39264. * Returns an array of uniform variable names
  39265. * @returns The array of uniform variable names.
  39266. */
  39267. getUniformNames(): string[];
  39268. /**
  39269. * Returns an array of uniform buffer variable names
  39270. * @returns The array of uniform buffer variable names.
  39271. */
  39272. getUniformBuffersNames(): string[];
  39273. /**
  39274. * Returns the index parameters used to create the effect
  39275. * @returns The index parameters object
  39276. */
  39277. getIndexParameters(): any;
  39278. /**
  39279. * The error from the last compilation.
  39280. * @returns the error string.
  39281. */
  39282. getCompilationError(): string;
  39283. /**
  39284. * Gets a boolean indicating that all fallbacks were used during compilation
  39285. * @returns true if all fallbacks were used
  39286. */
  39287. allFallbacksProcessed(): boolean;
  39288. /**
  39289. * Adds a callback to the onCompiled observable and call the callback immediately if already ready.
  39290. * @param func The callback to be used.
  39291. */
  39292. executeWhenCompiled(func: (effect: Effect) => void): void;
  39293. private _checkIsReady;
  39294. private _loadShader;
  39295. /**
  39296. * Gets the vertex shader source code of this effect
  39297. */
  39298. get vertexSourceCode(): string;
  39299. /**
  39300. * Gets the fragment shader source code of this effect
  39301. */
  39302. get fragmentSourceCode(): string;
  39303. /**
  39304. * Gets the vertex shader source code before it has been processed by the preprocessor
  39305. */
  39306. get rawVertexSourceCode(): string;
  39307. /**
  39308. * Gets the fragment shader source code before it has been processed by the preprocessor
  39309. */
  39310. get rawFragmentSourceCode(): string;
  39311. /**
  39312. * Recompiles the webGL program
  39313. * @param vertexSourceCode The source code for the vertex shader.
  39314. * @param fragmentSourceCode The source code for the fragment shader.
  39315. * @param onCompiled Callback called when completed.
  39316. * @param onError Callback called on error.
  39317. * @hidden
  39318. */
  39319. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39320. /**
  39321. * Prepares the effect
  39322. * @hidden
  39323. */
  39324. _prepareEffect(): void;
  39325. private _getShaderCodeAndErrorLine;
  39326. private _processCompilationErrors;
  39327. /**
  39328. * Checks if the effect is supported. (Must be called after compilation)
  39329. */
  39330. get isSupported(): boolean;
  39331. /**
  39332. * Binds a texture to the engine to be used as output of the shader.
  39333. * @param channel Name of the output variable.
  39334. * @param texture Texture to bind.
  39335. * @hidden
  39336. */
  39337. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39338. /**
  39339. * Sets a texture on the engine to be used in the shader.
  39340. * @param channel Name of the sampler variable.
  39341. * @param texture Texture to set.
  39342. */
  39343. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39344. /**
  39345. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39346. * @param channel Name of the sampler variable.
  39347. * @param texture Texture to set.
  39348. */
  39349. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39350. /**
  39351. * Sets an array of textures on the engine to be used in the shader.
  39352. * @param channel Name of the variable.
  39353. * @param textures Textures to set.
  39354. */
  39355. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39356. /**
  39357. * 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)
  39358. * @param channel Name of the sampler variable.
  39359. * @param postProcess Post process to get the input texture from.
  39360. */
  39361. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39362. /**
  39363. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39364. * 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)
  39365. * @param channel Name of the sampler variable.
  39366. * @param postProcess Post process to get the output texture from.
  39367. */
  39368. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39369. /**
  39370. * Binds a buffer to a uniform.
  39371. * @param buffer Buffer to bind.
  39372. * @param name Name of the uniform variable to bind to.
  39373. */
  39374. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39375. /**
  39376. * Binds block to a uniform.
  39377. * @param blockName Name of the block to bind.
  39378. * @param index Index to bind.
  39379. */
  39380. bindUniformBlock(blockName: string, index: number): void;
  39381. /**
  39382. * Sets an integer value on a uniform variable.
  39383. * @param uniformName Name of the variable.
  39384. * @param value Value to be set.
  39385. * @returns this effect.
  39386. */
  39387. setInt(uniformName: string, value: number): Effect;
  39388. /**
  39389. * Sets an int2 value on a uniform variable.
  39390. * @param uniformName Name of the variable.
  39391. * @param x First int in int2.
  39392. * @param y Second int in int2.
  39393. * @returns this effect.
  39394. */
  39395. setInt2(uniformName: string, x: number, y: number): Effect;
  39396. /**
  39397. * Sets an int3 value on a uniform variable.
  39398. * @param uniformName Name of the variable.
  39399. * @param x First int in int3.
  39400. * @param y Second int in int3.
  39401. * @param z Third int in int3.
  39402. * @returns this effect.
  39403. */
  39404. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39405. /**
  39406. * Sets an int4 value on a uniform variable.
  39407. * @param uniformName Name of the variable.
  39408. * @param x First int in int4.
  39409. * @param y Second int in int4.
  39410. * @param z Third int in int4.
  39411. * @param w Fourth int in int4.
  39412. * @returns this effect.
  39413. */
  39414. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39415. /**
  39416. * Sets an int array on a uniform variable.
  39417. * @param uniformName Name of the variable.
  39418. * @param array array to be set.
  39419. * @returns this effect.
  39420. */
  39421. setIntArray(uniformName: string, array: Int32Array): Effect;
  39422. /**
  39423. * 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)
  39424. * @param uniformName Name of the variable.
  39425. * @param array array to be set.
  39426. * @returns this effect.
  39427. */
  39428. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39429. /**
  39430. * 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)
  39431. * @param uniformName Name of the variable.
  39432. * @param array array to be set.
  39433. * @returns this effect.
  39434. */
  39435. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39436. /**
  39437. * 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)
  39438. * @param uniformName Name of the variable.
  39439. * @param array array to be set.
  39440. * @returns this effect.
  39441. */
  39442. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39443. /**
  39444. * Sets an float array on a uniform variable.
  39445. * @param uniformName Name of the variable.
  39446. * @param array array to be set.
  39447. * @returns this effect.
  39448. */
  39449. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39450. /**
  39451. * 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)
  39452. * @param uniformName Name of the variable.
  39453. * @param array array to be set.
  39454. * @returns this effect.
  39455. */
  39456. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39457. /**
  39458. * 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)
  39459. * @param uniformName Name of the variable.
  39460. * @param array array to be set.
  39461. * @returns this effect.
  39462. */
  39463. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39464. /**
  39465. * 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)
  39466. * @param uniformName Name of the variable.
  39467. * @param array array to be set.
  39468. * @returns this effect.
  39469. */
  39470. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39471. /**
  39472. * Sets an array on a uniform variable.
  39473. * @param uniformName Name of the variable.
  39474. * @param array array to be set.
  39475. * @returns this effect.
  39476. */
  39477. setArray(uniformName: string, array: number[]): Effect;
  39478. /**
  39479. * 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)
  39480. * @param uniformName Name of the variable.
  39481. * @param array array to be set.
  39482. * @returns this effect.
  39483. */
  39484. setArray2(uniformName: string, array: number[]): Effect;
  39485. /**
  39486. * 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)
  39487. * @param uniformName Name of the variable.
  39488. * @param array array to be set.
  39489. * @returns this effect.
  39490. */
  39491. setArray3(uniformName: string, array: number[]): Effect;
  39492. /**
  39493. * 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)
  39494. * @param uniformName Name of the variable.
  39495. * @param array array to be set.
  39496. * @returns this effect.
  39497. */
  39498. setArray4(uniformName: string, array: number[]): Effect;
  39499. /**
  39500. * Sets matrices on a uniform variable.
  39501. * @param uniformName Name of the variable.
  39502. * @param matrices matrices to be set.
  39503. * @returns this effect.
  39504. */
  39505. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39506. /**
  39507. * Sets matrix on a uniform variable.
  39508. * @param uniformName Name of the variable.
  39509. * @param matrix matrix to be set.
  39510. * @returns this effect.
  39511. */
  39512. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39513. /**
  39514. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  39515. * @param uniformName Name of the variable.
  39516. * @param matrix matrix to be set.
  39517. * @returns this effect.
  39518. */
  39519. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39520. /**
  39521. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39522. * @param uniformName Name of the variable.
  39523. * @param matrix matrix to be set.
  39524. * @returns this effect.
  39525. */
  39526. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39527. /**
  39528. * Sets a float on a uniform variable.
  39529. * @param uniformName Name of the variable.
  39530. * @param value value to be set.
  39531. * @returns this effect.
  39532. */
  39533. setFloat(uniformName: string, value: number): Effect;
  39534. /**
  39535. * Sets a boolean on a uniform variable.
  39536. * @param uniformName Name of the variable.
  39537. * @param bool value to be set.
  39538. * @returns this effect.
  39539. */
  39540. setBool(uniformName: string, bool: boolean): Effect;
  39541. /**
  39542. * Sets a Vector2 on a uniform variable.
  39543. * @param uniformName Name of the variable.
  39544. * @param vector2 vector2 to be set.
  39545. * @returns this effect.
  39546. */
  39547. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39548. /**
  39549. * Sets a float2 on a uniform variable.
  39550. * @param uniformName Name of the variable.
  39551. * @param x First float in float2.
  39552. * @param y Second float in float2.
  39553. * @returns this effect.
  39554. */
  39555. setFloat2(uniformName: string, x: number, y: number): Effect;
  39556. /**
  39557. * Sets a Vector3 on a uniform variable.
  39558. * @param uniformName Name of the variable.
  39559. * @param vector3 Value to be set.
  39560. * @returns this effect.
  39561. */
  39562. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39563. /**
  39564. * Sets a float3 on a uniform variable.
  39565. * @param uniformName Name of the variable.
  39566. * @param x First float in float3.
  39567. * @param y Second float in float3.
  39568. * @param z Third float in float3.
  39569. * @returns this effect.
  39570. */
  39571. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39572. /**
  39573. * Sets a Vector4 on a uniform variable.
  39574. * @param uniformName Name of the variable.
  39575. * @param vector4 Value to be set.
  39576. * @returns this effect.
  39577. */
  39578. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39579. /**
  39580. * Sets a float4 on a uniform variable.
  39581. * @param uniformName Name of the variable.
  39582. * @param x First float in float4.
  39583. * @param y Second float in float4.
  39584. * @param z Third float in float4.
  39585. * @param w Fourth float in float4.
  39586. * @returns this effect.
  39587. */
  39588. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39589. /**
  39590. * Sets a Color3 on a uniform variable.
  39591. * @param uniformName Name of the variable.
  39592. * @param color3 Value to be set.
  39593. * @returns this effect.
  39594. */
  39595. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39596. /**
  39597. * Sets a Color4 on a uniform variable.
  39598. * @param uniformName Name of the variable.
  39599. * @param color3 Value to be set.
  39600. * @param alpha Alpha value to be set.
  39601. * @returns this effect.
  39602. */
  39603. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39604. /**
  39605. * Sets a Color4 on a uniform variable
  39606. * @param uniformName defines the name of the variable
  39607. * @param color4 defines the value to be set
  39608. * @returns this effect.
  39609. */
  39610. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39611. /**
  39612. * Release all associated resources.
  39613. **/
  39614. dispose(): void;
  39615. /**
  39616. * This function will add a new shader to the shader store
  39617. * @param name the name of the shader
  39618. * @param pixelShader optional pixel shader content
  39619. * @param vertexShader optional vertex shader content
  39620. */
  39621. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39622. /**
  39623. * Store of each shader (The can be looked up using effect.key)
  39624. */
  39625. static ShadersStore: {
  39626. [key: string]: string;
  39627. };
  39628. /**
  39629. * Store of each included file for a shader (The can be looked up using effect.key)
  39630. */
  39631. static IncludesShadersStore: {
  39632. [key: string]: string;
  39633. };
  39634. /**
  39635. * Resets the cache of effects.
  39636. */
  39637. static ResetCache(): void;
  39638. }
  39639. }
  39640. declare module BABYLON {
  39641. /**
  39642. * Interface used to describe the capabilities of the engine relatively to the current browser
  39643. */
  39644. export interface EngineCapabilities {
  39645. /** Maximum textures units per fragment shader */
  39646. maxTexturesImageUnits: number;
  39647. /** Maximum texture units per vertex shader */
  39648. maxVertexTextureImageUnits: number;
  39649. /** Maximum textures units in the entire pipeline */
  39650. maxCombinedTexturesImageUnits: number;
  39651. /** Maximum texture size */
  39652. maxTextureSize: number;
  39653. /** Maximum texture samples */
  39654. maxSamples?: number;
  39655. /** Maximum cube texture size */
  39656. maxCubemapTextureSize: number;
  39657. /** Maximum render texture size */
  39658. maxRenderTextureSize: number;
  39659. /** Maximum number of vertex attributes */
  39660. maxVertexAttribs: number;
  39661. /** Maximum number of varyings */
  39662. maxVaryingVectors: number;
  39663. /** Maximum number of uniforms per vertex shader */
  39664. maxVertexUniformVectors: number;
  39665. /** Maximum number of uniforms per fragment shader */
  39666. maxFragmentUniformVectors: number;
  39667. /** Defines if standard derivatives (dx/dy) are supported */
  39668. standardDerivatives: boolean;
  39669. /** Defines if s3tc texture compression is supported */
  39670. s3tc?: WEBGL_compressed_texture_s3tc;
  39671. /** Defines if pvrtc texture compression is supported */
  39672. pvrtc: any;
  39673. /** Defines if etc1 texture compression is supported */
  39674. etc1: any;
  39675. /** Defines if etc2 texture compression is supported */
  39676. etc2: any;
  39677. /** Defines if astc texture compression is supported */
  39678. astc: any;
  39679. /** Defines if bptc texture compression is supported */
  39680. bptc: any;
  39681. /** Defines if float textures are supported */
  39682. textureFloat: boolean;
  39683. /** Defines if vertex array objects are supported */
  39684. vertexArrayObject: boolean;
  39685. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39686. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39687. /** Gets the maximum level of anisotropy supported */
  39688. maxAnisotropy: number;
  39689. /** Defines if instancing is supported */
  39690. instancedArrays: boolean;
  39691. /** Defines if 32 bits indices are supported */
  39692. uintIndices: boolean;
  39693. /** Defines if high precision shaders are supported */
  39694. highPrecisionShaderSupported: boolean;
  39695. /** Defines if depth reading in the fragment shader is supported */
  39696. fragmentDepthSupported: boolean;
  39697. /** Defines if float texture linear filtering is supported*/
  39698. textureFloatLinearFiltering: boolean;
  39699. /** Defines if rendering to float textures is supported */
  39700. textureFloatRender: boolean;
  39701. /** Defines if half float textures are supported*/
  39702. textureHalfFloat: boolean;
  39703. /** Defines if half float texture linear filtering is supported*/
  39704. textureHalfFloatLinearFiltering: boolean;
  39705. /** Defines if rendering to half float textures is supported */
  39706. textureHalfFloatRender: boolean;
  39707. /** Defines if textureLOD shader command is supported */
  39708. textureLOD: boolean;
  39709. /** Defines if draw buffers extension is supported */
  39710. drawBuffersExtension: boolean;
  39711. /** Defines if depth textures are supported */
  39712. depthTextureExtension: boolean;
  39713. /** Defines if float color buffer are supported */
  39714. colorBufferFloat: boolean;
  39715. /** Gets disjoint timer query extension (null if not supported) */
  39716. timerQuery?: EXT_disjoint_timer_query;
  39717. /** Defines if timestamp can be used with timer query */
  39718. canUseTimestampForTimerQuery: boolean;
  39719. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39720. multiview?: any;
  39721. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39722. oculusMultiview?: any;
  39723. /** Function used to let the system compiles shaders in background */
  39724. parallelShaderCompile?: {
  39725. COMPLETION_STATUS_KHR: number;
  39726. };
  39727. /** Max number of texture samples for MSAA */
  39728. maxMSAASamples: number;
  39729. /** Defines if the blend min max extension is supported */
  39730. blendMinMax: boolean;
  39731. /** In some iOS + WebGL1, gl_InstanceID (and gl_InstanceIDEXT) is undefined even if instancedArrays is true. So don't use gl_InstanceID in those cases */
  39732. canUseGLInstanceID: boolean;
  39733. }
  39734. }
  39735. declare module BABYLON {
  39736. /**
  39737. * @hidden
  39738. **/
  39739. export class DepthCullingState {
  39740. private _isDepthTestDirty;
  39741. private _isDepthMaskDirty;
  39742. private _isDepthFuncDirty;
  39743. private _isCullFaceDirty;
  39744. private _isCullDirty;
  39745. private _isZOffsetDirty;
  39746. private _isFrontFaceDirty;
  39747. private _depthTest;
  39748. private _depthMask;
  39749. private _depthFunc;
  39750. private _cull;
  39751. private _cullFace;
  39752. private _zOffset;
  39753. private _frontFace;
  39754. /**
  39755. * Initializes the state.
  39756. */
  39757. constructor();
  39758. get isDirty(): boolean;
  39759. get zOffset(): number;
  39760. set zOffset(value: number);
  39761. get cullFace(): Nullable<number>;
  39762. set cullFace(value: Nullable<number>);
  39763. get cull(): Nullable<boolean>;
  39764. set cull(value: Nullable<boolean>);
  39765. get depthFunc(): Nullable<number>;
  39766. set depthFunc(value: Nullable<number>);
  39767. get depthMask(): boolean;
  39768. set depthMask(value: boolean);
  39769. get depthTest(): boolean;
  39770. set depthTest(value: boolean);
  39771. get frontFace(): Nullable<number>;
  39772. set frontFace(value: Nullable<number>);
  39773. reset(): void;
  39774. apply(gl: WebGLRenderingContext): void;
  39775. }
  39776. }
  39777. declare module BABYLON {
  39778. /**
  39779. * @hidden
  39780. **/
  39781. export class StencilState {
  39782. /** 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 */
  39783. static readonly ALWAYS: number;
  39784. /** Passed to stencilOperation to specify that stencil value must be kept */
  39785. static readonly KEEP: number;
  39786. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39787. static readonly REPLACE: number;
  39788. private _isStencilTestDirty;
  39789. private _isStencilMaskDirty;
  39790. private _isStencilFuncDirty;
  39791. private _isStencilOpDirty;
  39792. private _stencilTest;
  39793. private _stencilMask;
  39794. private _stencilFunc;
  39795. private _stencilFuncRef;
  39796. private _stencilFuncMask;
  39797. private _stencilOpStencilFail;
  39798. private _stencilOpDepthFail;
  39799. private _stencilOpStencilDepthPass;
  39800. get isDirty(): boolean;
  39801. get stencilFunc(): number;
  39802. set stencilFunc(value: number);
  39803. get stencilFuncRef(): number;
  39804. set stencilFuncRef(value: number);
  39805. get stencilFuncMask(): number;
  39806. set stencilFuncMask(value: number);
  39807. get stencilOpStencilFail(): number;
  39808. set stencilOpStencilFail(value: number);
  39809. get stencilOpDepthFail(): number;
  39810. set stencilOpDepthFail(value: number);
  39811. get stencilOpStencilDepthPass(): number;
  39812. set stencilOpStencilDepthPass(value: number);
  39813. get stencilMask(): number;
  39814. set stencilMask(value: number);
  39815. get stencilTest(): boolean;
  39816. set stencilTest(value: boolean);
  39817. constructor();
  39818. reset(): void;
  39819. apply(gl: WebGLRenderingContext): void;
  39820. }
  39821. }
  39822. declare module BABYLON {
  39823. /**
  39824. * @hidden
  39825. **/
  39826. export class AlphaState {
  39827. _blendFunctionParameters: Nullable<number>[];
  39828. _blendEquationParameters: Nullable<number>[];
  39829. _blendConstants: Nullable<number>[];
  39830. _isBlendConstantsDirty: boolean;
  39831. private _alphaBlend;
  39832. private _isAlphaBlendDirty;
  39833. private _isBlendFunctionParametersDirty;
  39834. private _isBlendEquationParametersDirty;
  39835. /**
  39836. * Initializes the state.
  39837. */
  39838. constructor();
  39839. get isDirty(): boolean;
  39840. get alphaBlend(): boolean;
  39841. set alphaBlend(value: boolean);
  39842. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39843. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39844. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39845. reset(): void;
  39846. apply(gl: WebGLRenderingContext): void;
  39847. }
  39848. }
  39849. declare module BABYLON {
  39850. /** @hidden */
  39851. export class WebGLShaderProcessor implements IShaderProcessor {
  39852. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39853. }
  39854. }
  39855. declare module BABYLON {
  39856. /** @hidden */
  39857. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39858. attributeProcessor(attribute: string): string;
  39859. varyingProcessor(varying: string, isFragment: boolean): string;
  39860. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39861. }
  39862. }
  39863. declare module BABYLON {
  39864. /**
  39865. * Interface for attribute information associated with buffer instantiation
  39866. */
  39867. export interface InstancingAttributeInfo {
  39868. /**
  39869. * Name of the GLSL attribute
  39870. * if attribute index is not specified, this is used to retrieve the index from the effect
  39871. */
  39872. attributeName: string;
  39873. /**
  39874. * Index/offset of the attribute in the vertex shader
  39875. * if not specified, this will be computes from the name.
  39876. */
  39877. index?: number;
  39878. /**
  39879. * size of the attribute, 1, 2, 3 or 4
  39880. */
  39881. attributeSize: number;
  39882. /**
  39883. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39884. */
  39885. offset: number;
  39886. /**
  39887. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39888. * default to 1
  39889. */
  39890. divisor?: number;
  39891. /**
  39892. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39893. * default is FLOAT
  39894. */
  39895. attributeType?: number;
  39896. /**
  39897. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39898. */
  39899. normalized?: boolean;
  39900. }
  39901. }
  39902. declare module BABYLON {
  39903. /** @hidden */
  39904. export interface EngineFeatures {
  39905. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39906. forceBitmapOverHTMLImageElement: boolean;
  39907. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  39908. supportRenderAndCopyToLodForFloatTextures: boolean;
  39909. /** Indicates that the engine support handling depth/stencil textures */
  39910. supportDepthStencilTexture: boolean;
  39911. /** Indicates that the engine support shadow samplers */
  39912. supportShadowSamplers: boolean;
  39913. /** Indicates to check the matrix bytes per bytes to know if it has changed or not. If false, only the updateFlag of the matrix is checked */
  39914. uniformBufferHardCheckMatrix: boolean;
  39915. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  39916. allowTexturePrefiltering: boolean;
  39917. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  39918. trackUbosInFrame: boolean;
  39919. /** Indicates that the Cascaded Shadow Map technic is supported */
  39920. supportCSM: boolean;
  39921. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  39922. basisNeedsPOT: boolean;
  39923. /** Indicates that the engine supports 3D textures */
  39924. support3DTextures: boolean;
  39925. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  39926. needTypeSuffixInShaderConstants: boolean;
  39927. /** Indicates that MSAA is supported */
  39928. supportMSAA: boolean;
  39929. /** Indicates that SSAO2 is supported */
  39930. supportSSAO2: boolean;
  39931. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  39932. supportExtendedTextureFormats: boolean;
  39933. /** Indicates that the switch/case construct is supported in shaders */
  39934. supportSwitchCaseInShader: boolean;
  39935. /** Indicates that synchronous texture reading is supported */
  39936. supportSyncTextureRead: boolean;
  39937. /** @hidden */
  39938. _collectUbosUpdatedInFrame: boolean;
  39939. }
  39940. }
  39941. declare module BABYLON {
  39942. /** @hidden */
  39943. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  39944. private _webGLTexture;
  39945. private _context;
  39946. get underlyingResource(): Nullable<WebGLTexture>;
  39947. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  39948. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  39949. set(hardwareTexture: WebGLTexture): void;
  39950. reset(): void;
  39951. release(): void;
  39952. }
  39953. }
  39954. declare module BABYLON {
  39955. interface ThinEngine {
  39956. /**
  39957. * Update a video texture
  39958. * @param texture defines the texture to update
  39959. * @param video defines the video element to use
  39960. * @param invertY defines if data must be stored with Y axis inverted
  39961. */
  39962. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39963. }
  39964. }
  39965. declare module BABYLON {
  39966. interface ThinEngine {
  39967. /**
  39968. * Creates a dynamic texture
  39969. * @param width defines the width of the texture
  39970. * @param height defines the height of the texture
  39971. * @param generateMipMaps defines if the engine should generate the mip levels
  39972. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39973. * @returns the dynamic texture inside an InternalTexture
  39974. */
  39975. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39976. /**
  39977. * Update the content of a dynamic texture
  39978. * @param texture defines the texture to update
  39979. * @param source defines the source containing the data
  39980. * @param invertY defines if data must be stored with Y axis inverted
  39981. * @param premulAlpha defines if alpha is stored as premultiplied
  39982. * @param format defines the format of the data
  39983. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39984. */
  39985. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39986. }
  39987. }
  39988. declare module BABYLON {
  39989. /**
  39990. * Settings for finer control over video usage
  39991. */
  39992. export interface VideoTextureSettings {
  39993. /**
  39994. * Applies `autoplay` to video, if specified
  39995. */
  39996. autoPlay?: boolean;
  39997. /**
  39998. * Applies `muted` to video, if specified
  39999. */
  40000. muted?: boolean;
  40001. /**
  40002. * Applies `loop` to video, if specified
  40003. */
  40004. loop?: boolean;
  40005. /**
  40006. * Automatically updates internal texture from video at every frame in the render loop
  40007. */
  40008. autoUpdateTexture: boolean;
  40009. /**
  40010. * Image src displayed during the video loading or until the user interacts with the video.
  40011. */
  40012. poster?: string;
  40013. }
  40014. /**
  40015. * If you want to display a video in your scene, this is the special texture for that.
  40016. * This special texture works similar to other textures, with the exception of a few parameters.
  40017. * @see https://doc.babylonjs.com/how_to/video_texture
  40018. */
  40019. export class VideoTexture extends Texture {
  40020. /**
  40021. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40022. */
  40023. readonly autoUpdateTexture: boolean;
  40024. /**
  40025. * The video instance used by the texture internally
  40026. */
  40027. readonly video: HTMLVideoElement;
  40028. private _onUserActionRequestedObservable;
  40029. /**
  40030. * Event triggered when a dom action is required by the user to play the video.
  40031. * This happens due to recent changes in browser policies preventing video to auto start.
  40032. */
  40033. get onUserActionRequestedObservable(): Observable<Texture>;
  40034. private _generateMipMaps;
  40035. private _stillImageCaptured;
  40036. private _displayingPosterTexture;
  40037. private _settings;
  40038. private _createInternalTextureOnEvent;
  40039. private _frameId;
  40040. private _currentSrc;
  40041. /**
  40042. * Creates a video texture.
  40043. * If you want to display a video in your scene, this is the special texture for that.
  40044. * This special texture works similar to other textures, with the exception of a few parameters.
  40045. * @see https://doc.babylonjs.com/how_to/video_texture
  40046. * @param name optional name, will detect from video source, if not defined
  40047. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40048. * @param scene is obviously the current scene.
  40049. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40050. * @param invertY is false by default but can be used to invert video on Y axis
  40051. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40052. * @param settings allows finer control over video usage
  40053. */
  40054. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40055. private _getName;
  40056. private _getVideo;
  40057. private _createInternalTexture;
  40058. private reset;
  40059. /**
  40060. * @hidden Internal method to initiate `update`.
  40061. */
  40062. _rebuild(): void;
  40063. /**
  40064. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40065. */
  40066. update(): void;
  40067. /**
  40068. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40069. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.
  40070. */
  40071. updateTexture(isVisible: boolean): void;
  40072. protected _updateInternalTexture: () => void;
  40073. /**
  40074. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40075. * @param url New url.
  40076. */
  40077. updateURL(url: string): void;
  40078. /**
  40079. * Clones the texture.
  40080. * @returns the cloned texture
  40081. */
  40082. clone(): VideoTexture;
  40083. /**
  40084. * Dispose the texture and release its associated resources.
  40085. */
  40086. dispose(): void;
  40087. /**
  40088. * Creates a video texture straight from a stream.
  40089. * @param scene Define the scene the texture should be created in
  40090. * @param stream Define the stream the texture should be created from
  40091. * @returns The created video texture as a promise
  40092. */
  40093. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40094. /**
  40095. * Creates a video texture straight from your WebCam video feed.
  40096. * @param scene Define the scene the texture should be created in
  40097. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40098. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40099. * @returns The created video texture as a promise
  40100. */
  40101. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40102. minWidth: number;
  40103. maxWidth: number;
  40104. minHeight: number;
  40105. maxHeight: number;
  40106. deviceId: string;
  40107. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40108. /**
  40109. * Creates a video texture straight from your WebCam video feed.
  40110. * @param scene Define the scene the texture should be created in
  40111. * @param onReady Define a callback to triggered once the texture will be ready
  40112. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40113. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40114. */
  40115. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40116. minWidth: number;
  40117. maxWidth: number;
  40118. minHeight: number;
  40119. maxHeight: number;
  40120. deviceId: string;
  40121. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40122. }
  40123. }
  40124. declare module BABYLON {
  40125. /**
  40126. * Defines the interface used by objects working like Scene
  40127. * @hidden
  40128. */
  40129. export interface ISceneLike {
  40130. _addPendingData(data: any): void;
  40131. _removePendingData(data: any): void;
  40132. offlineProvider: IOfflineProvider;
  40133. }
  40134. /**
  40135. * Information about the current host
  40136. */
  40137. export interface HostInformation {
  40138. /**
  40139. * Defines if the current host is a mobile
  40140. */
  40141. isMobile: boolean;
  40142. }
  40143. /** Interface defining initialization parameters for Engine class */
  40144. export interface EngineOptions extends WebGLContextAttributes {
  40145. /**
  40146. * Defines if the engine should no exceed a specified device ratio
  40147. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40148. */
  40149. limitDeviceRatio?: number;
  40150. /**
  40151. * Defines if webvr should be enabled automatically
  40152. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40153. */
  40154. autoEnableWebVR?: boolean;
  40155. /**
  40156. * Defines if webgl2 should be turned off even if supported
  40157. * @see https://doc.babylonjs.com/features/webgl2
  40158. */
  40159. disableWebGL2Support?: boolean;
  40160. /**
  40161. * Defines if webaudio should be initialized as well
  40162. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40163. */
  40164. audioEngine?: boolean;
  40165. /**
  40166. * Defines if animations should run using a deterministic lock step
  40167. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40168. */
  40169. deterministicLockstep?: boolean;
  40170. /** Defines the maximum steps to use with deterministic lock step mode */
  40171. lockstepMaxSteps?: number;
  40172. /** Defines the seconds between each deterministic lock step */
  40173. timeStep?: number;
  40174. /**
  40175. * Defines that engine should ignore context lost events
  40176. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40177. */
  40178. doNotHandleContextLost?: boolean;
  40179. /**
  40180. * Defines that engine should ignore modifying touch action attribute and style
  40181. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40182. */
  40183. doNotHandleTouchAction?: boolean;
  40184. /**
  40185. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40186. */
  40187. useHighPrecisionFloats?: boolean;
  40188. /**
  40189. * Make the canvas XR Compatible for XR sessions
  40190. */
  40191. xrCompatible?: boolean;
  40192. /**
  40193. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40194. */
  40195. useHighPrecisionMatrix?: boolean;
  40196. /**
  40197. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40198. */
  40199. failIfMajorPerformanceCaveat?: boolean;
  40200. /**
  40201. * Defines whether to adapt to the device's viewport characteristics (default: false)
  40202. */
  40203. adaptToDeviceRatio?: boolean;
  40204. }
  40205. /**
  40206. * The base engine class (root of all engines)
  40207. */
  40208. export class ThinEngine {
  40209. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40210. static ExceptionList: ({
  40211. key: string;
  40212. capture: string;
  40213. captureConstraint: number;
  40214. targets: string[];
  40215. } | {
  40216. key: string;
  40217. capture: null;
  40218. captureConstraint: null;
  40219. targets: string[];
  40220. })[];
  40221. /** @hidden */
  40222. static _TextureLoaders: IInternalTextureLoader[];
  40223. /**
  40224. * Returns the current npm package of the sdk
  40225. */
  40226. static get NpmPackage(): string;
  40227. /**
  40228. * Returns the current version of the framework
  40229. */
  40230. static get Version(): string;
  40231. /**
  40232. * Returns a string describing the current engine
  40233. */
  40234. get description(): string;
  40235. /**
  40236. * Returns the name of the engine
  40237. */
  40238. get name(): string;
  40239. /**
  40240. * Returns the version of the engine
  40241. */
  40242. get version(): number;
  40243. /**
  40244. * Gets or sets the epsilon value used by collision engine
  40245. */
  40246. static CollisionsEpsilon: number;
  40247. /**
  40248. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40249. */
  40250. static get ShadersRepository(): string;
  40251. static set ShadersRepository(value: string);
  40252. /** @hidden */
  40253. _shaderProcessor: Nullable<IShaderProcessor>;
  40254. /**
  40255. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40256. */
  40257. forcePOTTextures: boolean;
  40258. /**
  40259. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40260. */
  40261. isFullscreen: boolean;
  40262. /**
  40263. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40264. */
  40265. cullBackFaces: boolean;
  40266. /**
  40267. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40268. */
  40269. renderEvenInBackground: boolean;
  40270. /**
  40271. * Gets or sets a boolean indicating that cache can be kept between frames
  40272. */
  40273. preventCacheWipeBetweenFrames: boolean;
  40274. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40275. validateShaderPrograms: boolean;
  40276. /**
  40277. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40278. * This can provide greater z depth for distant objects.
  40279. */
  40280. useReverseDepthBuffer: boolean;
  40281. /**
  40282. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40283. */
  40284. disableUniformBuffers: boolean;
  40285. private _frameId;
  40286. /**
  40287. * Gets the current frame id
  40288. */
  40289. get frameId(): number;
  40290. /** @hidden */
  40291. _uniformBuffers: UniformBuffer[];
  40292. /**
  40293. * Gets a boolean indicating that the engine supports uniform buffers
  40294. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40295. */
  40296. get supportsUniformBuffers(): boolean;
  40297. /** @hidden */
  40298. _gl: WebGLRenderingContext;
  40299. /** @hidden */
  40300. _webGLVersion: number;
  40301. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40302. protected _windowIsBackground: boolean;
  40303. protected _creationOptions: EngineOptions;
  40304. protected _highPrecisionShadersAllowed: boolean;
  40305. /** @hidden */
  40306. get _shouldUseHighPrecisionShader(): boolean;
  40307. /**
  40308. * Gets a boolean indicating that only power of 2 textures are supported
  40309. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40310. */
  40311. get needPOTTextures(): boolean;
  40312. /** @hidden */
  40313. _badOS: boolean;
  40314. /** @hidden */
  40315. _badDesktopOS: boolean;
  40316. protected _hardwareScalingLevel: number;
  40317. /** @hidden */
  40318. _caps: EngineCapabilities;
  40319. /** @hidden */
  40320. _features: EngineFeatures;
  40321. protected _isStencilEnable: boolean;
  40322. private _glVersion;
  40323. private _glRenderer;
  40324. private _glVendor;
  40325. /** @hidden */
  40326. _videoTextureSupported: boolean;
  40327. protected _renderingQueueLaunched: boolean;
  40328. protected _activeRenderLoops: (() => void)[];
  40329. /**
  40330. * Observable signaled when a context lost event is raised
  40331. */
  40332. onContextLostObservable: Observable<ThinEngine>;
  40333. /**
  40334. * Observable signaled when a context restored event is raised
  40335. */
  40336. onContextRestoredObservable: Observable<ThinEngine>;
  40337. private _onContextLost;
  40338. private _onContextRestored;
  40339. protected _contextWasLost: boolean;
  40340. /** @hidden */
  40341. _doNotHandleContextLost: boolean;
  40342. /**
  40343. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40344. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40345. */
  40346. get doNotHandleContextLost(): boolean;
  40347. set doNotHandleContextLost(value: boolean);
  40348. /**
  40349. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40350. */
  40351. disableVertexArrayObjects: boolean;
  40352. /** @hidden */
  40353. protected _colorWrite: boolean;
  40354. /** @hidden */
  40355. protected _colorWriteChanged: boolean;
  40356. /** @hidden */
  40357. protected _depthCullingState: DepthCullingState;
  40358. /** @hidden */
  40359. protected _stencilState: StencilState;
  40360. /** @hidden */
  40361. _alphaState: AlphaState;
  40362. /** @hidden */
  40363. _alphaMode: number;
  40364. /** @hidden */
  40365. _alphaEquation: number;
  40366. /** @hidden */
  40367. _internalTexturesCache: InternalTexture[];
  40368. /** @hidden */
  40369. protected _activeChannel: number;
  40370. private _currentTextureChannel;
  40371. /** @hidden */
  40372. protected _boundTexturesCache: {
  40373. [key: string]: Nullable<InternalTexture>;
  40374. };
  40375. /** @hidden */
  40376. protected _currentEffect: Nullable<Effect>;
  40377. /** @hidden */
  40378. protected _currentProgram: Nullable<WebGLProgram>;
  40379. protected _compiledEffects: {
  40380. [key: string]: Effect;
  40381. };
  40382. private _vertexAttribArraysEnabled;
  40383. /** @hidden */
  40384. protected _cachedViewport: Nullable<IViewportLike>;
  40385. private _cachedVertexArrayObject;
  40386. /** @hidden */
  40387. protected _cachedVertexBuffers: any;
  40388. /** @hidden */
  40389. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40390. /** @hidden */
  40391. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40392. /** @hidden */
  40393. _currentRenderTarget: Nullable<InternalTexture>;
  40394. private _uintIndicesCurrentlySet;
  40395. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40396. /** @hidden */
  40397. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40398. /** @hidden */
  40399. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40400. private _currentBufferPointers;
  40401. private _currentInstanceLocations;
  40402. private _currentInstanceBuffers;
  40403. private _textureUnits;
  40404. /** @hidden */
  40405. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40406. /** @hidden */
  40407. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40408. /** @hidden */
  40409. _boundRenderFunction: any;
  40410. private _vaoRecordInProgress;
  40411. private _mustWipeVertexAttributes;
  40412. private _emptyTexture;
  40413. private _emptyCubeTexture;
  40414. private _emptyTexture3D;
  40415. private _emptyTexture2DArray;
  40416. /** @hidden */
  40417. _frameHandler: number;
  40418. private _nextFreeTextureSlots;
  40419. private _maxSimultaneousTextures;
  40420. private _activeRequests;
  40421. /** @hidden */
  40422. _transformTextureUrl: Nullable<(url: string) => string>;
  40423. /**
  40424. * Gets information about the current host
  40425. */
  40426. hostInformation: HostInformation;
  40427. protected get _supportsHardwareTextureRescaling(): boolean;
  40428. private _framebufferDimensionsObject;
  40429. /**
  40430. * sets the object from which width and height will be taken from when getting render width and height
  40431. * Will fallback to the gl object
  40432. * @param dimensions the framebuffer width and height that will be used.
  40433. */
  40434. set framebufferDimensionsObject(dimensions: Nullable<{
  40435. framebufferWidth: number;
  40436. framebufferHeight: number;
  40437. }>);
  40438. /**
  40439. * Gets the current viewport
  40440. */
  40441. get currentViewport(): Nullable<IViewportLike>;
  40442. /**
  40443. * Gets the default empty texture
  40444. */
  40445. get emptyTexture(): InternalTexture;
  40446. /**
  40447. * Gets the default empty 3D texture
  40448. */
  40449. get emptyTexture3D(): InternalTexture;
  40450. /**
  40451. * Gets the default empty 2D array texture
  40452. */
  40453. get emptyTexture2DArray(): InternalTexture;
  40454. /**
  40455. * Gets the default empty cube texture
  40456. */
  40457. get emptyCubeTexture(): InternalTexture;
  40458. /**
  40459. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40460. */
  40461. premultipliedAlpha: boolean;
  40462. /**
  40463. * Observable event triggered before each texture is initialized
  40464. */
  40465. onBeforeTextureInitObservable: Observable<Texture>;
  40466. /** @hidden */
  40467. protected _isWebGPU: boolean;
  40468. /**
  40469. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40470. */
  40471. get isWebGPU(): boolean;
  40472. /** @hidden */
  40473. protected _shaderPlatformName: string;
  40474. /**
  40475. * Gets the shader platfrom name used by the effects.
  40476. */
  40477. get shaderPlatformName(): string;
  40478. /**
  40479. * Creates a new engine
  40480. * @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
  40481. * @param antialias defines enable antialiasing (default: false)
  40482. * @param options defines further options to be sent to the getContext() function
  40483. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40484. */
  40485. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40486. /**
  40487. * @hidden
  40488. */
  40489. _debugPushGroup(groupName: string, targetObject?: number): void;
  40490. /**
  40491. * @hidden
  40492. */
  40493. _debugPopGroup(targetObject?: number): void;
  40494. /**
  40495. * @hidden
  40496. */
  40497. _debugInsertMarker(text: string, targetObject?: number): void;
  40498. /**
  40499. * Shared initialization across engines types.
  40500. * @param canvas The canvas associated with this instance of the engine.
  40501. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40502. * @param audioEngine Defines if an audio engine should be created by default
  40503. */
  40504. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40505. /**
  40506. * Gets a shader processor implementation fitting with the current engine type.
  40507. * @returns The shader processor implementation.
  40508. */
  40509. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40510. /** @hidden */
  40511. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40512. private _rebuildInternalTextures;
  40513. private _rebuildEffects;
  40514. /**
  40515. * Gets a boolean indicating if all created effects are ready
  40516. * @returns true if all effects are ready
  40517. */
  40518. areAllEffectsReady(): boolean;
  40519. protected _rebuildBuffers(): void;
  40520. protected _initGLContext(): void;
  40521. protected _initFeatures(): void;
  40522. /**
  40523. * Gets version of the current webGL context
  40524. * Keep it for back compat - use version instead
  40525. */
  40526. get webGLVersion(): number;
  40527. /**
  40528. * Gets a string identifying the name of the class
  40529. * @returns "Engine" string
  40530. */
  40531. getClassName(): string;
  40532. /**
  40533. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40534. */
  40535. get isStencilEnable(): boolean;
  40536. /** @hidden */
  40537. _prepareWorkingCanvas(): void;
  40538. /**
  40539. * Reset the texture cache to empty state
  40540. */
  40541. resetTextureCache(): void;
  40542. /**
  40543. * Gets an object containing information about the current webGL context
  40544. * @returns an object containing the vendor, the renderer and the version of the current webGL context
  40545. */
  40546. getGlInfo(): {
  40547. vendor: string;
  40548. renderer: string;
  40549. version: string;
  40550. };
  40551. /**
  40552. * Defines the hardware scaling level.
  40553. * By default the hardware scaling level is computed from the window device ratio.
  40554. * 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.
  40555. * @param level defines the level to use
  40556. */
  40557. setHardwareScalingLevel(level: number): void;
  40558. /**
  40559. * Gets the current hardware scaling level.
  40560. * By default the hardware scaling level is computed from the window device ratio.
  40561. * 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.
  40562. * @returns a number indicating the current hardware scaling level
  40563. */
  40564. getHardwareScalingLevel(): number;
  40565. /**
  40566. * Gets the list of loaded textures
  40567. * @returns an array containing all loaded textures
  40568. */
  40569. getLoadedTexturesCache(): InternalTexture[];
  40570. /**
  40571. * Gets the object containing all engine capabilities
  40572. * @returns the EngineCapabilities object
  40573. */
  40574. getCaps(): EngineCapabilities;
  40575. /**
  40576. * stop executing a render loop function and remove it from the execution array
  40577. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40578. */
  40579. stopRenderLoop(renderFunction?: () => void): void;
  40580. /** @hidden */
  40581. _renderLoop(): void;
  40582. /**
  40583. * Gets the HTML canvas attached with the current webGL context
  40584. * @returns a HTML canvas
  40585. */
  40586. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40587. /**
  40588. * Gets host window
  40589. * @returns the host window object
  40590. */
  40591. getHostWindow(): Nullable<Window>;
  40592. /**
  40593. * Gets the current render width
  40594. * @param useScreen defines if screen size must be used (or the current render target if any)
  40595. * @returns a number defining the current render width
  40596. */
  40597. getRenderWidth(useScreen?: boolean): number;
  40598. /**
  40599. * Gets the current render height
  40600. * @param useScreen defines if screen size must be used (or the current render target if any)
  40601. * @returns a number defining the current render height
  40602. */
  40603. getRenderHeight(useScreen?: boolean): number;
  40604. /**
  40605. * Can be used to override the current requestAnimationFrame requester.
  40606. * @hidden
  40607. */
  40608. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40609. /**
  40610. * Register and execute a render loop. The engine can have more than one render function
  40611. * @param renderFunction defines the function to continuously execute
  40612. */
  40613. runRenderLoop(renderFunction: () => void): void;
  40614. /**
  40615. * Clear the current render buffer or the current render target (if any is set up)
  40616. * @param color defines the color to use
  40617. * @param backBuffer defines if the back buffer must be cleared
  40618. * @param depth defines if the depth buffer must be cleared
  40619. * @param stencil defines if the stencil buffer must be cleared
  40620. */
  40621. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40622. protected _viewportCached: {
  40623. x: number;
  40624. y: number;
  40625. z: number;
  40626. w: number;
  40627. };
  40628. /** @hidden */
  40629. _viewport(x: number, y: number, width: number, height: number): void;
  40630. /**
  40631. * Set the WebGL's viewport
  40632. * @param viewport defines the viewport element to be used
  40633. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40634. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40635. */
  40636. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40637. /**
  40638. * Begin a new frame
  40639. */
  40640. beginFrame(): void;
  40641. /**
  40642. * Enf the current frame
  40643. */
  40644. endFrame(): void;
  40645. /**
  40646. * Resize the view according to the canvas' size
  40647. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40648. */
  40649. resize(forceSetSize?: boolean): void;
  40650. /**
  40651. * Force a specific size of the canvas
  40652. * @param width defines the new canvas' width
  40653. * @param height defines the new canvas' height
  40654. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40655. * @returns true if the size was changed
  40656. */
  40657. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40658. /**
  40659. * Binds the frame buffer to the specified texture.
  40660. * @param texture The texture to render to or null for the default canvas
  40661. * @param faceIndex The face of the texture to render to in case of cube texture
  40662. * @param requiredWidth The width of the target to render to
  40663. * @param requiredHeight The height of the target to render to
  40664. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40665. * @param lodLevel defines the lod level to bind to the frame buffer
  40666. * @param layer defines the 2d array index to bind to frame buffer to
  40667. */
  40668. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40669. /** @hidden */
  40670. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40671. /**
  40672. * Unbind the current render target texture from the webGL context
  40673. * @param texture defines the render target texture to unbind
  40674. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40675. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40676. */
  40677. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40678. /**
  40679. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40680. */
  40681. flushFramebuffer(): void;
  40682. /**
  40683. * Unbind the current render target and bind the default framebuffer
  40684. */
  40685. restoreDefaultFramebuffer(): void;
  40686. /** @hidden */
  40687. protected _resetVertexBufferBinding(): void;
  40688. /**
  40689. * Creates a vertex buffer
  40690. * @param data the data for the vertex buffer
  40691. * @returns the new WebGL static buffer
  40692. */
  40693. createVertexBuffer(data: DataArray): DataBuffer;
  40694. private _createVertexBuffer;
  40695. /**
  40696. * Creates a dynamic vertex buffer
  40697. * @param data the data for the dynamic vertex buffer
  40698. * @returns the new WebGL dynamic buffer
  40699. */
  40700. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40701. protected _resetIndexBufferBinding(): void;
  40702. /**
  40703. * Creates a new index buffer
  40704. * @param indices defines the content of the index buffer
  40705. * @param updatable defines if the index buffer must be updatable
  40706. * @returns a new webGL buffer
  40707. */
  40708. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40709. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40710. /**
  40711. * Bind a webGL buffer to the webGL context
  40712. * @param buffer defines the buffer to bind
  40713. */
  40714. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40715. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40716. private bindBuffer;
  40717. /**
  40718. * update the bound buffer with the given data
  40719. * @param data defines the data to update
  40720. */
  40721. updateArrayBuffer(data: Float32Array): void;
  40722. private _vertexAttribPointer;
  40723. /** @hidden */
  40724. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40725. private _bindVertexBuffersAttributes;
  40726. /**
  40727. * Records a vertex array object
  40728. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40729. * @param vertexBuffers defines the list of vertex buffers to store
  40730. * @param indexBuffer defines the index buffer to store
  40731. * @param effect defines the effect to store
  40732. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40733. * @returns the new vertex array object
  40734. */
  40735. recordVertexArrayObject(vertexBuffers: {
  40736. [key: string]: VertexBuffer;
  40737. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40738. [kind: string]: Nullable<VertexBuffer>;
  40739. }): WebGLVertexArrayObject;
  40740. /**
  40741. * Bind a specific vertex array object
  40742. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40743. * @param vertexArrayObject defines the vertex array object to bind
  40744. * @param indexBuffer defines the index buffer to bind
  40745. */
  40746. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40747. /**
  40748. * Bind webGl buffers directly to the webGL context
  40749. * @param vertexBuffer defines the vertex buffer to bind
  40750. * @param indexBuffer defines the index buffer to bind
  40751. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40752. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40753. * @param effect defines the effect associated with the vertex buffer
  40754. */
  40755. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40756. private _unbindVertexArrayObject;
  40757. /**
  40758. * Bind a list of vertex buffers to the webGL context
  40759. * @param vertexBuffers defines the list of vertex buffers to bind
  40760. * @param indexBuffer defines the index buffer to bind
  40761. * @param effect defines the effect associated with the vertex buffers
  40762. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40763. */
  40764. bindBuffers(vertexBuffers: {
  40765. [key: string]: Nullable<VertexBuffer>;
  40766. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40767. [kind: string]: Nullable<VertexBuffer>;
  40768. }): void;
  40769. /**
  40770. * Unbind all instance attributes
  40771. */
  40772. unbindInstanceAttributes(): void;
  40773. /**
  40774. * Release and free the memory of a vertex array object
  40775. * @param vao defines the vertex array object to delete
  40776. */
  40777. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40778. /** @hidden */
  40779. _releaseBuffer(buffer: DataBuffer): boolean;
  40780. protected _deleteBuffer(buffer: DataBuffer): void;
  40781. /**
  40782. * Update the content of a webGL buffer used with instantiation and bind it to the webGL context
  40783. * @param instancesBuffer defines the webGL buffer to update and bind
  40784. * @param data defines the data to store in the buffer
  40785. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40786. */
  40787. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40788. /**
  40789. * Bind the content of a webGL buffer used with instantiation
  40790. * @param instancesBuffer defines the webGL buffer to bind
  40791. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40792. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40793. */
  40794. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40795. /**
  40796. * Disable the instance attribute corresponding to the name in parameter
  40797. * @param name defines the name of the attribute to disable
  40798. */
  40799. disableInstanceAttributeByName(name: string): void;
  40800. /**
  40801. * Disable the instance attribute corresponding to the location in parameter
  40802. * @param attributeLocation defines the attribute location of the attribute to disable
  40803. */
  40804. disableInstanceAttribute(attributeLocation: number): void;
  40805. /**
  40806. * Disable the attribute corresponding to the location in parameter
  40807. * @param attributeLocation defines the attribute location of the attribute to disable
  40808. */
  40809. disableAttributeByIndex(attributeLocation: number): void;
  40810. /**
  40811. * Send a draw order
  40812. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40813. * @param indexStart defines the starting index
  40814. * @param indexCount defines the number of index to draw
  40815. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40816. */
  40817. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40818. /**
  40819. * Draw a list of points
  40820. * @param verticesStart defines the index of first vertex to draw
  40821. * @param verticesCount defines the count of vertices to draw
  40822. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40823. */
  40824. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40825. /**
  40826. * Draw a list of unindexed primitives
  40827. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40828. * @param verticesStart defines the index of first vertex to draw
  40829. * @param verticesCount defines the count of vertices to draw
  40830. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40831. */
  40832. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40833. /**
  40834. * Draw a list of indexed primitives
  40835. * @param fillMode defines the primitive to use
  40836. * @param indexStart defines the starting index
  40837. * @param indexCount defines the number of index to draw
  40838. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40839. */
  40840. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40841. /**
  40842. * Draw a list of unindexed primitives
  40843. * @param fillMode defines the primitive to use
  40844. * @param verticesStart defines the index of first vertex to draw
  40845. * @param verticesCount defines the count of vertices to draw
  40846. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40847. */
  40848. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40849. private _drawMode;
  40850. /** @hidden */
  40851. protected _reportDrawCall(): void;
  40852. /** @hidden */
  40853. _releaseEffect(effect: Effect): void;
  40854. /** @hidden */
  40855. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40856. /**
  40857. * Create a new effect (used to store vertex/fragment shaders)
  40858. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40859. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40860. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40861. * @param samplers defines an array of string used to represent textures
  40862. * @param defines defines the string containing the defines to use to compile the shaders
  40863. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  40864. * @param onCompiled defines a function to call when the effect creation is successful
  40865. * @param onError defines a function to call when the effect creation has failed
  40866. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40867. * @returns the new Effect
  40868. */
  40869. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  40870. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40871. private _compileShader;
  40872. private _compileRawShader;
  40873. /** @hidden */
  40874. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40875. /**
  40876. * Directly creates a webGL program
  40877. * @param pipelineContext defines the pipeline context to attach to
  40878. * @param vertexCode defines the vertex shader code to use
  40879. * @param fragmentCode defines the fragment shader code to use
  40880. * @param context defines the webGL context to use (if not set, the current one will be used)
  40881. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40882. * @returns the new webGL program
  40883. */
  40884. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40885. /**
  40886. * Creates a webGL program
  40887. * @param pipelineContext defines the pipeline context to attach to
  40888. * @param vertexCode defines the vertex shader code to use
  40889. * @param fragmentCode defines the fragment shader code to use
  40890. * @param defines defines the string containing the defines to use to compile the shaders
  40891. * @param context defines the webGL context to use (if not set, the current one will be used)
  40892. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40893. * @returns the new webGL program
  40894. */
  40895. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40896. /**
  40897. * Creates a new pipeline context
  40898. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40899. * @returns the new pipeline
  40900. */
  40901. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40902. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40903. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40904. /** @hidden */
  40905. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40906. /** @hidden */
  40907. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40908. /** @hidden */
  40909. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40910. /**
  40911. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40912. * @param pipelineContext defines the pipeline context to use
  40913. * @param uniformsNames defines the list of uniform names
  40914. * @returns an array of webGL uniform locations
  40915. */
  40916. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40917. /**
  40918. * Gets the list of active attributes for a given webGL program
  40919. * @param pipelineContext defines the pipeline context to use
  40920. * @param attributesNames defines the list of attribute names to get
  40921. * @returns an array of indices indicating the offset of each attribute
  40922. */
  40923. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40924. /**
  40925. * Activates an effect, making it the current one (ie. the one used for rendering)
  40926. * @param effect defines the effect to activate
  40927. */
  40928. enableEffect(effect: Nullable<Effect>): void;
  40929. /**
  40930. * Set the value of an uniform to a number (int)
  40931. * @param uniform defines the webGL uniform location where to store the value
  40932. * @param value defines the int number to store
  40933. * @returns true if the value was set
  40934. */
  40935. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40936. /**
  40937. * Set the value of an uniform to a int2
  40938. * @param uniform defines the webGL uniform location where to store the value
  40939. * @param x defines the 1st component of the value
  40940. * @param y defines the 2nd component of the value
  40941. * @returns true if the value was set
  40942. */
  40943. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40944. /**
  40945. * Set the value of an uniform to a int3
  40946. * @param uniform defines the webGL uniform location where to store the value
  40947. * @param x defines the 1st component of the value
  40948. * @param y defines the 2nd component of the value
  40949. * @param z defines the 3rd component of the value
  40950. * @returns true if the value was set
  40951. */
  40952. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40953. /**
  40954. * Set the value of an uniform to a int4
  40955. * @param uniform defines the webGL uniform location where to store the value
  40956. * @param x defines the 1st component of the value
  40957. * @param y defines the 2nd component of the value
  40958. * @param z defines the 3rd component of the value
  40959. * @param w defines the 4th component of the value
  40960. * @returns true if the value was set
  40961. */
  40962. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40963. /**
  40964. * Set the value of an uniform to an array of int32
  40965. * @param uniform defines the webGL uniform location where to store the value
  40966. * @param array defines the array of int32 to store
  40967. * @returns true if the value was set
  40968. */
  40969. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40970. /**
  40971. * Set the value of an uniform to an array of int32 (stored as vec2)
  40972. * @param uniform defines the webGL uniform location where to store the value
  40973. * @param array defines the array of int32 to store
  40974. * @returns true if the value was set
  40975. */
  40976. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40977. /**
  40978. * Set the value of an uniform to an array of int32 (stored as vec3)
  40979. * @param uniform defines the webGL uniform location where to store the value
  40980. * @param array defines the array of int32 to store
  40981. * @returns true if the value was set
  40982. */
  40983. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40984. /**
  40985. * Set the value of an uniform to an array of int32 (stored as vec4)
  40986. * @param uniform defines the webGL uniform location where to store the value
  40987. * @param array defines the array of int32 to store
  40988. * @returns true if the value was set
  40989. */
  40990. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40991. /**
  40992. * Set the value of an uniform to an array of number
  40993. * @param uniform defines the webGL uniform location where to store the value
  40994. * @param array defines the array of number to store
  40995. * @returns true if the value was set
  40996. */
  40997. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40998. /**
  40999. * Set the value of an uniform to an array of number (stored as vec2)
  41000. * @param uniform defines the webGL uniform location where to store the value
  41001. * @param array defines the array of number to store
  41002. * @returns true if the value was set
  41003. */
  41004. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41005. /**
  41006. * Set the value of an uniform to an array of number (stored as vec3)
  41007. * @param uniform defines the webGL uniform location where to store the value
  41008. * @param array defines the array of number to store
  41009. * @returns true if the value was set
  41010. */
  41011. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41012. /**
  41013. * Set the value of an uniform to an array of number (stored as vec4)
  41014. * @param uniform defines the webGL uniform location where to store the value
  41015. * @param array defines the array of number to store
  41016. * @returns true if the value was set
  41017. */
  41018. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41019. /**
  41020. * Set the value of an uniform to an array of float32 (stored as matrices)
  41021. * @param uniform defines the webGL uniform location where to store the value
  41022. * @param matrices defines the array of float32 to store
  41023. * @returns true if the value was set
  41024. */
  41025. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41026. /**
  41027. * Set the value of an uniform to a matrix (3x3)
  41028. * @param uniform defines the webGL uniform location where to store the value
  41029. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41030. * @returns true if the value was set
  41031. */
  41032. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41033. /**
  41034. * Set the value of an uniform to a matrix (2x2)
  41035. * @param uniform defines the webGL uniform location where to store the value
  41036. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41037. * @returns true if the value was set
  41038. */
  41039. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41040. /**
  41041. * Set the value of an uniform to a number (float)
  41042. * @param uniform defines the webGL uniform location where to store the value
  41043. * @param value defines the float number to store
  41044. * @returns true if the value was transferred
  41045. */
  41046. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41047. /**
  41048. * Set the value of an uniform to a vec2
  41049. * @param uniform defines the webGL uniform location where to store the value
  41050. * @param x defines the 1st component of the value
  41051. * @param y defines the 2nd component of the value
  41052. * @returns true if the value was set
  41053. */
  41054. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41055. /**
  41056. * Set the value of an uniform to a vec3
  41057. * @param uniform defines the webGL uniform location where to store the value
  41058. * @param x defines the 1st component of the value
  41059. * @param y defines the 2nd component of the value
  41060. * @param z defines the 3rd component of the value
  41061. * @returns true if the value was set
  41062. */
  41063. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41064. /**
  41065. * Set the value of an uniform to a vec4
  41066. * @param uniform defines the webGL uniform location where to store the value
  41067. * @param x defines the 1st component of the value
  41068. * @param y defines the 2nd component of the value
  41069. * @param z defines the 3rd component of the value
  41070. * @param w defines the 4th component of the value
  41071. * @returns true if the value was set
  41072. */
  41073. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41074. /**
  41075. * Apply all cached states (depth, culling, stencil and alpha)
  41076. */
  41077. applyStates(): void;
  41078. /**
  41079. * Enable or disable color writing
  41080. * @param enable defines the state to set
  41081. */
  41082. setColorWrite(enable: boolean): void;
  41083. /**
  41084. * Gets a boolean indicating if color writing is enabled
  41085. * @returns the current color writing state
  41086. */
  41087. getColorWrite(): boolean;
  41088. /**
  41089. * Gets the depth culling state manager
  41090. */
  41091. get depthCullingState(): DepthCullingState;
  41092. /**
  41093. * Gets the alpha state manager
  41094. */
  41095. get alphaState(): AlphaState;
  41096. /**
  41097. * Gets the stencil state manager
  41098. */
  41099. get stencilState(): StencilState;
  41100. /**
  41101. * Clears the list of texture accessible through engine.
  41102. * This can help preventing texture load conflict due to name collision.
  41103. */
  41104. clearInternalTexturesCache(): void;
  41105. /**
  41106. * Force the entire cache to be cleared
  41107. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41108. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41109. */
  41110. wipeCaches(bruteForce?: boolean): void;
  41111. /** @hidden */
  41112. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41113. min: number;
  41114. mag: number;
  41115. };
  41116. /** @hidden */
  41117. protected _createTexture(): WebGLTexture;
  41118. /** @hidden */
  41119. _createHardwareTexture(): HardwareTextureWrapper;
  41120. protected _createTextureBase(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode: number | undefined, onLoad: (() => void) | null | undefined, onError: ((message: string, exception: any) => void) | null | undefined, prepareTexture: (texture: InternalTexture, extension: string, scene: Nullable<ISceneLike>, img: HTMLImageElement | ImageBitmap | {
  41121. width: number;
  41122. height: number;
  41123. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41124. width: number;
  41125. height: number;
  41126. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41127. width: number;
  41128. height: number;
  41129. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  41130. /**
  41131. * Usually called from Texture.ts.
  41132. * Passed information to create a WebGLTexture
  41133. * @param url defines a value which contains one of the following:
  41134. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41135. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41136. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41137. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41138. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  41139. * @param scene needed for loading to the correct scene
  41140. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41141. * @param onLoad optional callback to be called upon successful completion
  41142. * @param onError optional callback to be called upon failure
  41143. * @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
  41144. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41145. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41146. * @param forcedExtension defines the extension to use to pick the right loader
  41147. * @param mimeType defines an optional mime type
  41148. * @param loaderOptions options to be passed to the loader
  41149. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41150. */
  41151. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  41152. /**
  41153. * Loads an image as an HTMLImageElement.
  41154. * @param input url string, ArrayBuffer, or Blob to load
  41155. * @param onLoad callback called when the image successfully loads
  41156. * @param onError callback called when the image fails to load
  41157. * @param offlineProvider offline provider for caching
  41158. * @param mimeType optional mime type
  41159. * @returns the HTMLImageElement of the loaded image
  41160. * @hidden
  41161. */
  41162. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41163. /**
  41164. * @hidden
  41165. */
  41166. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41167. private _unpackFlipYCached;
  41168. /**
  41169. * In case you are sharing the context with other applications, it might
  41170. * be interested to not cache the unpack flip y state to ensure a consistent
  41171. * value would be set.
  41172. */
  41173. enableUnpackFlipYCached: boolean;
  41174. /** @hidden */
  41175. _unpackFlipY(value: boolean): void;
  41176. /** @hidden */
  41177. _getUnpackAlignement(): number;
  41178. private _getTextureTarget;
  41179. /**
  41180. * Update the sampling mode of a given texture
  41181. * @param samplingMode defines the required sampling mode
  41182. * @param texture defines the texture to update
  41183. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41184. */
  41185. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41186. /**
  41187. * Update the dimensions of a texture
  41188. * @param texture texture to update
  41189. * @param width new width of the texture
  41190. * @param height new height of the texture
  41191. * @param depth new depth of the texture
  41192. */
  41193. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  41194. /**
  41195. * Update the sampling mode of a given texture
  41196. * @param texture defines the texture to update
  41197. * @param wrapU defines the texture wrap mode of the u coordinates
  41198. * @param wrapV defines the texture wrap mode of the v coordinates
  41199. * @param wrapR defines the texture wrap mode of the r coordinates
  41200. */
  41201. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41202. /** @hidden */
  41203. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41204. width: number;
  41205. height: number;
  41206. layers?: number;
  41207. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  41208. /** @hidden */
  41209. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41210. /** @hidden */
  41211. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41212. /**
  41213. * Update a portion of an internal texture
  41214. * @param texture defines the texture to update
  41215. * @param imageData defines the data to store into the texture
  41216. * @param xOffset defines the x coordinates of the update rectangle
  41217. * @param yOffset defines the y coordinates of the update rectangle
  41218. * @param width defines the width of the update rectangle
  41219. * @param height defines the height of the update rectangle
  41220. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41221. * @param lod defines the lod level to update (0 by default)
  41222. */
  41223. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41224. /** @hidden */
  41225. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41226. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41227. private _prepareWebGLTexture;
  41228. /** @hidden */
  41229. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41230. private _getDepthStencilBuffer;
  41231. /** @hidden */
  41232. _releaseFramebufferObjects(texture: InternalTexture): void;
  41233. /** @hidden */
  41234. _releaseTexture(texture: InternalTexture): void;
  41235. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41236. protected _setProgram(program: WebGLProgram): void;
  41237. protected _boundUniforms: {
  41238. [key: number]: WebGLUniformLocation;
  41239. };
  41240. /**
  41241. * Binds an effect to the webGL context
  41242. * @param effect defines the effect to bind
  41243. */
  41244. bindSamplers(effect: Effect): void;
  41245. private _activateCurrentTexture;
  41246. /** @hidden */
  41247. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41248. /** @hidden */
  41249. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  41250. /**
  41251. * Unbind all textures from the webGL context
  41252. */
  41253. unbindAllTextures(): void;
  41254. /**
  41255. * Sets a texture to the according uniform.
  41256. * @param channel The texture channel
  41257. * @param uniform The uniform to set
  41258. * @param texture The texture to apply
  41259. * @param name The name of the uniform in the effect
  41260. */
  41261. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  41262. private _bindSamplerUniformToChannel;
  41263. private _getTextureWrapMode;
  41264. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  41265. /**
  41266. * Sets an array of texture to the webGL context
  41267. * @param channel defines the channel where the texture array must be set
  41268. * @param uniform defines the associated uniform location
  41269. * @param textures defines the array of textures to bind
  41270. * @param name name of the channel
  41271. */
  41272. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  41273. /** @hidden */
  41274. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41275. private _setTextureParameterFloat;
  41276. private _setTextureParameterInteger;
  41277. /**
  41278. * Unbind all vertex attributes from the webGL context
  41279. */
  41280. unbindAllAttributes(): void;
  41281. /**
  41282. * 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
  41283. */
  41284. releaseEffects(): void;
  41285. /**
  41286. * Dispose and release all associated resources
  41287. */
  41288. dispose(): void;
  41289. /**
  41290. * Attach a new callback raised when context lost event is fired
  41291. * @param callback defines the callback to call
  41292. */
  41293. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41294. /**
  41295. * Attach a new callback raised when context restored event is fired
  41296. * @param callback defines the callback to call
  41297. */
  41298. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41299. /**
  41300. * Get the current error code of the webGL context
  41301. * @returns the error code
  41302. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41303. */
  41304. getError(): number;
  41305. private _canRenderToFloatFramebuffer;
  41306. private _canRenderToHalfFloatFramebuffer;
  41307. private _canRenderToFramebuffer;
  41308. /** @hidden */
  41309. _getWebGLTextureType(type: number): number;
  41310. /** @hidden */
  41311. _getInternalFormat(format: number): number;
  41312. /** @hidden */
  41313. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41314. /** @hidden */
  41315. _getRGBAMultiSampleBufferFormat(type: number): number;
  41316. /** @hidden */
  41317. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  41318. /**
  41319. * Loads a file from a url
  41320. * @param url url to load
  41321. * @param onSuccess callback called when the file successfully loads
  41322. * @param onProgress callback called while file is loading (if the server supports this mode)
  41323. * @param offlineProvider defines the offline provider for caching
  41324. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41325. * @param onError callback called when the file fails to load
  41326. * @returns a file request object
  41327. * @hidden
  41328. */
  41329. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  41330. /**
  41331. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41332. * @param x defines the x coordinate of the rectangle where pixels must be read
  41333. * @param y defines the y coordinate of the rectangle where pixels must be read
  41334. * @param width defines the width of the rectangle where pixels must be read
  41335. * @param height defines the height of the rectangle where pixels must be read
  41336. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41337. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41338. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41339. */
  41340. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41341. private static _IsSupported;
  41342. private static _HasMajorPerformanceCaveat;
  41343. /**
  41344. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41345. */
  41346. static get IsSupported(): boolean;
  41347. /**
  41348. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41349. * @returns true if the engine can be created
  41350. * @ignorenaming
  41351. */
  41352. static isSupported(): boolean;
  41353. /**
  41354. * Gets a boolean indicating if the engine can be instantiated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  41355. */
  41356. static get HasMajorPerformanceCaveat(): boolean;
  41357. /**
  41358. * Find the next highest power of two.
  41359. * @param x Number to start search from.
  41360. * @return Next highest power of two.
  41361. */
  41362. static CeilingPOT(x: number): number;
  41363. /**
  41364. * Find the next lowest power of two.
  41365. * @param x Number to start search from.
  41366. * @return Next lowest power of two.
  41367. */
  41368. static FloorPOT(x: number): number;
  41369. /**
  41370. * Find the nearest power of two.
  41371. * @param x Number to start search from.
  41372. * @return Next nearest power of two.
  41373. */
  41374. static NearestPOT(x: number): number;
  41375. /**
  41376. * Get the closest exponent of two
  41377. * @param value defines the value to approximate
  41378. * @param max defines the maximum value to return
  41379. * @param mode defines how to define the closest value
  41380. * @returns closest exponent of two of the given value
  41381. */
  41382. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41383. /**
  41384. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41385. * @param func - the function to be called
  41386. * @param requester - the object that will request the next frame. Falls back to window.
  41387. * @returns frame number
  41388. */
  41389. static QueueNewFrame(func: () => void, requester?: any): number;
  41390. /**
  41391. * Gets host document
  41392. * @returns the host document object
  41393. */
  41394. getHostDocument(): Nullable<Document>;
  41395. }
  41396. }
  41397. declare module BABYLON {
  41398. /**
  41399. * Defines the source of the internal texture
  41400. */
  41401. export enum InternalTextureSource {
  41402. /**
  41403. * The source of the texture data is unknown
  41404. */
  41405. Unknown = 0,
  41406. /**
  41407. * Texture data comes from an URL
  41408. */
  41409. Url = 1,
  41410. /**
  41411. * Texture data is only used for temporary storage
  41412. */
  41413. Temp = 2,
  41414. /**
  41415. * Texture data comes from raw data (ArrayBuffer)
  41416. */
  41417. Raw = 3,
  41418. /**
  41419. * Texture content is dynamic (video or dynamic texture)
  41420. */
  41421. Dynamic = 4,
  41422. /**
  41423. * Texture content is generated by rendering to it
  41424. */
  41425. RenderTarget = 5,
  41426. /**
  41427. * Texture content is part of a multi render target process
  41428. */
  41429. MultiRenderTarget = 6,
  41430. /**
  41431. * Texture data comes from a cube data file
  41432. */
  41433. Cube = 7,
  41434. /**
  41435. * Texture data comes from a raw cube data
  41436. */
  41437. CubeRaw = 8,
  41438. /**
  41439. * Texture data come from a prefiltered cube data file
  41440. */
  41441. CubePrefiltered = 9,
  41442. /**
  41443. * Texture content is raw 3D data
  41444. */
  41445. Raw3D = 10,
  41446. /**
  41447. * Texture content is raw 2D array data
  41448. */
  41449. Raw2DArray = 11,
  41450. /**
  41451. * Texture content is a depth texture
  41452. */
  41453. Depth = 12,
  41454. /**
  41455. * Texture data comes from a raw cube data encoded with RGBD
  41456. */
  41457. CubeRawRGBD = 13
  41458. }
  41459. /**
  41460. * Class used to store data associated with WebGL texture data for the engine
  41461. * This class should not be used directly
  41462. */
  41463. export class InternalTexture {
  41464. /** @hidden */
  41465. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41466. /**
  41467. * Defines if the texture is ready
  41468. */
  41469. isReady: boolean;
  41470. /**
  41471. * Defines if the texture is a cube texture
  41472. */
  41473. isCube: boolean;
  41474. /**
  41475. * Defines if the texture contains 3D data
  41476. */
  41477. is3D: boolean;
  41478. /**
  41479. * Defines if the texture contains 2D array data
  41480. */
  41481. is2DArray: boolean;
  41482. /**
  41483. * Defines if the texture contains multiview data
  41484. */
  41485. isMultiview: boolean;
  41486. /**
  41487. * Gets the URL used to load this texture
  41488. */
  41489. url: string;
  41490. /** @hidden */
  41491. _originalUrl: string;
  41492. /**
  41493. * Gets the sampling mode of the texture
  41494. */
  41495. samplingMode: number;
  41496. /**
  41497. * Gets a boolean indicating if the texture needs mipmaps generation
  41498. */
  41499. generateMipMaps: boolean;
  41500. /**
  41501. * Gets the number of samples used by the texture (WebGL2+ only)
  41502. */
  41503. samples: number;
  41504. /**
  41505. * Gets the type of the texture (int, float...)
  41506. */
  41507. type: number;
  41508. /**
  41509. * Gets the format of the texture (RGB, RGBA...)
  41510. */
  41511. format: number;
  41512. /**
  41513. * Observable called when the texture is loaded
  41514. */
  41515. onLoadedObservable: Observable<InternalTexture>;
  41516. /**
  41517. * Gets the width of the texture
  41518. */
  41519. width: number;
  41520. /**
  41521. * Gets the height of the texture
  41522. */
  41523. height: number;
  41524. /**
  41525. * Gets the depth of the texture
  41526. */
  41527. depth: number;
  41528. /**
  41529. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41530. */
  41531. baseWidth: number;
  41532. /**
  41533. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41534. */
  41535. baseHeight: number;
  41536. /**
  41537. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41538. */
  41539. baseDepth: number;
  41540. /**
  41541. * Gets a boolean indicating if the texture is inverted on Y axis
  41542. */
  41543. invertY: boolean;
  41544. /** @hidden */
  41545. _invertVScale: boolean;
  41546. /** @hidden */
  41547. _associatedChannel: number;
  41548. /** @hidden */
  41549. _source: InternalTextureSource;
  41550. /** @hidden */
  41551. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41552. /** @hidden */
  41553. _bufferView: Nullable<ArrayBufferView>;
  41554. /** @hidden */
  41555. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41556. /** @hidden */
  41557. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41558. /** @hidden */
  41559. _size: number;
  41560. /** @hidden */
  41561. _extension: string;
  41562. /** @hidden */
  41563. _files: Nullable<string[]>;
  41564. /** @hidden */
  41565. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41566. /** @hidden */
  41567. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41568. /** @hidden */
  41569. _framebuffer: Nullable<WebGLFramebuffer>;
  41570. /** @hidden */
  41571. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41572. /** @hidden */
  41573. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41574. /** @hidden */
  41575. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41576. /** @hidden */
  41577. _attachments: Nullable<number[]>;
  41578. /** @hidden */
  41579. _textureArray: Nullable<InternalTexture[]>;
  41580. /** @hidden */
  41581. _cachedCoordinatesMode: Nullable<number>;
  41582. /** @hidden */
  41583. _cachedWrapU: Nullable<number>;
  41584. /** @hidden */
  41585. _cachedWrapV: Nullable<number>;
  41586. /** @hidden */
  41587. _cachedWrapR: Nullable<number>;
  41588. /** @hidden */
  41589. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41590. /** @hidden */
  41591. _isDisabled: boolean;
  41592. /** @hidden */
  41593. _compression: Nullable<string>;
  41594. /** @hidden */
  41595. _generateStencilBuffer: boolean;
  41596. /** @hidden */
  41597. _generateDepthBuffer: boolean;
  41598. /** @hidden */
  41599. _comparisonFunction: number;
  41600. /** @hidden */
  41601. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41602. /** @hidden */
  41603. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41604. /** @hidden */
  41605. _sphericalPolynomialComputed: boolean;
  41606. /** @hidden */
  41607. _lodGenerationScale: number;
  41608. /** @hidden */
  41609. _lodGenerationOffset: number;
  41610. /** @hidden */
  41611. _depthStencilTexture: Nullable<InternalTexture>;
  41612. /** @hidden */
  41613. _colorTextureArray: Nullable<WebGLTexture>;
  41614. /** @hidden */
  41615. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41616. /** @hidden */
  41617. _lodTextureHigh: Nullable<BaseTexture>;
  41618. /** @hidden */
  41619. _lodTextureMid: Nullable<BaseTexture>;
  41620. /** @hidden */
  41621. _lodTextureLow: Nullable<BaseTexture>;
  41622. /** @hidden */
  41623. _isRGBD: boolean;
  41624. /** @hidden */
  41625. _linearSpecularLOD: boolean;
  41626. /** @hidden */
  41627. _irradianceTexture: Nullable<BaseTexture>;
  41628. /** @hidden */
  41629. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41630. /** @hidden */
  41631. _references: number;
  41632. /** @hidden */
  41633. _gammaSpace: Nullable<boolean>;
  41634. private _engine;
  41635. private _uniqueId;
  41636. private static _Counter;
  41637. /** Gets the unique id of the internal texture */
  41638. get uniqueId(): number;
  41639. /**
  41640. * Gets the Engine the texture belongs to.
  41641. * @returns The babylon engine
  41642. */
  41643. getEngine(): ThinEngine;
  41644. /**
  41645. * Gets the data source type of the texture
  41646. */
  41647. get source(): InternalTextureSource;
  41648. /**
  41649. * Creates a new InternalTexture
  41650. * @param engine defines the engine to use
  41651. * @param source defines the type of data that will be used
  41652. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41653. */
  41654. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41655. /**
  41656. * Increments the number of references (ie. the number of Texture that point to it)
  41657. */
  41658. incrementReferences(): void;
  41659. /**
  41660. * Change the size of the texture (not the size of the content)
  41661. * @param width defines the new width
  41662. * @param height defines the new height
  41663. * @param depth defines the new depth (1 by default)
  41664. */
  41665. updateSize(width: int, height: int, depth?: int): void;
  41666. /** @hidden */
  41667. _rebuild(): void;
  41668. /** @hidden */
  41669. _swapAndDie(target: InternalTexture): void;
  41670. /**
  41671. * Dispose the current allocated resources
  41672. */
  41673. dispose(): void;
  41674. }
  41675. }
  41676. declare module BABYLON {
  41677. /**
  41678. * Interface used to present a loading screen while loading a scene
  41679. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41680. */
  41681. export interface ILoadingScreen {
  41682. /**
  41683. * Function called to display the loading screen
  41684. */
  41685. displayLoadingUI: () => void;
  41686. /**
  41687. * Function called to hide the loading screen
  41688. */
  41689. hideLoadingUI: () => void;
  41690. /**
  41691. * Gets or sets the color to use for the background
  41692. */
  41693. loadingUIBackgroundColor: string;
  41694. /**
  41695. * Gets or sets the text to display while loading
  41696. */
  41697. loadingUIText: string;
  41698. }
  41699. /**
  41700. * Class used for the default loading screen
  41701. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41702. */
  41703. export class DefaultLoadingScreen implements ILoadingScreen {
  41704. private _renderingCanvas;
  41705. private _loadingText;
  41706. private _loadingDivBackgroundColor;
  41707. private _loadingDiv;
  41708. private _loadingTextDiv;
  41709. /** Gets or sets the logo url to use for the default loading screen */
  41710. static DefaultLogoUrl: string;
  41711. /** Gets or sets the spinner url to use for the default loading screen */
  41712. static DefaultSpinnerUrl: string;
  41713. /**
  41714. * Creates a new default loading screen
  41715. * @param _renderingCanvas defines the canvas used to render the scene
  41716. * @param _loadingText defines the default text to display
  41717. * @param _loadingDivBackgroundColor defines the default background color
  41718. */
  41719. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41720. /**
  41721. * Function called to display the loading screen
  41722. */
  41723. displayLoadingUI(): void;
  41724. /**
  41725. * Function called to hide the loading screen
  41726. */
  41727. hideLoadingUI(): void;
  41728. /**
  41729. * Gets or sets the text to display while loading
  41730. */
  41731. set loadingUIText(text: string);
  41732. get loadingUIText(): string;
  41733. /**
  41734. * Gets or sets the color to use for the background
  41735. */
  41736. get loadingUIBackgroundColor(): string;
  41737. set loadingUIBackgroundColor(color: string);
  41738. private _resizeLoadingUI;
  41739. }
  41740. }
  41741. declare module BABYLON {
  41742. /**
  41743. * Interface for any object that can request an animation frame
  41744. */
  41745. export interface ICustomAnimationFrameRequester {
  41746. /**
  41747. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41748. */
  41749. renderFunction?: Function;
  41750. /**
  41751. * Called to request the next frame to render to
  41752. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41753. */
  41754. requestAnimationFrame: Function;
  41755. /**
  41756. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41757. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41758. */
  41759. requestID?: number;
  41760. }
  41761. }
  41762. declare module BABYLON {
  41763. /**
  41764. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41765. */
  41766. export class PerformanceMonitor {
  41767. private _enabled;
  41768. private _rollingFrameTime;
  41769. private _lastFrameTimeMs;
  41770. /**
  41771. * constructor
  41772. * @param frameSampleSize The number of samples required to saturate the sliding window
  41773. */
  41774. constructor(frameSampleSize?: number);
  41775. /**
  41776. * Samples current frame
  41777. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41778. */
  41779. sampleFrame(timeMs?: number): void;
  41780. /**
  41781. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41782. */
  41783. get averageFrameTime(): number;
  41784. /**
  41785. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41786. */
  41787. get averageFrameTimeVariance(): number;
  41788. /**
  41789. * Returns the frame time of the most recent frame
  41790. */
  41791. get instantaneousFrameTime(): number;
  41792. /**
  41793. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41794. */
  41795. get averageFPS(): number;
  41796. /**
  41797. * Returns the average framerate in frames per second using the most recent frame time
  41798. */
  41799. get instantaneousFPS(): number;
  41800. /**
  41801. * Returns true if enough samples have been taken to completely fill the sliding window
  41802. */
  41803. get isSaturated(): boolean;
  41804. /**
  41805. * Enables contributions to the sliding window sample set
  41806. */
  41807. enable(): void;
  41808. /**
  41809. * Disables contributions to the sliding window sample set
  41810. * Samples will not be interpolated over the disabled period
  41811. */
  41812. disable(): void;
  41813. /**
  41814. * Returns true if sampling is enabled
  41815. */
  41816. get isEnabled(): boolean;
  41817. /**
  41818. * Resets performance monitor
  41819. */
  41820. reset(): void;
  41821. }
  41822. /**
  41823. * RollingAverage
  41824. *
  41825. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41826. */
  41827. export class RollingAverage {
  41828. /**
  41829. * Current average
  41830. */
  41831. average: number;
  41832. /**
  41833. * Current variance
  41834. */
  41835. variance: number;
  41836. protected _samples: Array<number>;
  41837. protected _sampleCount: number;
  41838. protected _pos: number;
  41839. protected _m2: number;
  41840. /**
  41841. * constructor
  41842. * @param length The number of samples required to saturate the sliding window
  41843. */
  41844. constructor(length: number);
  41845. /**
  41846. * Adds a sample to the sample set
  41847. * @param v The sample value
  41848. */
  41849. add(v: number): void;
  41850. /**
  41851. * Returns previously added values or null if outside of history or outside the sliding window domain
  41852. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41853. * @return Value previously recorded with add() or null if outside of range
  41854. */
  41855. history(i: number): number;
  41856. /**
  41857. * Returns true if enough samples have been taken to completely fill the sliding window
  41858. * @return true if sample-set saturated
  41859. */
  41860. isSaturated(): boolean;
  41861. /**
  41862. * Resets the rolling average (equivalent to 0 samples taken so far)
  41863. */
  41864. reset(): void;
  41865. /**
  41866. * Wraps a value around the sample range boundaries
  41867. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41868. * @return Wrapped position in sample range
  41869. */
  41870. protected _wrapPosition(i: number): number;
  41871. }
  41872. }
  41873. declare module BABYLON {
  41874. /**
  41875. * This class is used to track a performance counter which is number based.
  41876. * The user has access to many properties which give statistics of different nature.
  41877. *
  41878. * The implementer can track two kinds of Performance Counter: time and count.
  41879. * 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.
  41880. * 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.
  41881. */
  41882. export class PerfCounter {
  41883. /**
  41884. * Gets or sets a global boolean to turn on and off all the counters
  41885. */
  41886. static Enabled: boolean;
  41887. /**
  41888. * Returns the smallest value ever
  41889. */
  41890. get min(): number;
  41891. /**
  41892. * Returns the biggest value ever
  41893. */
  41894. get max(): number;
  41895. /**
  41896. * Returns the average value since the performance counter is running
  41897. */
  41898. get average(): number;
  41899. /**
  41900. * Returns the average value of the last second the counter was monitored
  41901. */
  41902. get lastSecAverage(): number;
  41903. /**
  41904. * Returns the current value
  41905. */
  41906. get current(): number;
  41907. /**
  41908. * Gets the accumulated total
  41909. */
  41910. get total(): number;
  41911. /**
  41912. * Gets the total value count
  41913. */
  41914. get count(): number;
  41915. /**
  41916. * Creates a new counter
  41917. */
  41918. constructor();
  41919. /**
  41920. * Call this method to start monitoring a new frame.
  41921. * 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.
  41922. */
  41923. fetchNewFrame(): void;
  41924. /**
  41925. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41926. * @param newCount the count value to add to the monitored count
  41927. * @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.
  41928. */
  41929. addCount(newCount: number, fetchResult: boolean): void;
  41930. /**
  41931. * Start monitoring this performance counter
  41932. */
  41933. beginMonitoring(): void;
  41934. /**
  41935. * Compute the time lapsed since the previous beginMonitoring() call.
  41936. * @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
  41937. */
  41938. endMonitoring(newFrame?: boolean): void;
  41939. private _fetchResult;
  41940. private _startMonitoringTime;
  41941. private _min;
  41942. private _max;
  41943. private _average;
  41944. private _current;
  41945. private _totalValueCount;
  41946. private _totalAccumulated;
  41947. private _lastSecAverage;
  41948. private _lastSecAccumulated;
  41949. private _lastSecTime;
  41950. private _lastSecValueCount;
  41951. }
  41952. }
  41953. declare module BABYLON {
  41954. interface ThinEngine {
  41955. /** @hidden */
  41956. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41957. /** @hidden */
  41958. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  41959. }
  41960. }
  41961. declare module BABYLON {
  41962. /**
  41963. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41964. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41965. */
  41966. export class Analyser {
  41967. /**
  41968. * Gets or sets the smoothing
  41969. * @ignorenaming
  41970. */
  41971. SMOOTHING: number;
  41972. /**
  41973. * Gets or sets the FFT table size
  41974. * @ignorenaming
  41975. */
  41976. FFT_SIZE: number;
  41977. /**
  41978. * Gets or sets the bar graph amplitude
  41979. * @ignorenaming
  41980. */
  41981. BARGRAPHAMPLITUDE: number;
  41982. /**
  41983. * Gets or sets the position of the debug canvas
  41984. * @ignorenaming
  41985. */
  41986. DEBUGCANVASPOS: {
  41987. x: number;
  41988. y: number;
  41989. };
  41990. /**
  41991. * Gets or sets the debug canvas size
  41992. * @ignorenaming
  41993. */
  41994. DEBUGCANVASSIZE: {
  41995. width: number;
  41996. height: number;
  41997. };
  41998. private _byteFreqs;
  41999. private _byteTime;
  42000. private _floatFreqs;
  42001. private _webAudioAnalyser;
  42002. private _debugCanvas;
  42003. private _debugCanvasContext;
  42004. private _scene;
  42005. private _registerFunc;
  42006. private _audioEngine;
  42007. /**
  42008. * Creates a new analyser
  42009. * @param scene defines hosting scene
  42010. */
  42011. constructor(scene: Scene);
  42012. /**
  42013. * Get the number of data values you will have to play with for the visualization
  42014. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42015. * @returns a number
  42016. */
  42017. getFrequencyBinCount(): number;
  42018. /**
  42019. * Gets the current frequency data as a byte array
  42020. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42021. * @returns a Uint8Array
  42022. */
  42023. getByteFrequencyData(): Uint8Array;
  42024. /**
  42025. * Gets the current waveform as a byte array
  42026. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42027. * @returns a Uint8Array
  42028. */
  42029. getByteTimeDomainData(): Uint8Array;
  42030. /**
  42031. * Gets the current frequency data as a float array
  42032. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42033. * @returns a Float32Array
  42034. */
  42035. getFloatFrequencyData(): Float32Array;
  42036. /**
  42037. * Renders the debug canvas
  42038. */
  42039. drawDebugCanvas(): void;
  42040. /**
  42041. * Stops rendering the debug canvas and removes it
  42042. */
  42043. stopDebugCanvas(): void;
  42044. /**
  42045. * Connects two audio nodes
  42046. * @param inputAudioNode defines first node to connect
  42047. * @param outputAudioNode defines second node to connect
  42048. */
  42049. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42050. /**
  42051. * Releases all associated resources
  42052. */
  42053. dispose(): void;
  42054. }
  42055. }
  42056. declare module BABYLON {
  42057. /**
  42058. * This represents an audio engine and it is responsible
  42059. * to play, synchronize and analyse sounds throughout the application.
  42060. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42061. */
  42062. export interface IAudioEngine extends IDisposable {
  42063. /**
  42064. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42065. */
  42066. readonly canUseWebAudio: boolean;
  42067. /**
  42068. * Gets the current AudioContext if available.
  42069. */
  42070. readonly audioContext: Nullable<AudioContext>;
  42071. /**
  42072. * The master gain node defines the global audio volume of your audio engine.
  42073. */
  42074. readonly masterGain: GainNode;
  42075. /**
  42076. * Gets whether or not mp3 are supported by your browser.
  42077. */
  42078. readonly isMP3supported: boolean;
  42079. /**
  42080. * Gets whether or not ogg are supported by your browser.
  42081. */
  42082. readonly isOGGsupported: boolean;
  42083. /**
  42084. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42085. * @ignoreNaming
  42086. */
  42087. WarnedWebAudioUnsupported: boolean;
  42088. /**
  42089. * Defines if the audio engine relies on a custom unlocked button.
  42090. * In this case, the embedded button will not be displayed.
  42091. */
  42092. useCustomUnlockedButton: boolean;
  42093. /**
  42094. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42095. */
  42096. readonly unlocked: boolean;
  42097. /**
  42098. * Event raised when audio has been unlocked on the browser.
  42099. */
  42100. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42101. /**
  42102. * Event raised when audio has been locked on the browser.
  42103. */
  42104. onAudioLockedObservable: Observable<IAudioEngine>;
  42105. /**
  42106. * Flags the audio engine in Locked state.
  42107. * This happens due to new browser policies preventing audio to autoplay.
  42108. */
  42109. lock(): void;
  42110. /**
  42111. * Unlocks the audio engine once a user action has been done on the dom.
  42112. * This is helpful to resume play once browser policies have been satisfied.
  42113. */
  42114. unlock(): void;
  42115. /**
  42116. * Gets the global volume sets on the master gain.
  42117. * @returns the global volume if set or -1 otherwise
  42118. */
  42119. getGlobalVolume(): number;
  42120. /**
  42121. * Sets the global volume of your experience (sets on the master gain).
  42122. * @param newVolume Defines the new global volume of the application
  42123. */
  42124. setGlobalVolume(newVolume: number): void;
  42125. /**
  42126. * Connect the audio engine to an audio analyser allowing some amazing
  42127. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  42128. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42129. * @param analyser The analyser to connect to the engine
  42130. */
  42131. connectToAnalyser(analyser: Analyser): void;
  42132. }
  42133. }
  42134. declare module BABYLON {
  42135. /**
  42136. * Defines the interface used by display changed events
  42137. */
  42138. export interface IDisplayChangedEventArgs {
  42139. /** Gets the vrDisplay object (if any) */
  42140. vrDisplay: Nullable<any>;
  42141. /** Gets a boolean indicating if webVR is supported */
  42142. vrSupported: boolean;
  42143. }
  42144. /**
  42145. * Defines the interface used by objects containing a viewport (like a camera)
  42146. */
  42147. interface IViewportOwnerLike {
  42148. /**
  42149. * Gets or sets the viewport
  42150. */
  42151. viewport: IViewportLike;
  42152. }
  42153. /**
  42154. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42155. */
  42156. export class Engine extends ThinEngine {
  42157. /** Defines that alpha blending is disabled */
  42158. static readonly ALPHA_DISABLE: number;
  42159. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42160. static readonly ALPHA_ADD: number;
  42161. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42162. static readonly ALPHA_COMBINE: number;
  42163. /** Defines that alpha blending to DEST - SRC * DEST */
  42164. static readonly ALPHA_SUBTRACT: number;
  42165. /** Defines that alpha blending to SRC * DEST */
  42166. static readonly ALPHA_MULTIPLY: number;
  42167. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42168. static readonly ALPHA_MAXIMIZED: number;
  42169. /** Defines that alpha blending to SRC + DEST */
  42170. static readonly ALPHA_ONEONE: number;
  42171. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42172. static readonly ALPHA_PREMULTIPLIED: number;
  42173. /**
  42174. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42175. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42176. */
  42177. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42178. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42179. static readonly ALPHA_INTERPOLATE: number;
  42180. /**
  42181. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42182. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42183. */
  42184. static readonly ALPHA_SCREENMODE: number;
  42185. /** Defines that the resource is not delayed*/
  42186. static readonly DELAYLOADSTATE_NONE: number;
  42187. /** Defines that the resource was successfully delay loaded */
  42188. static readonly DELAYLOADSTATE_LOADED: number;
  42189. /** Defines that the resource is currently delay loading */
  42190. static readonly DELAYLOADSTATE_LOADING: number;
  42191. /** Defines that the resource is delayed and has not started loading */
  42192. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42193. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42194. static readonly NEVER: number;
  42195. /** 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 */
  42196. static readonly ALWAYS: number;
  42197. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42198. static readonly LESS: number;
  42199. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42200. static readonly EQUAL: number;
  42201. /** 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 */
  42202. static readonly LEQUAL: number;
  42203. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42204. static readonly GREATER: number;
  42205. /** 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 */
  42206. static readonly GEQUAL: number;
  42207. /** 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 */
  42208. static readonly NOTEQUAL: number;
  42209. /** Passed to stencilOperation to specify that stencil value must be kept */
  42210. static readonly KEEP: number;
  42211. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42212. static readonly REPLACE: number;
  42213. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42214. static readonly INCR: number;
  42215. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42216. static readonly DECR: number;
  42217. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42218. static readonly INVERT: number;
  42219. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42220. static readonly INCR_WRAP: number;
  42221. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42222. static readonly DECR_WRAP: number;
  42223. /** Texture is not repeating outside of 0..1 UVs */
  42224. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42225. /** Texture is repeating outside of 0..1 UVs */
  42226. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42227. /** Texture is repeating and mirrored */
  42228. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42229. /** ALPHA */
  42230. static readonly TEXTUREFORMAT_ALPHA: number;
  42231. /** LUMINANCE */
  42232. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42233. /** LUMINANCE_ALPHA */
  42234. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42235. /** RGB */
  42236. static readonly TEXTUREFORMAT_RGB: number;
  42237. /** RGBA */
  42238. static readonly TEXTUREFORMAT_RGBA: number;
  42239. /** RED */
  42240. static readonly TEXTUREFORMAT_RED: number;
  42241. /** RED (2nd reference) */
  42242. static readonly TEXTUREFORMAT_R: number;
  42243. /** RG */
  42244. static readonly TEXTUREFORMAT_RG: number;
  42245. /** RED_INTEGER */
  42246. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42247. /** RED_INTEGER (2nd reference) */
  42248. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42249. /** RG_INTEGER */
  42250. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42251. /** RGB_INTEGER */
  42252. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42253. /** RGBA_INTEGER */
  42254. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42255. /** UNSIGNED_BYTE */
  42256. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42257. /** UNSIGNED_BYTE (2nd reference) */
  42258. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42259. /** FLOAT */
  42260. static readonly TEXTURETYPE_FLOAT: number;
  42261. /** HALF_FLOAT */
  42262. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42263. /** BYTE */
  42264. static readonly TEXTURETYPE_BYTE: number;
  42265. /** SHORT */
  42266. static readonly TEXTURETYPE_SHORT: number;
  42267. /** UNSIGNED_SHORT */
  42268. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42269. /** INT */
  42270. static readonly TEXTURETYPE_INT: number;
  42271. /** UNSIGNED_INT */
  42272. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42273. /** UNSIGNED_SHORT_4_4_4_4 */
  42274. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42275. /** UNSIGNED_SHORT_5_5_5_1 */
  42276. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42277. /** UNSIGNED_SHORT_5_6_5 */
  42278. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42279. /** UNSIGNED_INT_2_10_10_10_REV */
  42280. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42281. /** UNSIGNED_INT_24_8 */
  42282. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42283. /** UNSIGNED_INT_10F_11F_11F_REV */
  42284. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42285. /** UNSIGNED_INT_5_9_9_9_REV */
  42286. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42287. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42288. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42289. /** nearest is mag = nearest and min = nearest and mip = none */
  42290. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42291. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42292. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42293. /** Trilinear is mag = linear and min = linear and mip = linear */
  42294. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42295. /** nearest is mag = nearest and min = nearest and mip = linear */
  42296. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42297. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42298. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42299. /** Trilinear is mag = linear and min = linear and mip = linear */
  42300. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42301. /** mag = nearest and min = nearest and mip = nearest */
  42302. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42303. /** mag = nearest and min = linear and mip = nearest */
  42304. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42305. /** mag = nearest and min = linear and mip = linear */
  42306. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42307. /** mag = nearest and min = linear and mip = none */
  42308. static readonly TEXTURE_NEAREST_LINEAR: number;
  42309. /** mag = nearest and min = nearest and mip = none */
  42310. static readonly TEXTURE_NEAREST_NEAREST: number;
  42311. /** mag = linear and min = nearest and mip = nearest */
  42312. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42313. /** mag = linear and min = nearest and mip = linear */
  42314. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42315. /** mag = linear and min = linear and mip = none */
  42316. static readonly TEXTURE_LINEAR_LINEAR: number;
  42317. /** mag = linear and min = nearest and mip = none */
  42318. static readonly TEXTURE_LINEAR_NEAREST: number;
  42319. /** Explicit coordinates mode */
  42320. static readonly TEXTURE_EXPLICIT_MODE: number;
  42321. /** Spherical coordinates mode */
  42322. static readonly TEXTURE_SPHERICAL_MODE: number;
  42323. /** Planar coordinates mode */
  42324. static readonly TEXTURE_PLANAR_MODE: number;
  42325. /** Cubic coordinates mode */
  42326. static readonly TEXTURE_CUBIC_MODE: number;
  42327. /** Projection coordinates mode */
  42328. static readonly TEXTURE_PROJECTION_MODE: number;
  42329. /** Skybox coordinates mode */
  42330. static readonly TEXTURE_SKYBOX_MODE: number;
  42331. /** Inverse Cubic coordinates mode */
  42332. static readonly TEXTURE_INVCUBIC_MODE: number;
  42333. /** Equirectangular coordinates mode */
  42334. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42335. /** Equirectangular Fixed coordinates mode */
  42336. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42337. /** Equirectangular Fixed Mirrored coordinates mode */
  42338. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42339. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42340. static readonly SCALEMODE_FLOOR: number;
  42341. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42342. static readonly SCALEMODE_NEAREST: number;
  42343. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42344. static readonly SCALEMODE_CEILING: number;
  42345. /**
  42346. * Returns the current npm package of the sdk
  42347. */
  42348. static get NpmPackage(): string;
  42349. /**
  42350. * Returns the current version of the framework
  42351. */
  42352. static get Version(): string;
  42353. /** Gets the list of created engines */
  42354. static get Instances(): Engine[];
  42355. /**
  42356. * Gets the latest created engine
  42357. */
  42358. static get LastCreatedEngine(): Nullable<Engine>;
  42359. /**
  42360. * Gets the latest created scene
  42361. */
  42362. static get LastCreatedScene(): Nullable<Scene>;
  42363. /**
  42364. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42365. * @param flag defines which part of the materials must be marked as dirty
  42366. * @param predicate defines a predicate used to filter which materials should be affected
  42367. */
  42368. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42369. /**
  42370. * Method called to create the default loading screen.
  42371. * This can be overridden in your own app.
  42372. * @param canvas The rendering canvas element
  42373. * @returns The loading screen
  42374. */
  42375. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42376. /**
  42377. * Method called to create the default rescale post process on each engine.
  42378. */
  42379. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42380. /**
  42381. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42382. **/
  42383. enableOfflineSupport: boolean;
  42384. /**
  42385. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  42386. **/
  42387. disableManifestCheck: boolean;
  42388. /**
  42389. * Gets the list of created scenes
  42390. */
  42391. scenes: Scene[];
  42392. /**
  42393. * Event raised when a new scene is created
  42394. */
  42395. onNewSceneAddedObservable: Observable<Scene>;
  42396. /**
  42397. * Gets the list of created postprocesses
  42398. */
  42399. postProcesses: PostProcess[];
  42400. /**
  42401. * Gets a boolean indicating if the pointer is currently locked
  42402. */
  42403. isPointerLock: boolean;
  42404. /**
  42405. * Observable event triggered each time the rendering canvas is resized
  42406. */
  42407. onResizeObservable: Observable<Engine>;
  42408. /**
  42409. * Observable event triggered each time the canvas loses focus
  42410. */
  42411. onCanvasBlurObservable: Observable<Engine>;
  42412. /**
  42413. * Observable event triggered each time the canvas gains focus
  42414. */
  42415. onCanvasFocusObservable: Observable<Engine>;
  42416. /**
  42417. * Observable event triggered each time the canvas receives pointerout event
  42418. */
  42419. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42420. /**
  42421. * Observable raised when the engine begins a new frame
  42422. */
  42423. onBeginFrameObservable: Observable<Engine>;
  42424. /**
  42425. * If set, will be used to request the next animation frame for the render loop
  42426. */
  42427. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42428. /**
  42429. * Observable raised when the engine ends the current frame
  42430. */
  42431. onEndFrameObservable: Observable<Engine>;
  42432. /**
  42433. * Observable raised when the engine is about to compile a shader
  42434. */
  42435. onBeforeShaderCompilationObservable: Observable<Engine>;
  42436. /**
  42437. * Observable raised when the engine has just compiled a shader
  42438. */
  42439. onAfterShaderCompilationObservable: Observable<Engine>;
  42440. /**
  42441. * Gets the audio engine
  42442. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42443. * @ignorenaming
  42444. */
  42445. static audioEngine: IAudioEngine;
  42446. /**
  42447. * Default AudioEngine factory responsible of creating the Audio Engine.
  42448. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42449. */
  42450. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42451. /**
  42452. * Default offline support factory responsible of creating a tool used to store data locally.
  42453. * By default, this will create a Database object if the workload has been embedded.
  42454. */
  42455. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42456. private _loadingScreen;
  42457. private _pointerLockRequested;
  42458. private _rescalePostProcess;
  42459. protected _deterministicLockstep: boolean;
  42460. protected _lockstepMaxSteps: number;
  42461. protected _timeStep: number;
  42462. protected get _supportsHardwareTextureRescaling(): boolean;
  42463. private _fps;
  42464. private _deltaTime;
  42465. /** @hidden */
  42466. _drawCalls: PerfCounter;
  42467. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  42468. canvasTabIndex: number;
  42469. /**
  42470. * Turn this value on if you want to pause FPS computation when in background
  42471. */
  42472. disablePerformanceMonitorInBackground: boolean;
  42473. private _performanceMonitor;
  42474. /**
  42475. * Gets the performance monitor attached to this engine
  42476. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42477. */
  42478. get performanceMonitor(): PerformanceMonitor;
  42479. private _onFocus;
  42480. private _onBlur;
  42481. private _onCanvasPointerOut;
  42482. private _onCanvasBlur;
  42483. private _onCanvasFocus;
  42484. private _onFullscreenChange;
  42485. private _onPointerLockChange;
  42486. /**
  42487. * Gets the HTML element used to attach event listeners
  42488. * @returns a HTML element
  42489. */
  42490. getInputElement(): Nullable<HTMLElement>;
  42491. /**
  42492. * Creates a new engine
  42493. * @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 already used the WebGL context
  42494. * @param antialias defines enable antialiasing (default: false)
  42495. * @param options defines further options to be sent to the getContext() function
  42496. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42497. */
  42498. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42499. /**
  42500. * Shared initialization across engines types.
  42501. * @param canvas The canvas associated with this instance of the engine.
  42502. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42503. * @param audioEngine Defines if an audio engine should be created by default
  42504. */
  42505. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42506. /**
  42507. * Gets current aspect ratio
  42508. * @param viewportOwner defines the camera to use to get the aspect ratio
  42509. * @param useScreen defines if screen size must be used (or the current render target if any)
  42510. * @returns a number defining the aspect ratio
  42511. */
  42512. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42513. /**
  42514. * Gets current screen aspect ratio
  42515. * @returns a number defining the aspect ratio
  42516. */
  42517. getScreenAspectRatio(): number;
  42518. /**
  42519. * Gets the client rect of the HTML canvas attached with the current webGL context
  42520. * @returns a client rectangle
  42521. */
  42522. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42523. /**
  42524. * Gets the client rect of the HTML element used for events
  42525. * @returns a client rectangle
  42526. */
  42527. getInputElementClientRect(): Nullable<ClientRect>;
  42528. /**
  42529. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42530. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42531. * @returns true if engine is in deterministic lock step mode
  42532. */
  42533. isDeterministicLockStep(): boolean;
  42534. /**
  42535. * Gets the max steps when engine is running in deterministic lock step
  42536. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42537. * @returns the max steps
  42538. */
  42539. getLockstepMaxSteps(): number;
  42540. /**
  42541. * Returns the time in ms between steps when using deterministic lock step.
  42542. * @returns time step in (ms)
  42543. */
  42544. getTimeStep(): number;
  42545. /**
  42546. * Force the mipmap generation for the given render target texture
  42547. * @param texture defines the render target texture to use
  42548. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42549. */
  42550. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42551. /** States */
  42552. /**
  42553. * Set various states to the webGL context
  42554. * @param culling defines backface culling state
  42555. * @param zOffset defines the value to apply to zOffset (0 by default)
  42556. * @param force defines if states must be applied even if cache is up to date
  42557. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42558. */
  42559. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42560. /**
  42561. * Set the z offset to apply to current rendering
  42562. * @param value defines the offset to apply
  42563. */
  42564. setZOffset(value: number): void;
  42565. /**
  42566. * Gets the current value of the zOffset
  42567. * @returns the current zOffset state
  42568. */
  42569. getZOffset(): number;
  42570. /**
  42571. * Gets a boolean indicating if depth testing is enabled
  42572. * @returns the current state
  42573. */
  42574. getDepthBuffer(): boolean;
  42575. /**
  42576. * Enable or disable depth buffering
  42577. * @param enable defines the state to set
  42578. */
  42579. setDepthBuffer(enable: boolean): void;
  42580. /**
  42581. * Gets a boolean indicating if depth writing is enabled
  42582. * @returns the current depth writing state
  42583. */
  42584. getDepthWrite(): boolean;
  42585. /**
  42586. * Enable or disable depth writing
  42587. * @param enable defines the state to set
  42588. */
  42589. setDepthWrite(enable: boolean): void;
  42590. /**
  42591. * Gets a boolean indicating if stencil buffer is enabled
  42592. * @returns the current stencil buffer state
  42593. */
  42594. getStencilBuffer(): boolean;
  42595. /**
  42596. * Enable or disable the stencil buffer
  42597. * @param enable defines if the stencil buffer must be enabled or disabled
  42598. */
  42599. setStencilBuffer(enable: boolean): void;
  42600. /**
  42601. * Gets the current stencil mask
  42602. * @returns a number defining the new stencil mask to use
  42603. */
  42604. getStencilMask(): number;
  42605. /**
  42606. * Sets the current stencil mask
  42607. * @param mask defines the new stencil mask to use
  42608. */
  42609. setStencilMask(mask: number): void;
  42610. /**
  42611. * Gets the current stencil function
  42612. * @returns a number defining the stencil function to use
  42613. */
  42614. getStencilFunction(): number;
  42615. /**
  42616. * Gets the current stencil reference value
  42617. * @returns a number defining the stencil reference value to use
  42618. */
  42619. getStencilFunctionReference(): number;
  42620. /**
  42621. * Gets the current stencil mask
  42622. * @returns a number defining the stencil mask to use
  42623. */
  42624. getStencilFunctionMask(): number;
  42625. /**
  42626. * Sets the current stencil function
  42627. * @param stencilFunc defines the new stencil function to use
  42628. */
  42629. setStencilFunction(stencilFunc: number): void;
  42630. /**
  42631. * Sets the current stencil reference
  42632. * @param reference defines the new stencil reference to use
  42633. */
  42634. setStencilFunctionReference(reference: number): void;
  42635. /**
  42636. * Sets the current stencil mask
  42637. * @param mask defines the new stencil mask to use
  42638. */
  42639. setStencilFunctionMask(mask: number): void;
  42640. /**
  42641. * Gets the current stencil operation when stencil fails
  42642. * @returns a number defining stencil operation to use when stencil fails
  42643. */
  42644. getStencilOperationFail(): number;
  42645. /**
  42646. * Gets the current stencil operation when depth fails
  42647. * @returns a number defining stencil operation to use when depth fails
  42648. */
  42649. getStencilOperationDepthFail(): number;
  42650. /**
  42651. * Gets the current stencil operation when stencil passes
  42652. * @returns a number defining stencil operation to use when stencil passes
  42653. */
  42654. getStencilOperationPass(): number;
  42655. /**
  42656. * Sets the stencil operation to use when stencil fails
  42657. * @param operation defines the stencil operation to use when stencil fails
  42658. */
  42659. setStencilOperationFail(operation: number): void;
  42660. /**
  42661. * Sets the stencil operation to use when depth fails
  42662. * @param operation defines the stencil operation to use when depth fails
  42663. */
  42664. setStencilOperationDepthFail(operation: number): void;
  42665. /**
  42666. * Sets the stencil operation to use when stencil passes
  42667. * @param operation defines the stencil operation to use when stencil passes
  42668. */
  42669. setStencilOperationPass(operation: number): void;
  42670. /**
  42671. * Sets a boolean indicating if the dithering state is enabled or disabled
  42672. * @param value defines the dithering state
  42673. */
  42674. setDitheringState(value: boolean): void;
  42675. /**
  42676. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42677. * @param value defines the rasterizer state
  42678. */
  42679. setRasterizerState(value: boolean): void;
  42680. /**
  42681. * Gets the current depth function
  42682. * @returns a number defining the depth function
  42683. */
  42684. getDepthFunction(): Nullable<number>;
  42685. /**
  42686. * Sets the current depth function
  42687. * @param depthFunc defines the function to use
  42688. */
  42689. setDepthFunction(depthFunc: number): void;
  42690. /**
  42691. * Sets the current depth function to GREATER
  42692. */
  42693. setDepthFunctionToGreater(): void;
  42694. /**
  42695. * Sets the current depth function to GEQUAL
  42696. */
  42697. setDepthFunctionToGreaterOrEqual(): void;
  42698. /**
  42699. * Sets the current depth function to LESS
  42700. */
  42701. setDepthFunctionToLess(): void;
  42702. /**
  42703. * Sets the current depth function to LEQUAL
  42704. */
  42705. setDepthFunctionToLessOrEqual(): void;
  42706. private _cachedStencilBuffer;
  42707. private _cachedStencilFunction;
  42708. private _cachedStencilMask;
  42709. private _cachedStencilOperationPass;
  42710. private _cachedStencilOperationFail;
  42711. private _cachedStencilOperationDepthFail;
  42712. private _cachedStencilReference;
  42713. /**
  42714. * Caches the the state of the stencil buffer
  42715. */
  42716. cacheStencilState(): void;
  42717. /**
  42718. * Restores the state of the stencil buffer
  42719. */
  42720. restoreStencilState(): void;
  42721. /**
  42722. * Directly set the WebGL Viewport
  42723. * @param x defines the x coordinate of the viewport (in screen space)
  42724. * @param y defines the y coordinate of the viewport (in screen space)
  42725. * @param width defines the width of the viewport (in screen space)
  42726. * @param height defines the height of the viewport (in screen space)
  42727. * @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
  42728. */
  42729. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42730. /**
  42731. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42732. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42733. * @param y defines the y-coordinate of the corner of the clear rectangle
  42734. * @param width defines the width of the clear rectangle
  42735. * @param height defines the height of the clear rectangle
  42736. * @param clearColor defines the clear color
  42737. */
  42738. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42739. /**
  42740. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42741. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42742. * @param y defines the y-coordinate of the corner of the clear rectangle
  42743. * @param width defines the width of the clear rectangle
  42744. * @param height defines the height of the clear rectangle
  42745. */
  42746. enableScissor(x: number, y: number, width: number, height: number): void;
  42747. /**
  42748. * Disable previously set scissor test rectangle
  42749. */
  42750. disableScissor(): void;
  42751. protected _reportDrawCall(): void;
  42752. /**
  42753. * Initializes a webVR display and starts listening to display change events
  42754. * The onVRDisplayChangedObservable will be notified upon these changes
  42755. * @returns The onVRDisplayChangedObservable
  42756. */
  42757. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42758. /** @hidden */
  42759. _prepareVRComponent(): void;
  42760. /** @hidden */
  42761. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42762. /** @hidden */
  42763. _submitVRFrame(): void;
  42764. /**
  42765. * Call this function to leave webVR mode
  42766. * Will do nothing if webVR is not supported or if there is no webVR device
  42767. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42768. */
  42769. disableVR(): void;
  42770. /**
  42771. * Gets a boolean indicating that the system is in VR mode and is presenting
  42772. * @returns true if VR mode is engaged
  42773. */
  42774. isVRPresenting(): boolean;
  42775. /** @hidden */
  42776. _requestVRFrame(): void;
  42777. /** @hidden */
  42778. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42779. /**
  42780. * Gets the source code of the vertex shader associated with a specific webGL program
  42781. * @param program defines the program to use
  42782. * @returns a string containing the source code of the vertex shader associated with the program
  42783. */
  42784. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42785. /**
  42786. * Gets the source code of the fragment shader associated with a specific webGL program
  42787. * @param program defines the program to use
  42788. * @returns a string containing the source code of the fragment shader associated with the program
  42789. */
  42790. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42791. /**
  42792. * Sets a depth stencil texture from a render target to the according uniform.
  42793. * @param channel The texture channel
  42794. * @param uniform The uniform to set
  42795. * @param texture The render target texture containing the depth stencil texture to apply
  42796. * @param name The texture name
  42797. */
  42798. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42799. /**
  42800. * Sets a texture to the webGL context from a postprocess
  42801. * @param channel defines the channel to use
  42802. * @param postProcess defines the source postprocess
  42803. * @param name name of the channel
  42804. */
  42805. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42806. /**
  42807. * Binds the output of the passed in post process to the texture channel specified
  42808. * @param channel The channel the texture should be bound to
  42809. * @param postProcess The post process which's output should be bound
  42810. * @param name name of the channel
  42811. */
  42812. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42813. protected _rebuildBuffers(): void;
  42814. /** @hidden */
  42815. _renderFrame(): void;
  42816. _renderLoop(): void;
  42817. /** @hidden */
  42818. _renderViews(): boolean;
  42819. /**
  42820. * Toggle full screen mode
  42821. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42822. */
  42823. switchFullscreen(requestPointerLock: boolean): void;
  42824. /**
  42825. * Enters full screen mode
  42826. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42827. */
  42828. enterFullscreen(requestPointerLock: boolean): void;
  42829. /**
  42830. * Exits full screen mode
  42831. */
  42832. exitFullscreen(): void;
  42833. /**
  42834. * Enters Pointerlock mode
  42835. */
  42836. enterPointerlock(): void;
  42837. /**
  42838. * Exits Pointerlock mode
  42839. */
  42840. exitPointerlock(): void;
  42841. /**
  42842. * Begin a new frame
  42843. */
  42844. beginFrame(): void;
  42845. /**
  42846. * End the current frame
  42847. */
  42848. endFrame(): void;
  42849. /**
  42850. * Resize the view according to the canvas' size
  42851. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42852. */
  42853. resize(forceSetSize?: boolean): void;
  42854. /**
  42855. * Force a specific size of the canvas
  42856. * @param width defines the new canvas' width
  42857. * @param height defines the new canvas' height
  42858. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42859. * @returns true if the size was changed
  42860. */
  42861. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42862. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42863. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42864. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42865. _releaseTexture(texture: InternalTexture): void;
  42866. /**
  42867. * @hidden
  42868. * Rescales a texture
  42869. * @param source input texture
  42870. * @param destination destination texture
  42871. * @param scene scene to use to render the resize
  42872. * @param internalFormat format to use when resizing
  42873. * @param onComplete callback to be called when resize has completed
  42874. */
  42875. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42876. /**
  42877. * Gets the current framerate
  42878. * @returns a number representing the framerate
  42879. */
  42880. getFps(): number;
  42881. /**
  42882. * Gets the time spent between current and previous frame
  42883. * @returns a number representing the delta time in ms
  42884. */
  42885. getDeltaTime(): number;
  42886. private _measureFps;
  42887. /** @hidden */
  42888. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42889. /**
  42890. * Updates the sample count of a render target texture
  42891. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42892. * @param texture defines the texture to update
  42893. * @param samples defines the sample count to set
  42894. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42895. */
  42896. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42897. /**
  42898. * Updates a depth texture Comparison Mode and Function.
  42899. * If the comparison Function is equal to 0, the mode will be set to none.
  42900. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42901. * @param texture The texture to set the comparison function for
  42902. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42903. */
  42904. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42905. /**
  42906. * Creates a webGL buffer to use with instantiation
  42907. * @param capacity defines the size of the buffer
  42908. * @returns the webGL buffer
  42909. */
  42910. createInstancesBuffer(capacity: number): DataBuffer;
  42911. /**
  42912. * Delete a webGL buffer used with instantiation
  42913. * @param buffer defines the webGL buffer to delete
  42914. */
  42915. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42916. private _clientWaitAsync;
  42917. /** @hidden */
  42918. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  42919. dispose(): void;
  42920. private _disableTouchAction;
  42921. /**
  42922. * Display the loading screen
  42923. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42924. */
  42925. displayLoadingUI(): void;
  42926. /**
  42927. * Hide the loading screen
  42928. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42929. */
  42930. hideLoadingUI(): void;
  42931. /**
  42932. * Gets the current loading screen object
  42933. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42934. */
  42935. get loadingScreen(): ILoadingScreen;
  42936. /**
  42937. * Sets the current loading screen object
  42938. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42939. */
  42940. set loadingScreen(loadingScreen: ILoadingScreen);
  42941. /**
  42942. * Sets the current loading screen text
  42943. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42944. */
  42945. set loadingUIText(text: string);
  42946. /**
  42947. * Sets the current loading screen background color
  42948. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42949. */
  42950. set loadingUIBackgroundColor(color: string);
  42951. /** Pointerlock and fullscreen */
  42952. /**
  42953. * Ask the browser to promote the current element to pointerlock mode
  42954. * @param element defines the DOM element to promote
  42955. */
  42956. static _RequestPointerlock(element: HTMLElement): void;
  42957. /**
  42958. * Asks the browser to exit pointerlock mode
  42959. */
  42960. static _ExitPointerlock(): void;
  42961. /**
  42962. * Ask the browser to promote the current element to fullscreen rendering mode
  42963. * @param element defines the DOM element to promote
  42964. */
  42965. static _RequestFullscreen(element: HTMLElement): void;
  42966. /**
  42967. * Asks the browser to exit fullscreen mode
  42968. */
  42969. static _ExitFullscreen(): void;
  42970. }
  42971. }
  42972. declare module BABYLON {
  42973. /**
  42974. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42975. * during the life time of the application.
  42976. */
  42977. export class EngineStore {
  42978. /** Gets the list of created engines */
  42979. static Instances: Engine[];
  42980. /** @hidden */
  42981. static _LastCreatedScene: Nullable<Scene>;
  42982. /**
  42983. * Gets the latest created engine
  42984. */
  42985. static get LastCreatedEngine(): Nullable<Engine>;
  42986. /**
  42987. * Gets the latest created scene
  42988. */
  42989. static get LastCreatedScene(): Nullable<Scene>;
  42990. /**
  42991. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42992. * @ignorenaming
  42993. */
  42994. static UseFallbackTexture: boolean;
  42995. /**
  42996. * Texture content used if a texture cannot loaded
  42997. * @ignorenaming
  42998. */
  42999. static FallbackTexture: string;
  43000. }
  43001. }
  43002. declare module BABYLON {
  43003. /**
  43004. * Helper class that provides a small promise polyfill
  43005. */
  43006. export class PromisePolyfill {
  43007. /**
  43008. * Static function used to check if the polyfill is required
  43009. * If this is the case then the function will inject the polyfill to window.Promise
  43010. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43011. */
  43012. static Apply(force?: boolean): void;
  43013. }
  43014. }
  43015. declare module BABYLON {
  43016. /**
  43017. * Interface for screenshot methods with describe argument called `size` as object with options
  43018. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43019. */
  43020. export interface IScreenshotSize {
  43021. /**
  43022. * number in pixels for canvas height
  43023. */
  43024. height?: number;
  43025. /**
  43026. * multiplier allowing render at a higher or lower resolution
  43027. * If value is defined then height and width will be ignored and taken from camera
  43028. */
  43029. precision?: number;
  43030. /**
  43031. * number in pixels for canvas width
  43032. */
  43033. width?: number;
  43034. }
  43035. }
  43036. declare module BABYLON {
  43037. interface IColor4Like {
  43038. r: float;
  43039. g: float;
  43040. b: float;
  43041. a: float;
  43042. }
  43043. /**
  43044. * Class containing a set of static utilities functions
  43045. */
  43046. export class Tools {
  43047. /**
  43048. * Gets or sets the base URL to use to load assets
  43049. */
  43050. static get BaseUrl(): string;
  43051. static set BaseUrl(value: string);
  43052. /**
  43053. * Enable/Disable Custom HTTP Request Headers globally.
  43054. * default = false
  43055. * @see CustomRequestHeaders
  43056. */
  43057. static UseCustomRequestHeaders: boolean;
  43058. /**
  43059. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43060. * i.e. when loading files, where the server/service expects an Authorization header
  43061. */
  43062. static CustomRequestHeaders: {
  43063. [key: string]: string;
  43064. };
  43065. /**
  43066. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43067. */
  43068. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43069. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43070. /**
  43071. * Default behaviour for cors in the application.
  43072. * It can be a string if the expected behavior is identical in the entire app.
  43073. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43074. */
  43075. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43076. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43077. /**
  43078. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43079. * @ignorenaming
  43080. */
  43081. static get UseFallbackTexture(): boolean;
  43082. static set UseFallbackTexture(value: boolean);
  43083. /**
  43084. * Use this object to register external classes like custom textures or material
  43085. * to allow the loaders to instantiate them
  43086. */
  43087. static get RegisteredExternalClasses(): {
  43088. [key: string]: Object;
  43089. };
  43090. static set RegisteredExternalClasses(classes: {
  43091. [key: string]: Object;
  43092. });
  43093. /**
  43094. * Texture content used if a texture cannot loaded
  43095. * @ignorenaming
  43096. */
  43097. static get fallbackTexture(): string;
  43098. static set fallbackTexture(value: string);
  43099. /**
  43100. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43101. * @param u defines the coordinate on X axis
  43102. * @param v defines the coordinate on Y axis
  43103. * @param width defines the width of the source data
  43104. * @param height defines the height of the source data
  43105. * @param pixels defines the source byte array
  43106. * @param color defines the output color
  43107. */
  43108. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43109. /**
  43110. * Interpolates between a and b via alpha
  43111. * @param a The lower value (returned when alpha = 0)
  43112. * @param b The upper value (returned when alpha = 1)
  43113. * @param alpha The interpolation-factor
  43114. * @return The mixed value
  43115. */
  43116. static Mix(a: number, b: number, alpha: number): number;
  43117. /**
  43118. * Tries to instantiate a new object from a given class name
  43119. * @param className defines the class name to instantiate
  43120. * @returns the new object or null if the system was not able to do the instantiation
  43121. */
  43122. static Instantiate(className: string): any;
  43123. /**
  43124. * Provides a slice function that will work even on IE
  43125. * @param data defines the array to slice
  43126. * @param start defines the start of the data (optional)
  43127. * @param end defines the end of the data (optional)
  43128. * @returns the new sliced array
  43129. */
  43130. static Slice<T>(data: T, start?: number, end?: number): T;
  43131. /**
  43132. * Provides a slice function that will work even on IE
  43133. * The difference between this and Slice is that this will force-convert to array
  43134. * @param data defines the array to slice
  43135. * @param start defines the start of the data (optional)
  43136. * @param end defines the end of the data (optional)
  43137. * @returns the new sliced array
  43138. */
  43139. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43140. /**
  43141. * Polyfill for setImmediate
  43142. * @param action defines the action to execute after the current execution block
  43143. */
  43144. static SetImmediate(action: () => void): void;
  43145. /**
  43146. * Function indicating if a number is an exponent of 2
  43147. * @param value defines the value to test
  43148. * @returns true if the value is an exponent of 2
  43149. */
  43150. static IsExponentOfTwo(value: number): boolean;
  43151. private static _tmpFloatArray;
  43152. /**
  43153. * Returns the nearest 32-bit single precision float representation of a Number
  43154. * @param value A Number. If the parameter is of a different type, it will get converted
  43155. * to a number or to NaN if it cannot be converted
  43156. * @returns number
  43157. */
  43158. static FloatRound(value: number): number;
  43159. /**
  43160. * Extracts the filename from a path
  43161. * @param path defines the path to use
  43162. * @returns the filename
  43163. */
  43164. static GetFilename(path: string): string;
  43165. /**
  43166. * Extracts the "folder" part of a path (everything before the filename).
  43167. * @param uri The URI to extract the info from
  43168. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43169. * @returns The "folder" part of the path
  43170. */
  43171. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43172. /**
  43173. * Extracts text content from a DOM element hierarchy
  43174. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43175. */
  43176. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43177. /**
  43178. * Convert an angle in radians to degrees
  43179. * @param angle defines the angle to convert
  43180. * @returns the angle in degrees
  43181. */
  43182. static ToDegrees(angle: number): number;
  43183. /**
  43184. * Convert an angle in degrees to radians
  43185. * @param angle defines the angle to convert
  43186. * @returns the angle in radians
  43187. */
  43188. static ToRadians(angle: number): number;
  43189. /**
  43190. * Returns an array if obj is not an array
  43191. * @param obj defines the object to evaluate as an array
  43192. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43193. * @returns either obj directly if obj is an array or a new array containing obj
  43194. */
  43195. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43196. /**
  43197. * Gets the pointer prefix to use
  43198. * @param engine defines the engine we are finding the prefix for
  43199. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43200. */
  43201. static GetPointerPrefix(engine: Engine): string;
  43202. /**
  43203. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43204. * @param url define the url we are trying
  43205. * @param element define the dom element where to configure the cors policy
  43206. */
  43207. static SetCorsBehavior(url: string | string[], element: {
  43208. crossOrigin: string | null;
  43209. }): void;
  43210. /**
  43211. * Removes unwanted characters from an url
  43212. * @param url defines the url to clean
  43213. * @returns the cleaned url
  43214. */
  43215. static CleanUrl(url: string): string;
  43216. /**
  43217. * Gets or sets a function used to pre-process url before using them to load assets
  43218. */
  43219. static get PreprocessUrl(): (url: string) => string;
  43220. static set PreprocessUrl(processor: (url: string) => string);
  43221. /**
  43222. * Loads an image as an HTMLImageElement.
  43223. * @param input url string, ArrayBuffer, or Blob to load
  43224. * @param onLoad callback called when the image successfully loads
  43225. * @param onError callback called when the image fails to load
  43226. * @param offlineProvider offline provider for caching
  43227. * @param mimeType optional mime type
  43228. * @returns the HTMLImageElement of the loaded image
  43229. */
  43230. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43231. /**
  43232. * Loads a file from a url
  43233. * @param url url string, ArrayBuffer, or Blob to load
  43234. * @param onSuccess callback called when the file successfully loads
  43235. * @param onProgress callback called while file is loading (if the server supports this mode)
  43236. * @param offlineProvider defines the offline provider for caching
  43237. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43238. * @param onError callback called when the file fails to load
  43239. * @returns a file request object
  43240. */
  43241. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  43242. /**
  43243. * Loads a file from a url
  43244. * @param url the file url to load
  43245. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43246. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43247. */
  43248. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43249. /**
  43250. * Load a script (identified by an url). When the url returns, the
  43251. * content of this file is added into a new script element, attached to the DOM (body element)
  43252. * @param scriptUrl defines the url of the script to laod
  43253. * @param onSuccess defines the callback called when the script is loaded
  43254. * @param onError defines the callback to call if an error occurs
  43255. * @param scriptId defines the id of the script element
  43256. */
  43257. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43258. /**
  43259. * Load an asynchronous script (identified by an url). When the url returns, the
  43260. * content of this file is added into a new script element, attached to the DOM (body element)
  43261. * @param scriptUrl defines the url of the script to laod
  43262. * @param scriptId defines the id of the script element
  43263. * @returns a promise request object
  43264. */
  43265. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43266. /**
  43267. * Loads a file from a blob
  43268. * @param fileToLoad defines the blob to use
  43269. * @param callback defines the callback to call when data is loaded
  43270. * @param progressCallback defines the callback to call during loading process
  43271. * @returns a file request object
  43272. */
  43273. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43274. /**
  43275. * Reads a file from a File object
  43276. * @param file defines the file to load
  43277. * @param onSuccess defines the callback to call when data is loaded
  43278. * @param onProgress defines the callback to call during loading process
  43279. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43280. * @param onError defines the callback to call when an error occurs
  43281. * @returns a file request object
  43282. */
  43283. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43284. /**
  43285. * Creates a data url from a given string content
  43286. * @param content defines the content to convert
  43287. * @returns the new data url link
  43288. */
  43289. static FileAsURL(content: string): string;
  43290. /**
  43291. * Format the given number to a specific decimal format
  43292. * @param value defines the number to format
  43293. * @param decimals defines the number of decimals to use
  43294. * @returns the formatted string
  43295. */
  43296. static Format(value: number, decimals?: number): string;
  43297. /**
  43298. * Tries to copy an object by duplicating every property
  43299. * @param source defines the source object
  43300. * @param destination defines the target object
  43301. * @param doNotCopyList defines a list of properties to avoid
  43302. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43303. */
  43304. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43305. /**
  43306. * Gets a boolean indicating if the given object has no own property
  43307. * @param obj defines the object to test
  43308. * @returns true if object has no own property
  43309. */
  43310. static IsEmpty(obj: any): boolean;
  43311. /**
  43312. * Function used to register events at window level
  43313. * @param windowElement defines the Window object to use
  43314. * @param events defines the events to register
  43315. */
  43316. static RegisterTopRootEvents(windowElement: Window, events: {
  43317. name: string;
  43318. handler: Nullable<(e: FocusEvent) => any>;
  43319. }[]): void;
  43320. /**
  43321. * Function used to unregister events from window level
  43322. * @param windowElement defines the Window object to use
  43323. * @param events defines the events to unregister
  43324. */
  43325. static UnregisterTopRootEvents(windowElement: Window, events: {
  43326. name: string;
  43327. handler: Nullable<(e: FocusEvent) => any>;
  43328. }[]): void;
  43329. /**
  43330. * @ignore
  43331. */
  43332. static _ScreenshotCanvas: HTMLCanvasElement;
  43333. /**
  43334. * Dumps the current bound framebuffer
  43335. * @param width defines the rendering width
  43336. * @param height defines the rendering height
  43337. * @param engine defines the hosting engine
  43338. * @param successCallback defines the callback triggered once the data are available
  43339. * @param mimeType defines the mime type of the result
  43340. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43341. * @return a void promise
  43342. */
  43343. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43344. /**
  43345. * Dumps an array buffer
  43346. * @param width defines the rendering width
  43347. * @param height defines the rendering height
  43348. * @param data the data array
  43349. * @param successCallback defines the callback triggered once the data are available
  43350. * @param mimeType defines the mime type of the result
  43351. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43352. * @param invertY true to invert the picture in the Y dimension
  43353. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43354. */
  43355. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43356. /**
  43357. * Dumps an array buffer
  43358. * @param width defines the rendering width
  43359. * @param height defines the rendering height
  43360. * @param data the data array
  43361. * @param successCallback defines the callback triggered once the data are available
  43362. * @param mimeType defines the mime type of the result
  43363. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43364. * @param invertY true to invert the picture in the Y dimension
  43365. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43366. * @return a promise that resolve to the final data
  43367. */
  43368. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43369. /**
  43370. * Converts the canvas data to blob.
  43371. * This acts as a polyfill for browsers not supporting the to blob function.
  43372. * @param canvas Defines the canvas to extract the data from
  43373. * @param successCallback Defines the callback triggered once the data are available
  43374. * @param mimeType Defines the mime type of the result
  43375. */
  43376. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43377. /**
  43378. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43379. * @param successCallback defines the callback triggered once the data are available
  43380. * @param mimeType defines the mime type of the result
  43381. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43382. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43383. */
  43384. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43385. /**
  43386. * Downloads a blob in the browser
  43387. * @param blob defines the blob to download
  43388. * @param fileName defines the name of the downloaded file
  43389. */
  43390. static Download(blob: Blob, fileName: string): void;
  43391. /**
  43392. * Will return the right value of the noPreventDefault variable
  43393. * Needed to keep backwards compatibility to the old API.
  43394. *
  43395. * @param args arguments passed to the attachControl function
  43396. * @returns the correct value for noPreventDefault
  43397. */
  43398. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43399. /**
  43400. * Captures a screenshot of the current rendering
  43401. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43402. * @param engine defines the rendering engine
  43403. * @param camera defines the source camera
  43404. * @param size This parameter can be set to a single number or to an object with the
  43405. * following (optional) properties: precision, width, height. If a single number is passed,
  43406. * it will be used for both width and height. If an object is passed, the screenshot size
  43407. * will be derived from the parameters. The precision property is a multiplier allowing
  43408. * rendering at a higher or lower resolution
  43409. * @param successCallback defines the callback receives a single parameter which contains the
  43410. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43411. * src parameter of an <img> to display it
  43412. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43413. * Check your browser for supported MIME types
  43414. */
  43415. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43416. /**
  43417. * Captures a screenshot of the current rendering
  43418. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43419. * @param engine defines the rendering engine
  43420. * @param camera defines the source camera
  43421. * @param size This parameter can be set to a single number or to an object with the
  43422. * following (optional) properties: precision, width, height. If a single number is passed,
  43423. * it will be used for both width and height. If an object is passed, the screenshot size
  43424. * will be derived from the parameters. The precision property is a multiplier allowing
  43425. * rendering at a higher or lower resolution
  43426. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43427. * Check your browser for supported MIME types
  43428. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43429. * to the src parameter of an <img> to display it
  43430. */
  43431. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43432. /**
  43433. * Generates an image screenshot from the specified camera.
  43434. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43435. * @param engine The engine to use for rendering
  43436. * @param camera The camera to use for rendering
  43437. * @param size This parameter can be set to a single number or to an object with the
  43438. * following (optional) properties: precision, width, height. If a single number is passed,
  43439. * it will be used for both width and height. If an object is passed, the screenshot size
  43440. * will be derived from the parameters. The precision property is a multiplier allowing
  43441. * rendering at a higher or lower resolution
  43442. * @param successCallback The callback receives a single parameter which contains the
  43443. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43444. * src parameter of an <img> to display it
  43445. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43446. * Check your browser for supported MIME types
  43447. * @param samples Texture samples (default: 1)
  43448. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43449. * @param fileName A name for for the downloaded file.
  43450. */
  43451. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43452. /**
  43453. * Generates an image screenshot from the specified camera.
  43454. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43455. * @param engine The engine to use for rendering
  43456. * @param camera The camera to use for rendering
  43457. * @param size This parameter can be set to a single number or to an object with the
  43458. * following (optional) properties: precision, width, height. If a single number is passed,
  43459. * it will be used for both width and height. If an object is passed, the screenshot size
  43460. * will be derived from the parameters. The precision property is a multiplier allowing
  43461. * rendering at a higher or lower resolution
  43462. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43463. * Check your browser for supported MIME types
  43464. * @param samples Texture samples (default: 1)
  43465. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43466. * @param fileName A name for for the downloaded file.
  43467. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43468. * to the src parameter of an <img> to display it
  43469. */
  43470. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43471. /**
  43472. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43473. * Be aware Math.random() could cause collisions, but:
  43474. * "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"
  43475. * @returns a pseudo random id
  43476. */
  43477. static RandomId(): string;
  43478. /**
  43479. * Test if the given uri is a base64 string
  43480. * @param uri The uri to test
  43481. * @return True if the uri is a base64 string or false otherwise
  43482. */
  43483. static IsBase64(uri: string): boolean;
  43484. /**
  43485. * Decode the given base64 uri.
  43486. * @param uri The uri to decode
  43487. * @return The decoded base64 data.
  43488. */
  43489. static DecodeBase64(uri: string): ArrayBuffer;
  43490. /**
  43491. * Gets the absolute url.
  43492. * @param url the input url
  43493. * @return the absolute url
  43494. */
  43495. static GetAbsoluteUrl(url: string): string;
  43496. /**
  43497. * No log
  43498. */
  43499. static readonly NoneLogLevel: number;
  43500. /**
  43501. * Only message logs
  43502. */
  43503. static readonly MessageLogLevel: number;
  43504. /**
  43505. * Only warning logs
  43506. */
  43507. static readonly WarningLogLevel: number;
  43508. /**
  43509. * Only error logs
  43510. */
  43511. static readonly ErrorLogLevel: number;
  43512. /**
  43513. * All logs
  43514. */
  43515. static readonly AllLogLevel: number;
  43516. /**
  43517. * Gets a value indicating the number of loading errors
  43518. * @ignorenaming
  43519. */
  43520. static get errorsCount(): number;
  43521. /**
  43522. * Callback called when a new log is added
  43523. */
  43524. static OnNewCacheEntry: (entry: string) => void;
  43525. /**
  43526. * Log a message to the console
  43527. * @param message defines the message to log
  43528. */
  43529. static Log(message: string): void;
  43530. /**
  43531. * Write a warning message to the console
  43532. * @param message defines the message to log
  43533. */
  43534. static Warn(message: string): void;
  43535. /**
  43536. * Write an error message to the console
  43537. * @param message defines the message to log
  43538. */
  43539. static Error(message: string): void;
  43540. /**
  43541. * Gets current log cache (list of logs)
  43542. */
  43543. static get LogCache(): string;
  43544. /**
  43545. * Clears the log cache
  43546. */
  43547. static ClearLogCache(): void;
  43548. /**
  43549. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43550. */
  43551. static set LogLevels(level: number);
  43552. /**
  43553. * Checks if the window object exists
  43554. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43555. */
  43556. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43557. /**
  43558. * No performance log
  43559. */
  43560. static readonly PerformanceNoneLogLevel: number;
  43561. /**
  43562. * Use user marks to log performance
  43563. */
  43564. static readonly PerformanceUserMarkLogLevel: number;
  43565. /**
  43566. * Log performance to the console
  43567. */
  43568. static readonly PerformanceConsoleLogLevel: number;
  43569. private static _performance;
  43570. /**
  43571. * Sets the current performance log level
  43572. */
  43573. static set PerformanceLogLevel(level: number);
  43574. private static _StartPerformanceCounterDisabled;
  43575. private static _EndPerformanceCounterDisabled;
  43576. private static _StartUserMark;
  43577. private static _EndUserMark;
  43578. private static _StartPerformanceConsole;
  43579. private static _EndPerformanceConsole;
  43580. /**
  43581. * Starts a performance counter
  43582. */
  43583. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43584. /**
  43585. * Ends a specific performance counter
  43586. */
  43587. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43588. /**
  43589. * Gets either window.performance.now() if supported or Date.now() else
  43590. */
  43591. static get Now(): number;
  43592. /**
  43593. * This method will return the name of the class used to create the instance of the given object.
  43594. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43595. * @param object the object to get the class name from
  43596. * @param isType defines if the object is actually a type
  43597. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43598. */
  43599. static GetClassName(object: any, isType?: boolean): string;
  43600. /**
  43601. * Gets the first element of an array satisfying a given predicate
  43602. * @param array defines the array to browse
  43603. * @param predicate defines the predicate to use
  43604. * @returns null if not found or the element
  43605. */
  43606. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43607. /**
  43608. * This method will return the name of the full name of the class, including its owning module (if any).
  43609. * 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).
  43610. * @param object the object to get the class name from
  43611. * @param isType defines if the object is actually a type
  43612. * @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.
  43613. * @ignorenaming
  43614. */
  43615. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43616. /**
  43617. * Returns a promise that resolves after the given amount of time.
  43618. * @param delay Number of milliseconds to delay
  43619. * @returns Promise that resolves after the given amount of time
  43620. */
  43621. static DelayAsync(delay: number): Promise<void>;
  43622. /**
  43623. * Utility function to detect if the current user agent is Safari
  43624. * @returns whether or not the current user agent is safari
  43625. */
  43626. static IsSafari(): boolean;
  43627. }
  43628. /**
  43629. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43630. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43631. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43632. * @param name The name of the class, case should be preserved
  43633. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43634. */
  43635. export function className(name: string, module?: string): (target: Object) => void;
  43636. /**
  43637. * An implementation of a loop for asynchronous functions.
  43638. */
  43639. export class AsyncLoop {
  43640. /**
  43641. * Defines the number of iterations for the loop
  43642. */
  43643. iterations: number;
  43644. /**
  43645. * Defines the current index of the loop.
  43646. */
  43647. index: number;
  43648. private _done;
  43649. private _fn;
  43650. private _successCallback;
  43651. /**
  43652. * Constructor.
  43653. * @param iterations the number of iterations.
  43654. * @param func the function to run each iteration
  43655. * @param successCallback the callback that will be called upon successful execution
  43656. * @param offset starting offset.
  43657. */
  43658. constructor(
  43659. /**
  43660. * Defines the number of iterations for the loop
  43661. */
  43662. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43663. /**
  43664. * Execute the next iteration. Must be called after the last iteration was finished.
  43665. */
  43666. executeNext(): void;
  43667. /**
  43668. * Break the loop and run the success callback.
  43669. */
  43670. breakLoop(): void;
  43671. /**
  43672. * Create and run an async loop.
  43673. * @param iterations the number of iterations.
  43674. * @param fn the function to run each iteration
  43675. * @param successCallback the callback that will be called upon successful execution
  43676. * @param offset starting offset.
  43677. * @returns the created async loop object
  43678. */
  43679. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43680. /**
  43681. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43682. * @param iterations total number of iterations
  43683. * @param syncedIterations number of synchronous iterations in each async iteration.
  43684. * @param fn the function to call each iteration.
  43685. * @param callback a success call back that will be called when iterating stops.
  43686. * @param breakFunction a break condition (optional)
  43687. * @param timeout timeout settings for the setTimeout function. default - 0.
  43688. * @returns the created async loop object
  43689. */
  43690. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43691. }
  43692. }
  43693. declare module BABYLON {
  43694. /**
  43695. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43696. * The underlying implementation relies on an associative array to ensure the best performances.
  43697. * The value can be anything including 'null' but except 'undefined'
  43698. */
  43699. export class StringDictionary<T> {
  43700. /**
  43701. * This will clear this dictionary and copy the content from the 'source' one.
  43702. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43703. * @param source the dictionary to take the content from and copy to this dictionary
  43704. */
  43705. copyFrom(source: StringDictionary<T>): void;
  43706. /**
  43707. * Get a value based from its key
  43708. * @param key the given key to get the matching value from
  43709. * @return the value if found, otherwise undefined is returned
  43710. */
  43711. get(key: string): T | undefined;
  43712. /**
  43713. * Get a value from its key or add it if it doesn't exist.
  43714. * This method will ensure you that a given key/data will be present in the dictionary.
  43715. * @param key the given key to get the matching value from
  43716. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43717. * The factory will only be invoked if there's no data for the given key.
  43718. * @return the value corresponding to the key.
  43719. */
  43720. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43721. /**
  43722. * Get a value from its key if present in the dictionary otherwise add it
  43723. * @param key the key to get the value from
  43724. * @param val if there's no such key/value pair in the dictionary add it with this value
  43725. * @return the value corresponding to the key
  43726. */
  43727. getOrAdd(key: string, val: T): T;
  43728. /**
  43729. * Check if there's a given key in the dictionary
  43730. * @param key the key to check for
  43731. * @return true if the key is present, false otherwise
  43732. */
  43733. contains(key: string): boolean;
  43734. /**
  43735. * Add a new key and its corresponding value
  43736. * @param key the key to add
  43737. * @param value the value corresponding to the key
  43738. * @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
  43739. */
  43740. add(key: string, value: T): boolean;
  43741. /**
  43742. * Update a specific value associated to a key
  43743. * @param key defines the key to use
  43744. * @param value defines the value to store
  43745. * @returns true if the value was updated (or false if the key was not found)
  43746. */
  43747. set(key: string, value: T): boolean;
  43748. /**
  43749. * Get the element of the given key and remove it from the dictionary
  43750. * @param key defines the key to search
  43751. * @returns the value associated with the key or null if not found
  43752. */
  43753. getAndRemove(key: string): Nullable<T>;
  43754. /**
  43755. * Remove a key/value from the dictionary.
  43756. * @param key the key to remove
  43757. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43758. */
  43759. remove(key: string): boolean;
  43760. /**
  43761. * Clear the whole content of the dictionary
  43762. */
  43763. clear(): void;
  43764. /**
  43765. * Gets the current count
  43766. */
  43767. get count(): number;
  43768. /**
  43769. * Execute a callback on each key/val of the dictionary.
  43770. * Note that you can remove any element in this dictionary in the callback implementation
  43771. * @param callback the callback to execute on a given key/value pair
  43772. */
  43773. forEach(callback: (key: string, val: T) => void): void;
  43774. /**
  43775. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43776. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43777. * Note that you can remove any element in this dictionary in the callback implementation
  43778. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43779. * @returns the first item
  43780. */
  43781. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43782. private _count;
  43783. private _data;
  43784. }
  43785. }
  43786. declare module BABYLON {
  43787. /** @hidden */
  43788. export interface ICollisionCoordinator {
  43789. createCollider(): Collider;
  43790. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43791. init(scene: Scene): void;
  43792. }
  43793. /** @hidden */
  43794. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43795. private _scene;
  43796. private _scaledPosition;
  43797. private _scaledVelocity;
  43798. private _finalPosition;
  43799. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43800. createCollider(): Collider;
  43801. init(scene: Scene): void;
  43802. private _collideWithWorld;
  43803. }
  43804. }
  43805. declare module BABYLON {
  43806. /**
  43807. * Class used to manage all inputs for the scene.
  43808. */
  43809. export class InputManager {
  43810. /** The distance in pixel that you have to move to prevent some events */
  43811. static DragMovementThreshold: number;
  43812. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43813. static LongPressDelay: number;
  43814. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43815. static DoubleClickDelay: number;
  43816. /** If you need to check double click without raising a single click at first click, enable this flag */
  43817. static ExclusiveDoubleClickMode: boolean;
  43818. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  43819. private _alreadyAttached;
  43820. private _alreadyAttachedTo;
  43821. private _wheelEventName;
  43822. private _onPointerMove;
  43823. private _onPointerDown;
  43824. private _onPointerUp;
  43825. private _initClickEvent;
  43826. private _initActionManager;
  43827. private _delayedSimpleClick;
  43828. private _delayedSimpleClickTimeout;
  43829. private _previousDelayedSimpleClickTimeout;
  43830. private _meshPickProceed;
  43831. private _previousButtonPressed;
  43832. private _currentPickResult;
  43833. private _previousPickResult;
  43834. private _totalPointersPressed;
  43835. private _doubleClickOccured;
  43836. private _pointerOverMesh;
  43837. private _pickedDownMesh;
  43838. private _pickedUpMesh;
  43839. private _pointerX;
  43840. private _pointerY;
  43841. private _unTranslatedPointerX;
  43842. private _unTranslatedPointerY;
  43843. private _startingPointerPosition;
  43844. private _previousStartingPointerPosition;
  43845. private _startingPointerTime;
  43846. private _previousStartingPointerTime;
  43847. private _pointerCaptures;
  43848. private _meshUnderPointerId;
  43849. private _onKeyDown;
  43850. private _onKeyUp;
  43851. private _keyboardIsAttached;
  43852. private _onCanvasFocusObserver;
  43853. private _onCanvasBlurObserver;
  43854. private _scene;
  43855. /**
  43856. * Creates a new InputManager
  43857. * @param scene defines the hosting scene
  43858. */
  43859. constructor(scene: Scene);
  43860. /**
  43861. * Gets the mesh that is currently under the pointer
  43862. */
  43863. get meshUnderPointer(): Nullable<AbstractMesh>;
  43864. /**
  43865. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43866. * @param pointerId the pointer id to use
  43867. * @returns The mesh under this pointer id or null if not found
  43868. */
  43869. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43870. /**
  43871. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43872. */
  43873. get unTranslatedPointer(): Vector2;
  43874. /**
  43875. * Gets or sets the current on-screen X position of the pointer
  43876. */
  43877. get pointerX(): number;
  43878. set pointerX(value: number);
  43879. /**
  43880. * Gets or sets the current on-screen Y position of the pointer
  43881. */
  43882. get pointerY(): number;
  43883. set pointerY(value: number);
  43884. private _updatePointerPosition;
  43885. private _processPointerMove;
  43886. private _setRayOnPointerInfo;
  43887. private _checkPrePointerObservable;
  43888. /**
  43889. * Use this method to simulate a pointer move on a mesh
  43890. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43891. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43892. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43893. */
  43894. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43895. /**
  43896. * Use this method to simulate a pointer down on a mesh
  43897. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43898. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43899. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43900. */
  43901. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43902. private _processPointerDown;
  43903. /** @hidden */
  43904. _isPointerSwiping(): boolean;
  43905. /**
  43906. * Use this method to simulate a pointer up on a mesh
  43907. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43908. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43909. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43910. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43911. */
  43912. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43913. private _processPointerUp;
  43914. /**
  43915. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43916. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43917. * @returns true if the pointer was captured
  43918. */
  43919. isPointerCaptured(pointerId?: number): boolean;
  43920. /**
  43921. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43922. * @param attachUp defines if you want to attach events to pointerup
  43923. * @param attachDown defines if you want to attach events to pointerdown
  43924. * @param attachMove defines if you want to attach events to pointermove
  43925. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43926. */
  43927. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43928. /**
  43929. * Detaches all event handlers
  43930. */
  43931. detachControl(): void;
  43932. /**
  43933. * Force the value of meshUnderPointer
  43934. * @param mesh defines the mesh to use
  43935. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43936. */
  43937. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43938. /**
  43939. * Gets the mesh under the pointer
  43940. * @returns a Mesh or null if no mesh is under the pointer
  43941. */
  43942. getPointerOverMesh(): Nullable<AbstractMesh>;
  43943. }
  43944. }
  43945. declare module BABYLON {
  43946. /**
  43947. * This class defines the direct association between an animation and a target
  43948. */
  43949. export class TargetedAnimation {
  43950. /**
  43951. * Animation to perform
  43952. */
  43953. animation: Animation;
  43954. /**
  43955. * Target to animate
  43956. */
  43957. target: any;
  43958. /**
  43959. * Returns the string "TargetedAnimation"
  43960. * @returns "TargetedAnimation"
  43961. */
  43962. getClassName(): string;
  43963. /**
  43964. * Serialize the object
  43965. * @returns the JSON object representing the current entity
  43966. */
  43967. serialize(): any;
  43968. }
  43969. /**
  43970. * Use this class to create coordinated animations on multiple targets
  43971. */
  43972. export class AnimationGroup implements IDisposable {
  43973. /** The name of the animation group */
  43974. name: string;
  43975. private _scene;
  43976. private _targetedAnimations;
  43977. private _animatables;
  43978. private _from;
  43979. private _to;
  43980. private _isStarted;
  43981. private _isPaused;
  43982. private _speedRatio;
  43983. private _loopAnimation;
  43984. private _isAdditive;
  43985. /**
  43986. * Gets or sets the unique id of the node
  43987. */
  43988. uniqueId: number;
  43989. /**
  43990. * This observable will notify when one animation have ended
  43991. */
  43992. onAnimationEndObservable: Observable<TargetedAnimation>;
  43993. /**
  43994. * Observer raised when one animation loops
  43995. */
  43996. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43997. /**
  43998. * Observer raised when all animations have looped
  43999. */
  44000. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44001. /**
  44002. * This observable will notify when all animations have ended.
  44003. */
  44004. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44005. /**
  44006. * This observable will notify when all animations have paused.
  44007. */
  44008. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44009. /**
  44010. * This observable will notify when all animations are playing.
  44011. */
  44012. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44013. /**
  44014. * Gets the first frame
  44015. */
  44016. get from(): number;
  44017. /**
  44018. * Gets the last frame
  44019. */
  44020. get to(): number;
  44021. /**
  44022. * Define if the animations are started
  44023. */
  44024. get isStarted(): boolean;
  44025. /**
  44026. * Gets a value indicating that the current group is playing
  44027. */
  44028. get isPlaying(): boolean;
  44029. /**
  44030. * Gets or sets the speed ratio to use for all animations
  44031. */
  44032. get speedRatio(): number;
  44033. /**
  44034. * Gets or sets the speed ratio to use for all animations
  44035. */
  44036. set speedRatio(value: number);
  44037. /**
  44038. * Gets or sets if all animations should loop or not
  44039. */
  44040. get loopAnimation(): boolean;
  44041. set loopAnimation(value: boolean);
  44042. /**
  44043. * Gets or sets if all animations should be evaluated additively
  44044. */
  44045. get isAdditive(): boolean;
  44046. set isAdditive(value: boolean);
  44047. /**
  44048. * Gets the targeted animations for this animation group
  44049. */
  44050. get targetedAnimations(): Array<TargetedAnimation>;
  44051. /**
  44052. * returning the list of animatables controlled by this animation group.
  44053. */
  44054. get animatables(): Array<Animatable>;
  44055. /**
  44056. * Gets the list of target animations
  44057. */
  44058. get children(): TargetedAnimation[];
  44059. /**
  44060. * Instantiates a new Animation Group.
  44061. * This helps managing several animations at once.
  44062. * @see https://doc.babylonjs.com/how_to/group
  44063. * @param name Defines the name of the group
  44064. * @param scene Defines the scene the group belongs to
  44065. */
  44066. constructor(
  44067. /** The name of the animation group */
  44068. name: string, scene?: Nullable<Scene>);
  44069. /**
  44070. * Add an animation (with its target) in the group
  44071. * @param animation defines the animation we want to add
  44072. * @param target defines the target of the animation
  44073. * @returns the TargetedAnimation object
  44074. */
  44075. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44076. /**
  44077. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44078. * It can add constant keys at begin or end
  44079. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44080. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44081. * @returns the animation group
  44082. */
  44083. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44084. private _animationLoopCount;
  44085. private _animationLoopFlags;
  44086. private _processLoop;
  44087. /**
  44088. * Start all animations on given targets
  44089. * @param loop defines if animations must loop
  44090. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44091. * @param from defines the from key (optional)
  44092. * @param to defines the to key (optional)
  44093. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44094. * @returns the current animation group
  44095. */
  44096. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44097. /**
  44098. * Pause all animations
  44099. * @returns the animation group
  44100. */
  44101. pause(): AnimationGroup;
  44102. /**
  44103. * Play all animations to initial state
  44104. * This function will start() the animations if they were not started or will restart() them if they were paused
  44105. * @param loop defines if animations must loop
  44106. * @returns the animation group
  44107. */
  44108. play(loop?: boolean): AnimationGroup;
  44109. /**
  44110. * Reset all animations to initial state
  44111. * @returns the animation group
  44112. */
  44113. reset(): AnimationGroup;
  44114. /**
  44115. * Restart animations from key 0
  44116. * @returns the animation group
  44117. */
  44118. restart(): AnimationGroup;
  44119. /**
  44120. * Stop all animations
  44121. * @returns the animation group
  44122. */
  44123. stop(): AnimationGroup;
  44124. /**
  44125. * Set animation weight for all animatables
  44126. * @param weight defines the weight to use
  44127. * @return the animationGroup
  44128. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44129. */
  44130. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44131. /**
  44132. * Synchronize and normalize all animatables with a source animatable
  44133. * @param root defines the root animatable to synchronize with
  44134. * @return the animationGroup
  44135. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44136. */
  44137. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44138. /**
  44139. * Goes to a specific frame in this animation group
  44140. * @param frame the frame number to go to
  44141. * @return the animationGroup
  44142. */
  44143. goToFrame(frame: number): AnimationGroup;
  44144. /**
  44145. * Dispose all associated resources
  44146. */
  44147. dispose(): void;
  44148. private _checkAnimationGroupEnded;
  44149. /**
  44150. * Clone the current animation group and returns a copy
  44151. * @param newName defines the name of the new group
  44152. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44153. * @returns the new animation group
  44154. */
  44155. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44156. /**
  44157. * Serializes the animationGroup to an object
  44158. * @returns Serialized object
  44159. */
  44160. serialize(): any;
  44161. /**
  44162. * Returns a new AnimationGroup object parsed from the source provided.
  44163. * @param parsedAnimationGroup defines the source
  44164. * @param scene defines the scene that will receive the animationGroup
  44165. * @returns a new AnimationGroup
  44166. */
  44167. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44168. /**
  44169. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44170. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44171. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44172. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44173. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44174. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44175. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44176. */
  44177. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44178. /**
  44179. * Returns the string "AnimationGroup"
  44180. * @returns "AnimationGroup"
  44181. */
  44182. getClassName(): string;
  44183. /**
  44184. * Creates a detailed string about the object
  44185. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44186. * @returns a string representing the object
  44187. */
  44188. toString(fullDetails?: boolean): string;
  44189. }
  44190. }
  44191. declare module BABYLON {
  44192. /**
  44193. * @hidden
  44194. **/
  44195. export class _TimeToken {
  44196. _startTimeQuery: Nullable<WebGLQuery>;
  44197. _endTimeQuery: Nullable<WebGLQuery>;
  44198. _timeElapsedQuery: Nullable<WebGLQuery>;
  44199. _timeElapsedQueryEnded: boolean;
  44200. }
  44201. }
  44202. declare module BABYLON {
  44203. /** @hidden */
  44204. export enum ExtensionName {
  44205. DepthClamping = "depth-clamping",
  44206. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44207. Depth32FloatStencil8 = "depth32float-stencil8",
  44208. PipelineStatisticsQuery = "pipeline-statistics-query",
  44209. TextureCompressionBC = "texture-compression-bc",
  44210. TimestampQuery = "timestamp-query"
  44211. }
  44212. /** @hidden */
  44213. export enum AddressMode {
  44214. ClampToEdge = "clamp-to-edge",
  44215. Repeat = "repeat",
  44216. MirrorRepeat = "mirror-repeat"
  44217. }
  44218. /** @hidden */
  44219. export enum BindingType {
  44220. UniformBuffer = "uniform-buffer",
  44221. StorageBuffer = "storage-buffer",
  44222. ReadonlyStorageBuffer = "readonly-storage-buffer",
  44223. Sampler = "sampler",
  44224. ComparisonSampler = "comparison-sampler",
  44225. SampledTexture = "sampled-texture",
  44226. ReadonlyStorageTexture = "readonly-storage-texture",
  44227. WriteonlyStorageTexture = "writeonly-storage-texture"
  44228. }
  44229. /** @hidden */
  44230. export enum BlendFactor {
  44231. Zero = "zero",
  44232. One = "one",
  44233. SrcColor = "src-color",
  44234. OneMinusSrcColor = "one-minus-src-color",
  44235. SrcAlpha = "src-alpha",
  44236. OneMinusSrcAlpha = "one-minus-src-alpha",
  44237. DstColor = "dst-color",
  44238. OneMinusDstColor = "one-minus-dst-color",
  44239. DstAlpha = "dst-alpha",
  44240. OneMinusDstAlpha = "one-minus-dst-alpha",
  44241. SrcAlphaSaturated = "src-alpha-saturated",
  44242. BlendColor = "blend-color",
  44243. OneMinusBlendColor = "one-minus-blend-color"
  44244. }
  44245. /** @hidden */
  44246. export enum BlendOperation {
  44247. Add = "add",
  44248. Subtract = "subtract",
  44249. ReverseSubtract = "reverse-subtract",
  44250. Min = "min",
  44251. Max = "max"
  44252. }
  44253. /** @hidden */
  44254. export enum CompareFunction {
  44255. Never = "never",
  44256. Less = "less",
  44257. Equal = "equal",
  44258. LessEqual = "less-equal",
  44259. Greater = "greater",
  44260. NotEqual = "not-equal",
  44261. GreaterEqual = "greater-equal",
  44262. Always = "always"
  44263. }
  44264. /** @hidden */
  44265. export enum CullMode {
  44266. None = "none",
  44267. Front = "front",
  44268. Back = "back"
  44269. }
  44270. /** @hidden */
  44271. export enum FilterMode {
  44272. Nearest = "nearest",
  44273. Linear = "linear"
  44274. }
  44275. /** @hidden */
  44276. export enum FrontFace {
  44277. CCW = "ccw",
  44278. CW = "cw"
  44279. }
  44280. /** @hidden */
  44281. export enum IndexFormat {
  44282. Uint16 = "uint16",
  44283. Uint32 = "uint32"
  44284. }
  44285. /** @hidden */
  44286. export enum InputStepMode {
  44287. Vertex = "vertex",
  44288. Instance = "instance"
  44289. }
  44290. /** @hidden */
  44291. export enum LoadOp {
  44292. Load = "load"
  44293. }
  44294. /** @hidden */
  44295. export enum PrimitiveTopology {
  44296. PointList = "point-list",
  44297. LineList = "line-list",
  44298. LineStrip = "line-strip",
  44299. TriangleList = "triangle-list",
  44300. TriangleStrip = "triangle-strip"
  44301. }
  44302. /** @hidden */
  44303. export enum StencilOperation {
  44304. Keep = "keep",
  44305. Zero = "zero",
  44306. Replace = "replace",
  44307. Invert = "invert",
  44308. IncrementClamp = "increment-clamp",
  44309. DecrementClamp = "decrement-clamp",
  44310. IncrementWrap = "increment-wrap",
  44311. DecrementWrap = "decrement-wrap"
  44312. }
  44313. /** @hidden */
  44314. export enum StoreOp {
  44315. Store = "store",
  44316. Clear = "clear"
  44317. }
  44318. /** @hidden */
  44319. export enum TextureDimension {
  44320. E1d = "1d",
  44321. E2d = "2d",
  44322. E3d = "3d"
  44323. }
  44324. /** @hidden */
  44325. export enum TextureFormat {
  44326. R8Unorm = "r8unorm",
  44327. R8Snorm = "r8snorm",
  44328. R8Uint = "r8uint",
  44329. R8Sint = "r8sint",
  44330. R16Uint = "r16uint",
  44331. R16Sint = "r16sint",
  44332. R16Float = "r16float",
  44333. RG8Unorm = "rg8unorm",
  44334. RG8Snorm = "rg8snorm",
  44335. RG8Uint = "rg8uint",
  44336. RG8Sint = "rg8sint",
  44337. R32Uint = "r32uint",
  44338. R32Sint = "r32sint",
  44339. R32Float = "r32float",
  44340. RG16Uint = "rg16uint",
  44341. RG16Sint = "rg16sint",
  44342. RG16Float = "rg16float",
  44343. RGBA8Unorm = "rgba8unorm",
  44344. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44345. RGBA8Snorm = "rgba8snorm",
  44346. RGBA8Uint = "rgba8uint",
  44347. RGBA8Sint = "rgba8sint",
  44348. BGRA8Unorm = "bgra8unorm",
  44349. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44350. RGB9E5UFloat = "rgb9e5ufloat",
  44351. RGB10A2Unorm = "rgb10a2unorm",
  44352. RG11B10UFloat = "rg11b10ufloat",
  44353. RG32Uint = "rg32uint",
  44354. RG32Sint = "rg32sint",
  44355. RG32Float = "rg32float",
  44356. RGBA16Uint = "rgba16uint",
  44357. RGBA16Sint = "rgba16sint",
  44358. RGBA16Float = "rgba16float",
  44359. RGBA32Uint = "rgba32uint",
  44360. RGBA32Sint = "rgba32sint",
  44361. RGBA32Float = "rgba32float",
  44362. Stencil8 = "stencil8",
  44363. Depth16Unorm = "depth16unorm",
  44364. Depth24Plus = "depth24plus",
  44365. Depth24PlusStencil8 = "depth24plus-stencil8",
  44366. Depth32Float = "depth32float",
  44367. BC1RGBAUNorm = "bc1-rgba-unorm",
  44368. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44369. BC2RGBAUnorm = "bc2-rgba-unorm",
  44370. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44371. BC3RGBAUnorm = "bc3-rgba-unorm",
  44372. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44373. BC4RUnorm = "bc4-r-unorm",
  44374. BC4RSnorm = "bc4-r-snorm",
  44375. BC5RGUnorm = "bc5-rg-unorm",
  44376. BC5RGSnorm = "bc5-rg-snorm",
  44377. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44378. BC6HRGBFloat = "bc6h-rgb-float",
  44379. BC7RGBAUnorm = "bc7-rgba-unorm",
  44380. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44381. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44382. Depth32FloatStencil8 = "depth32float-stencil8"
  44383. }
  44384. /** @hidden */
  44385. export enum TextureComponentType {
  44386. Float = "float",
  44387. Sint = "sint",
  44388. Uint = "uint",
  44389. DepthComparison = "depth-comparison"
  44390. }
  44391. /** @hidden */
  44392. export enum TextureViewDimension {
  44393. E1d = "1d",
  44394. E2d = "2d",
  44395. E2dArray = "2d-array",
  44396. Cube = "cube",
  44397. CubeArray = "cube-array",
  44398. E3d = "3d"
  44399. }
  44400. /** @hidden */
  44401. export enum VertexFormat {
  44402. Uchar2 = "uchar2",
  44403. Uchar4 = "uchar4",
  44404. Char2 = "char2",
  44405. Char4 = "char4",
  44406. Uchar2Norm = "uchar2norm",
  44407. Uchar4Norm = "uchar4norm",
  44408. Char2Norm = "char2norm",
  44409. Char4Norm = "char4norm",
  44410. Ushort2 = "ushort2",
  44411. Ushort4 = "ushort4",
  44412. Short2 = "short2",
  44413. Short4 = "short4",
  44414. Ushort2Norm = "ushort2norm",
  44415. Ushort4Norm = "ushort4norm",
  44416. Short2Norm = "short2norm",
  44417. Short4Norm = "short4norm",
  44418. Half2 = "half2",
  44419. Half4 = "half4",
  44420. Float = "float",
  44421. Float2 = "float2",
  44422. Float3 = "float3",
  44423. Float4 = "float4",
  44424. Uint = "uint",
  44425. Uint2 = "uint2",
  44426. Uint3 = "uint3",
  44427. Uint4 = "uint4",
  44428. Int = "int",
  44429. Int2 = "int2",
  44430. Int3 = "int3",
  44431. Int4 = "int4"
  44432. }
  44433. /** @hidden */
  44434. export enum TextureAspect {
  44435. All = "all",
  44436. StencilOnly = "stencil-only",
  44437. DepthOnly = "depth-only"
  44438. }
  44439. /** @hidden */
  44440. export enum CompilationMessageType {
  44441. Error = "error",
  44442. Warning = "warning",
  44443. Info = "info"
  44444. }
  44445. /** @hidden */
  44446. export enum QueryType {
  44447. Occlusion = "occlusion"
  44448. }
  44449. /** @hidden */
  44450. export enum BufferUsage {
  44451. MapRead = 1,
  44452. MapWrite = 2,
  44453. CopySrc = 4,
  44454. CopyDst = 8,
  44455. Index = 16,
  44456. Vertex = 32,
  44457. Uniform = 64,
  44458. Storage = 128,
  44459. Indirect = 256,
  44460. QueryResolve = 512
  44461. }
  44462. /** @hidden */
  44463. export enum ColorWrite {
  44464. Red = 1,
  44465. Green = 2,
  44466. Blue = 4,
  44467. Alpha = 8,
  44468. All = 15
  44469. }
  44470. /** @hidden */
  44471. export enum ShaderStage {
  44472. Vertex = 1,
  44473. Fragment = 2,
  44474. Compute = 4
  44475. }
  44476. /** @hidden */
  44477. export enum TextureUsage {
  44478. CopySrc = 1,
  44479. CopyDst = 2,
  44480. Sampled = 4,
  44481. Storage = 8,
  44482. OutputAttachment = 16
  44483. }
  44484. /** @hidden */
  44485. export enum MapMode {
  44486. Read = 1,
  44487. Write = 2
  44488. }
  44489. }
  44490. declare module BABYLON {
  44491. /** @hidden */
  44492. export interface WebGPUBindingInfo {
  44493. setIndex: number;
  44494. bindingIndex: number;
  44495. }
  44496. /** @hidden */
  44497. export interface WebGPUTextureSamplerBindingDescription {
  44498. sampler: WebGPUBindingInfo;
  44499. isTextureArray: boolean;
  44500. textures: Array<WebGPUBindingInfo>;
  44501. }
  44502. /** @hidden
  44503. * If the binding is a UBO, isSampler=isTexture=false
  44504. */
  44505. export interface WebGPUBindingDescription {
  44506. name: string;
  44507. usedInVertex: boolean;
  44508. usedInFragment: boolean;
  44509. isSampler: boolean;
  44510. isComparisonSampler?: boolean;
  44511. isTexture: boolean;
  44512. componentType?: GPUTextureComponentType;
  44513. textureDimension?: GPUTextureViewDimension;
  44514. }
  44515. /**
  44516. * @hidden
  44517. */
  44518. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44519. uboNextBindingIndex: number;
  44520. freeSetIndex: number;
  44521. freeBindingIndex: number;
  44522. availableVaryings: {
  44523. [key: string]: number;
  44524. };
  44525. availableAttributes: {
  44526. [key: string]: number;
  44527. };
  44528. availableUBOs: {
  44529. [key: string]: {
  44530. setIndex: number;
  44531. bindingIndex: number;
  44532. };
  44533. };
  44534. availableSamplers: {
  44535. [key: string]: WebGPUTextureSamplerBindingDescription;
  44536. };
  44537. leftOverUniforms: {
  44538. name: string;
  44539. type: string;
  44540. length: number;
  44541. }[];
  44542. orderedAttributes: string[];
  44543. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44544. uniformBufferNames: string[];
  44545. private _attributeNextLocation;
  44546. private _varyingNextLocation;
  44547. constructor();
  44548. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44549. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44550. getNextFreeUBOBinding(): {
  44551. setIndex: number;
  44552. bindingIndex: number;
  44553. };
  44554. private _getNextFreeBinding;
  44555. }
  44556. }
  44557. declare module BABYLON {
  44558. /** @hidden */
  44559. export interface IWebGPUPipelineContextSamplerCache {
  44560. samplerBinding: number;
  44561. firstTextureName: string;
  44562. }
  44563. /** @hidden */
  44564. export interface IWebGPUPipelineContextTextureCache {
  44565. textureBinding: number;
  44566. texture: InternalTexture;
  44567. }
  44568. /** @hidden */
  44569. export interface IWebGPUPipelineContextVertexInputsCache {
  44570. indexBuffer: Nullable<GPUBuffer>;
  44571. indexOffset: number;
  44572. vertexStartSlot: number;
  44573. vertexBuffers: GPUBuffer[];
  44574. vertexOffsets: number[];
  44575. }
  44576. /** @hidden */
  44577. export interface IWebGPURenderPipelineStageDescriptor {
  44578. vertexStage: GPUProgrammableStageDescriptor;
  44579. fragmentStage?: GPUProgrammableStageDescriptor;
  44580. }
  44581. /** @hidden */
  44582. export class WebGPUPipelineContext implements IPipelineContext {
  44583. engine: WebGPUEngine;
  44584. shaderProcessingContext: WebGPUShaderProcessingContext;
  44585. leftOverUniformsByName: {
  44586. [name: string]: string;
  44587. };
  44588. sources: {
  44589. vertex: string;
  44590. fragment: string;
  44591. rawVertex: string;
  44592. rawFragment: string;
  44593. };
  44594. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44595. samplers: {
  44596. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44597. };
  44598. textures: {
  44599. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44600. };
  44601. bindGroupLayouts: GPUBindGroupLayout[];
  44602. bindGroupsCache: {
  44603. [key: string]: GPUBindGroup[];
  44604. };
  44605. /**
  44606. * Stores the uniform buffer
  44607. */
  44608. uniformBuffer: Nullable<UniformBuffer>;
  44609. onCompiled?: () => void;
  44610. get isAsync(): boolean;
  44611. get isReady(): boolean;
  44612. /** @hidden */
  44613. _name: string;
  44614. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44615. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44616. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44617. [key: string]: number;
  44618. }, uniformsNames: string[], uniforms: {
  44619. [key: string]: Nullable<WebGLUniformLocation>;
  44620. }, samplerList: string[], samplers: {
  44621. [key: string]: number;
  44622. }, attributesNames: string[], attributes: number[]): void;
  44623. /** @hidden */
  44624. /**
  44625. * Build the uniform buffer used in the material.
  44626. */
  44627. buildUniformLayout(): void;
  44628. /**
  44629. * Release all associated resources.
  44630. **/
  44631. dispose(): void;
  44632. /**
  44633. * Sets an integer value on a uniform variable.
  44634. * @param uniformName Name of the variable.
  44635. * @param value Value to be set.
  44636. */
  44637. setInt(uniformName: string, value: number): void;
  44638. /**
  44639. * Sets an int2 value on a uniform variable.
  44640. * @param uniformName Name of the variable.
  44641. * @param x First int in int2.
  44642. * @param y Second int in int2.
  44643. */
  44644. setInt2(uniformName: string, x: number, y: number): void;
  44645. /**
  44646. * Sets an int3 value on a uniform variable.
  44647. * @param uniformName Name of the variable.
  44648. * @param x First int in int3.
  44649. * @param y Second int in int3.
  44650. * @param z Third int in int3.
  44651. */
  44652. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44653. /**
  44654. * Sets an int4 value on a uniform variable.
  44655. * @param uniformName Name of the variable.
  44656. * @param x First int in int4.
  44657. * @param y Second int in int4.
  44658. * @param z Third int in int4.
  44659. * @param w Fourth int in int4.
  44660. */
  44661. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44662. /**
  44663. * Sets an int array on a uniform variable.
  44664. * @param uniformName Name of the variable.
  44665. * @param array array to be set.
  44666. */
  44667. setIntArray(uniformName: string, array: Int32Array): void;
  44668. /**
  44669. * 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)
  44670. * @param uniformName Name of the variable.
  44671. * @param array array to be set.
  44672. */
  44673. setIntArray2(uniformName: string, array: Int32Array): void;
  44674. /**
  44675. * 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)
  44676. * @param uniformName Name of the variable.
  44677. * @param array array to be set.
  44678. */
  44679. setIntArray3(uniformName: string, array: Int32Array): void;
  44680. /**
  44681. * 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)
  44682. * @param uniformName Name of the variable.
  44683. * @param array array to be set.
  44684. */
  44685. setIntArray4(uniformName: string, array: Int32Array): void;
  44686. /**
  44687. * Sets an array on a uniform variable.
  44688. * @param uniformName Name of the variable.
  44689. * @param array array to be set.
  44690. */
  44691. setArray(uniformName: string, array: number[]): void;
  44692. /**
  44693. * 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)
  44694. * @param uniformName Name of the variable.
  44695. * @param array array to be set.
  44696. */
  44697. setArray2(uniformName: string, array: number[]): void;
  44698. /**
  44699. * 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)
  44700. * @param uniformName Name of the variable.
  44701. * @param array array to be set.
  44702. * @returns this effect.
  44703. */
  44704. setArray3(uniformName: string, array: number[]): void;
  44705. /**
  44706. * 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)
  44707. * @param uniformName Name of the variable.
  44708. * @param array array to be set.
  44709. */
  44710. setArray4(uniformName: string, array: number[]): void;
  44711. /**
  44712. * Sets matrices on a uniform variable.
  44713. * @param uniformName Name of the variable.
  44714. * @param matrices matrices to be set.
  44715. */
  44716. setMatrices(uniformName: string, matrices: Float32Array): void;
  44717. /**
  44718. * Sets matrix on a uniform variable.
  44719. * @param uniformName Name of the variable.
  44720. * @param matrix matrix to be set.
  44721. */
  44722. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44723. /**
  44724. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  44725. * @param uniformName Name of the variable.
  44726. * @param matrix matrix to be set.
  44727. */
  44728. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44729. /**
  44730. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44731. * @param uniformName Name of the variable.
  44732. * @param matrix matrix to be set.
  44733. */
  44734. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44735. /**
  44736. * Sets a float on a uniform variable.
  44737. * @param uniformName Name of the variable.
  44738. * @param value value to be set.
  44739. * @returns this effect.
  44740. */
  44741. setFloat(uniformName: string, value: number): void;
  44742. /**
  44743. * Sets a Vector2 on a uniform variable.
  44744. * @param uniformName Name of the variable.
  44745. * @param vector2 vector2 to be set.
  44746. */
  44747. setVector2(uniformName: string, vector2: IVector2Like): void;
  44748. /**
  44749. * Sets a float2 on a uniform variable.
  44750. * @param uniformName Name of the variable.
  44751. * @param x First float in float2.
  44752. * @param y Second float in float2.
  44753. */
  44754. setFloat2(uniformName: string, x: number, y: number): void;
  44755. /**
  44756. * Sets a Vector3 on a uniform variable.
  44757. * @param uniformName Name of the variable.
  44758. * @param vector3 Value to be set.
  44759. */
  44760. setVector3(uniformName: string, vector3: IVector3Like): void;
  44761. /**
  44762. * Sets a float3 on a uniform variable.
  44763. * @param uniformName Name of the variable.
  44764. * @param x First float in float3.
  44765. * @param y Second float in float3.
  44766. * @param z Third float in float3.
  44767. */
  44768. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44769. /**
  44770. * Sets a Vector4 on a uniform variable.
  44771. * @param uniformName Name of the variable.
  44772. * @param vector4 Value to be set.
  44773. */
  44774. setVector4(uniformName: string, vector4: IVector4Like): void;
  44775. /**
  44776. * Sets a float4 on a uniform variable.
  44777. * @param uniformName Name of the variable.
  44778. * @param x First float in float4.
  44779. * @param y Second float in float4.
  44780. * @param z Third float in float4.
  44781. * @param w Fourth float in float4.
  44782. * @returns this effect.
  44783. */
  44784. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44785. /**
  44786. * Sets a Color3 on a uniform variable.
  44787. * @param uniformName Name of the variable.
  44788. * @param color3 Value to be set.
  44789. */
  44790. setColor3(uniformName: string, color3: IColor3Like): void;
  44791. /**
  44792. * Sets a Color4 on a uniform variable.
  44793. * @param uniformName Name of the variable.
  44794. * @param color3 Value to be set.
  44795. * @param alpha Alpha value to be set.
  44796. */
  44797. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44798. /**
  44799. * Sets a Color4 on a uniform variable
  44800. * @param uniformName defines the name of the variable
  44801. * @param color4 defines the value to be set
  44802. */
  44803. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44804. _getVertexShaderCode(): string | null;
  44805. _getFragmentShaderCode(): string | null;
  44806. }
  44807. }
  44808. declare module BABYLON {
  44809. /** @hidden */
  44810. export class WebGPUDataBuffer extends DataBuffer {
  44811. private _buffer;
  44812. constructor(resource: GPUBuffer);
  44813. get underlyingResource(): any;
  44814. }
  44815. }
  44816. declare module BABYLON {
  44817. /**
  44818. * Class used to inline functions in shader code
  44819. */
  44820. export class ShaderCodeInliner {
  44821. private static readonly _RegexpFindFunctionNameAndType;
  44822. private _sourceCode;
  44823. private _functionDescr;
  44824. private _numMaxIterations;
  44825. /** Gets or sets the token used to mark the functions to inline */
  44826. inlineToken: string;
  44827. /** Gets or sets the debug mode */
  44828. debug: boolean;
  44829. /** Gets the code after the inlining process */
  44830. get code(): string;
  44831. /**
  44832. * Initializes the inliner
  44833. * @param sourceCode shader code source to inline
  44834. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44835. */
  44836. constructor(sourceCode: string, numMaxIterations?: number);
  44837. /**
  44838. * Start the processing of the shader code
  44839. */
  44840. processCode(): void;
  44841. private _collectFunctions;
  44842. private _processInlining;
  44843. private _extractBetweenMarkers;
  44844. private _skipWhitespaces;
  44845. private _isIdentifierChar;
  44846. private _removeComments;
  44847. private _replaceFunctionCallsByCode;
  44848. private _findBackward;
  44849. private _escapeRegExp;
  44850. private _replaceNames;
  44851. }
  44852. }
  44853. declare module BABYLON {
  44854. /** @hidden */
  44855. export class WebGPUShaderProcessor implements IShaderProcessor {
  44856. protected _missingVaryings: Array<string>;
  44857. protected _textureArrayProcessing: Array<string>;
  44858. protected _preProcessors: {
  44859. [key: string]: string;
  44860. };
  44861. private _getArraySize;
  44862. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44863. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44864. [key: string]: string;
  44865. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44866. attributeProcessor(attribute: string, preProcessors: {
  44867. [key: string]: string;
  44868. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44869. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44870. [key: string]: string;
  44871. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44872. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44873. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44874. private _applyTextureArrayProcessing;
  44875. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44876. vertexCode: string;
  44877. fragmentCode: string;
  44878. };
  44879. }
  44880. }
  44881. declare module BABYLON {
  44882. /** @hidden */
  44883. export class WebGPUBufferManager {
  44884. private _device;
  44885. private _deferredReleaseBuffers;
  44886. private static _IsGPUBuffer;
  44887. constructor(device: GPUDevice);
  44888. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44889. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44890. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44891. private _FromHalfFloat;
  44892. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44893. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44894. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44895. destroyDeferredBuffers(): void;
  44896. }
  44897. }
  44898. declare module BABYLON {
  44899. /** @hidden */
  44900. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  44901. private _webgpuTexture;
  44902. private _webgpuMSAATexture;
  44903. get underlyingResource(): Nullable<GPUTexture>;
  44904. get msaaTexture(): Nullable<GPUTexture>;
  44905. set msaaTexture(texture: Nullable<GPUTexture>);
  44906. view: Nullable<GPUTextureView>;
  44907. format: GPUTextureFormat;
  44908. textureUsages: number;
  44909. constructor(existingTexture?: Nullable<GPUTexture>);
  44910. set(hardwareTexture: GPUTexture): void;
  44911. setMSAATexture(hardwareTexture: GPUTexture): void;
  44912. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  44913. createView(descriptor?: GPUTextureViewDescriptor): void;
  44914. reset(): void;
  44915. release(): void;
  44916. }
  44917. }
  44918. declare module BABYLON {
  44919. /** @hidden */
  44920. export class WebGPUTextureHelper {
  44921. private _device;
  44922. private _glslang;
  44923. private _bufferManager;
  44924. private _mipmapSampler;
  44925. private _invertYPreMultiplyAlphaSampler;
  44926. private _pipelines;
  44927. private _compiledShaders;
  44928. private _deferredReleaseTextures;
  44929. private _commandEncoderForCreation;
  44930. static ComputeNumMipmapLevels(width: number, height: number): number;
  44931. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  44932. private _getPipeline;
  44933. private static _GetTextureTypeFromFormat;
  44934. private static _GetBlockInformationFromFormat;
  44935. private static _IsHardwareTexture;
  44936. private static _IsInternalTexture;
  44937. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  44938. static IsImageBitmap(imageBitmap: ImageBitmap | {
  44939. width: number;
  44940. height: number;
  44941. }): imageBitmap is ImageBitmap;
  44942. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  44943. width: number;
  44944. height: number;
  44945. }): imageBitmap is ImageBitmap[];
  44946. setCommandEncoder(encoder: GPUCommandEncoder): void;
  44947. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  44948. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  44949. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44950. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  44951. createTexture(imageBitmap: ImageBitmap | {
  44952. width: number;
  44953. height: number;
  44954. layers: number;
  44955. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44956. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  44957. width: number;
  44958. height: number;
  44959. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44960. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  44961. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44962. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  44963. createMSAATexture(texture: InternalTexture, samples: number): void;
  44964. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44965. updateTexture(imageBitmap: ImageBitmap | Uint8Array, gpuTexture: GPUTexture, width: number, height: number, layers: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44966. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  44967. releaseTexture(texture: InternalTexture | GPUTexture): void;
  44968. destroyDeferredTextures(): void;
  44969. }
  44970. }
  44971. declare module BABYLON {
  44972. /** @hidden */
  44973. export class WebGPURenderPassWrapper {
  44974. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  44975. renderPass: Nullable<GPURenderPassEncoder>;
  44976. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44977. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44978. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  44979. depthTextureFormat: GPUTextureFormat | undefined;
  44980. constructor();
  44981. reset(fullReset?: boolean): void;
  44982. }
  44983. }
  44984. declare module BABYLON {
  44985. /** @hidden */
  44986. export class WebGPUCacheSampler {
  44987. private _samplers;
  44988. private _device;
  44989. disabled: boolean;
  44990. constructor(device: GPUDevice);
  44991. private static _GetSamplerHashCode;
  44992. private static _GetSamplerFilterDescriptor;
  44993. private static _GetWrappingMode;
  44994. private static _GetSamplerWrappingDescriptor;
  44995. private static _GetSamplerDescriptor;
  44996. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  44997. }
  44998. }
  44999. declare module BABYLON {
  45000. /** @hidden */
  45001. export class WebGPUShaderManager {
  45002. private _shaders;
  45003. private _device;
  45004. constructor(device: GPUDevice);
  45005. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  45006. }
  45007. }
  45008. declare module BABYLON {
  45009. /** @hidden */
  45010. export class WebGPUCacheRenderPipeline {
  45011. static NumCacheHitWithoutHash: number;
  45012. static NumCacheHitWithHash: number;
  45013. static NumCacheMiss: number;
  45014. static NumPipelineCreationLastFrame: number;
  45015. disabled: boolean;
  45016. private static _Cache;
  45017. private static _NumPipelineCreationCurrentFrame;
  45018. private _device;
  45019. private _states;
  45020. private _isDirty;
  45021. private _currentRenderPipeline;
  45022. private _emptyVertexBuffer;
  45023. private _shaderId;
  45024. private _alphaToCoverageEnabled;
  45025. private _frontFace;
  45026. private _cullEnabled;
  45027. private _cullFace;
  45028. private _clampDepth;
  45029. private _rasterizationState;
  45030. private _depthBias;
  45031. private _depthBiasClamp;
  45032. private _depthBiasSlopeScale;
  45033. private _colorFormat;
  45034. private _webgpuColorFormat;
  45035. private _mrtAttachments1;
  45036. private _mrtAttachments2;
  45037. private _mrtFormats;
  45038. private _alphaBlendEnabled;
  45039. private _alphaBlendFuncParams;
  45040. private _alphaBlendEqParams;
  45041. private _writeMask;
  45042. private _colorStates;
  45043. private _depthStencilFormat;
  45044. private _webgpuDepthStencilFormat;
  45045. private _depthTestEnabled;
  45046. private _depthWriteEnabled;
  45047. private _depthCompare;
  45048. private _stencilEnabled;
  45049. private _stencilFrontCompare;
  45050. private _stencilFrontDepthFailOp;
  45051. private _stencilFrontPassOp;
  45052. private _stencilFrontFailOp;
  45053. private _stencilReadMask;
  45054. private _stencilWriteMask;
  45055. private _depthStencilState;
  45056. private _vertexBuffers;
  45057. private _overrideVertexBuffers;
  45058. private _indexBuffer;
  45059. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45060. reset(): void;
  45061. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  45062. endFrame(): void;
  45063. setAlphaToCoverage(enabled: boolean): void;
  45064. setFrontFace(frontFace: number): void;
  45065. setCullEnabled(enabled: boolean): void;
  45066. setCullFace(cullFace: number): void;
  45067. setClampDepth(clampDepth: boolean): void;
  45068. resetDepthCullingState(): void;
  45069. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  45070. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  45071. setColorFormat(format: GPUTextureFormat): void;
  45072. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  45073. setAlphaBlendEnabled(enabled: boolean): void;
  45074. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  45075. setWriteMask(mask: number): void;
  45076. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  45077. setDepthTestEnabled(enabled: boolean): void;
  45078. setDepthWriteEnabled(enabled: boolean): void;
  45079. setDepthCompare(func: Nullable<number>): void;
  45080. setStencilEnabled(enabled: boolean): void;
  45081. setStencilCompare(func: Nullable<number>): void;
  45082. setStencilDepthFailOp(op: Nullable<number>): void;
  45083. setStencilPassOp(op: Nullable<number>): void;
  45084. setStencilFailOp(op: Nullable<number>): void;
  45085. setStencilReadMask(mask: number): void;
  45086. setStencilWriteMask(mask: number): void;
  45087. resetStencilState(): void;
  45088. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  45089. setBuffers(vertexBuffers: Nullable<{
  45090. [key: string]: Nullable<VertexBuffer>;
  45091. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  45092. [key: string]: Nullable<VertexBuffer>;
  45093. }>): void;
  45094. private static _GetTopology;
  45095. private static _GetAphaBlendOperation;
  45096. private static _GetAphaBlendFactor;
  45097. private static _GetCompareFunction;
  45098. private static _GetStencilOpFunction;
  45099. private static _GetVertexInputDescriptorFormat;
  45100. private _getAphaBlendState;
  45101. private _getColorBlendState;
  45102. private _setShaderStage;
  45103. private _setRasterizationState;
  45104. private _setColorStates;
  45105. private _setDepthStencilState;
  45106. private _setVertexState;
  45107. private _createPipelineLayout;
  45108. private _getVertexInputDescriptor;
  45109. private _createRenderPipeline;
  45110. }
  45111. }
  45112. declare module BABYLON {
  45113. /** @hidden */
  45114. export var clearQuadVertexShader: {
  45115. name: string;
  45116. shader: string;
  45117. };
  45118. }
  45119. declare module BABYLON {
  45120. /** @hidden */
  45121. export var clearQuadPixelShader: {
  45122. name: string;
  45123. shader: string;
  45124. };
  45125. }
  45126. declare module BABYLON {
  45127. /**
  45128. * Options to load the associated Glslang library
  45129. */
  45130. export interface GlslangOptions {
  45131. /**
  45132. * Defines an existing instance of Glslang (useful in modules who do not access the global instance).
  45133. */
  45134. glslang?: any;
  45135. /**
  45136. * Defines the URL of the glslang JS File.
  45137. */
  45138. jsPath?: string;
  45139. /**
  45140. * Defines the URL of the glslang WASM File.
  45141. */
  45142. wasmPath?: string;
  45143. }
  45144. /**
  45145. * Options to create the WebGPU engine
  45146. */
  45147. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  45148. /**
  45149. * If delta time between frames should be constant
  45150. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45151. */
  45152. deterministicLockstep?: boolean;
  45153. /**
  45154. * Maximum about of steps between frames (Default: 4)
  45155. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45156. */
  45157. lockstepMaxSteps?: number;
  45158. /**
  45159. * Defines the seconds between each deterministic lock step
  45160. */
  45161. timeStep?: number;
  45162. /**
  45163. * Defines that engine should ignore modifying touch action attribute and style
  45164. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  45165. */
  45166. doNotHandleTouchAction?: boolean;
  45167. /**
  45168. * Defines if webaudio should be initialized as well
  45169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  45170. */
  45171. audioEngine?: boolean;
  45172. /**
  45173. * Defines the category of adapter to use.
  45174. * Is it the discrete or integrated device.
  45175. */
  45176. powerPreference?: GPUPowerPreference;
  45177. /**
  45178. * Defines the device descriptor used to create a device.
  45179. */
  45180. deviceDescriptor?: GPUDeviceDescriptor;
  45181. /**
  45182. * Defines the requested Swap Chain Format.
  45183. */
  45184. swapChainFormat?: GPUTextureFormat;
  45185. /**
  45186. * Defines whether MSAA is enabled on the canvas.
  45187. */
  45188. antialiasing?: boolean;
  45189. /**
  45190. * Defines whether the stencil buffer should be enabled.
  45191. */
  45192. stencil?: boolean;
  45193. /**
  45194. * Defines whether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  45195. */
  45196. enableGPUDebugMarkers?: boolean;
  45197. /**
  45198. * Options to load the associated Glslang library
  45199. */
  45200. glslangOptions?: GlslangOptions;
  45201. }
  45202. /**
  45203. * The web GPU engine class provides support for WebGPU version of babylon.js.
  45204. */
  45205. export class WebGPUEngine extends Engine {
  45206. private static readonly _glslangDefaultOptions;
  45207. private readonly _uploadEncoderDescriptor;
  45208. private readonly _renderEncoderDescriptor;
  45209. private readonly _renderTargetEncoderDescriptor;
  45210. private readonly _clearDepthValue;
  45211. private readonly _clearReverseDepthValue;
  45212. private readonly _clearStencilValue;
  45213. private readonly _defaultSampleCount;
  45214. private _canvas;
  45215. private _options;
  45216. private _glslang;
  45217. private _adapter;
  45218. private _adapterSupportedExtensions;
  45219. private _device;
  45220. private _deviceEnabledExtensions;
  45221. private _context;
  45222. private _swapChain;
  45223. private _swapChainTexture;
  45224. private _mainPassSampleCount;
  45225. private _textureHelper;
  45226. private _bufferManager;
  45227. private _shaderManager;
  45228. private _cacheSampler;
  45229. private _cacheRenderPipeline;
  45230. private _emptyVertexBuffer;
  45231. private _lastCachedWrapU;
  45232. private _lastCachedWrapV;
  45233. private _lastCachedWrapR;
  45234. private _mrtAttachments;
  45235. private _counters;
  45236. private _mainTexture;
  45237. private _depthTexture;
  45238. private _mainTextureExtends;
  45239. private _depthTextureFormat;
  45240. private _colorFormat;
  45241. private _uploadEncoder;
  45242. private _renderEncoder;
  45243. private _renderTargetEncoder;
  45244. private _commandBuffers;
  45245. private _currentRenderPass;
  45246. private _mainRenderPassWrapper;
  45247. private _rttRenderPassWrapper;
  45248. private _pendingDebugCommands;
  45249. private _currentVertexBuffers;
  45250. private _currentOverrideVertexBuffers;
  45251. private _currentIndexBuffer;
  45252. private __colorWrite;
  45253. private _uniformsBuffers;
  45254. private _forceEnableEffect;
  45255. /** @hidden */
  45256. dbgShowShaderCode: boolean;
  45257. /** @hidden */
  45258. dbgSanityChecks: boolean;
  45259. /** @hidden */
  45260. dbgGenerateLogs: boolean;
  45261. /** @hidden */
  45262. dbgVerboseLogsForFirstFrames: boolean;
  45263. /** @hidden */
  45264. dbgVerboseLogsNumFrames: number;
  45265. /** @hidden */
  45266. dbgShowWarningsNotImplemented: boolean;
  45267. /**
  45268. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  45269. */
  45270. get disableCacheSamplers(): boolean;
  45271. set disableCacheSamplers(disable: boolean);
  45272. /**
  45273. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  45274. */
  45275. get disableCacheRenderPipelines(): boolean;
  45276. set disableCacheRenderPipelines(disable: boolean);
  45277. /**
  45278. * Gets a boolean indicating if the engine can be instantiated (ie. if a WebGPU context can be found)
  45279. * @returns true if the engine can be created
  45280. */
  45281. static get IsSupported(): boolean;
  45282. /**
  45283. * Gets a boolean indicating that the engine supports uniform buffers
  45284. */
  45285. get supportsUniformBuffers(): boolean;
  45286. /** Gets the supported extensions by the WebGPU adapter */
  45287. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  45288. /** Gets the currently enabled extensions on the WebGPU device */
  45289. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  45290. /**
  45291. * Returns the name of the engine
  45292. */
  45293. get name(): string;
  45294. /**
  45295. * Returns a string describing the current engine
  45296. */
  45297. get description(): string;
  45298. /**
  45299. * Returns the version of the engine
  45300. */
  45301. get version(): number;
  45302. /**
  45303. * Create a new instance of the gpu engine asynchronously
  45304. * @param canvas Defines the canvas to use to display the result
  45305. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45306. * @returns a promise that resolves with the created engine
  45307. */
  45308. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  45309. /**
  45310. * Create a new instance of the gpu engine.
  45311. * @param canvas Defines the canvas to use to display the result
  45312. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45313. */
  45314. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  45315. /**
  45316. * Initializes the WebGPU context and dependencies.
  45317. * @param glslangOptions Defines the GLSLang compiler options if necessary
  45318. * @returns a promise notifying the readiness of the engine.
  45319. */
  45320. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  45321. private _initGlslang;
  45322. private _initializeLimits;
  45323. private _initializeContextAndSwapChain;
  45324. private _initializeMainAttachments;
  45325. /**
  45326. * Force a specific size of the canvas
  45327. * @param width defines the new canvas' width
  45328. * @param height defines the new canvas' height
  45329. * @param forceSetSize true to force setting the sizes of the underlying canvas
  45330. * @returns true if the size was changed
  45331. */
  45332. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  45333. /**
  45334. * Gets a shader processor implementation fitting with the current engine type.
  45335. * @returns The shader processor implementation.
  45336. */
  45337. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  45338. /** @hidden */
  45339. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  45340. /**
  45341. * Force the entire cache to be cleared
  45342. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  45343. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45344. */
  45345. wipeCaches(bruteForce?: boolean): void;
  45346. /**
  45347. * Enable or disable color writing
  45348. * @param enable defines the state to set
  45349. */
  45350. setColorWrite(enable: boolean): void;
  45351. /**
  45352. * Gets a boolean indicating if color writing is enabled
  45353. * @returns the current color writing state
  45354. */
  45355. getColorWrite(): boolean;
  45356. private _viewportsCurrent;
  45357. private _resetCurrentViewport;
  45358. private _applyViewport;
  45359. /** @hidden */
  45360. _viewport(x: number, y: number, width: number, height: number): void;
  45361. private _scissorsCurrent;
  45362. protected _scissorCached: {
  45363. x: number;
  45364. y: number;
  45365. z: number;
  45366. w: number;
  45367. };
  45368. private _resetCurrentScissor;
  45369. private _applyScissor;
  45370. private _scissorIsActive;
  45371. enableScissor(x: number, y: number, width: number, height: number): void;
  45372. disableScissor(): void;
  45373. /**
  45374. * Clear the current render buffer or the current render target (if any is set up)
  45375. * @param color defines the color to use
  45376. * @param backBuffer defines if the back buffer must be cleared
  45377. * @param depth defines if the depth buffer must be cleared
  45378. * @param stencil defines if the stencil buffer must be cleared
  45379. */
  45380. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45381. /**
  45382. * Clears a list of attachments
  45383. * @param attachments list of the attachments
  45384. * @param colorMain clear color for the main attachment (the first one)
  45385. * @param colorOthers clear color for the other attachments
  45386. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  45387. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  45388. */
  45389. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  45390. /**
  45391. * Creates a vertex buffer
  45392. * @param data the data for the vertex buffer
  45393. * @returns the new buffer
  45394. */
  45395. createVertexBuffer(data: DataArray): DataBuffer;
  45396. /**
  45397. * Creates a vertex buffer
  45398. * @param data the data for the dynamic vertex buffer
  45399. * @returns the new buffer
  45400. */
  45401. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45402. /**
  45403. * Updates a vertex buffer.
  45404. * @param vertexBuffer the vertex buffer to update
  45405. * @param data the data used to update the vertex buffer
  45406. * @param byteOffset the byte offset of the data
  45407. * @param byteLength the byte length of the data
  45408. */
  45409. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45410. /**
  45411. * Creates a new index buffer
  45412. * @param indices defines the content of the index buffer
  45413. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  45414. * @returns a new buffer
  45415. */
  45416. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  45417. /**
  45418. * Update an index buffer
  45419. * @param indexBuffer defines the target index buffer
  45420. * @param indices defines the data to update
  45421. * @param offset defines the offset in the target index buffer where update should start
  45422. */
  45423. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45424. /** @hidden */
  45425. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  45426. /** @hidden */
  45427. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  45428. /**
  45429. * Bind a list of vertex buffers with the engine
  45430. * @param vertexBuffers defines the list of vertex buffers to bind
  45431. * @param indexBuffer defines the index buffer to bind
  45432. * @param effect defines the effect associated with the vertex buffers
  45433. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  45434. */
  45435. bindBuffers(vertexBuffers: {
  45436. [key: string]: Nullable<VertexBuffer>;
  45437. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  45438. [kind: string]: Nullable<VertexBuffer>;
  45439. }): void;
  45440. /** @hidden */
  45441. _releaseBuffer(buffer: DataBuffer): boolean;
  45442. createUniformBuffer(elements: FloatArray): DataBuffer;
  45443. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  45444. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  45445. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  45446. /**
  45447. * Create a new effect (used to store vertex/fragment shaders)
  45448. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  45449. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  45450. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  45451. * @param samplers defines an array of string used to represent textures
  45452. * @param defines defines the string containing the defines to use to compile the shaders
  45453. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  45454. * @param onCompiled defines a function to call when the effect creation is successful
  45455. * @param onError defines a function to call when the effect creation has failed
  45456. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  45457. * @returns the new Effect
  45458. */
  45459. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  45460. private _compileRawShaderToSpirV;
  45461. private _compileShaderToSpirV;
  45462. private _createPipelineStageDescriptor;
  45463. private _compileRawPipelineStageDescriptor;
  45464. private _compilePipelineStageDescriptor;
  45465. /** @hidden */
  45466. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45467. /** @hidden */
  45468. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45469. /**
  45470. * Creates a new pipeline context
  45471. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45472. * @returns the new pipeline
  45473. */
  45474. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45475. /** @hidden */
  45476. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45477. /**
  45478. * Gets the list of active attributes for a given WebGPU program
  45479. * @param pipelineContext defines the pipeline context to use
  45480. * @param attributesNames defines the list of attribute names to get
  45481. * @returns an array of indices indicating the offset of each attribute
  45482. */
  45483. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45484. /**
  45485. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45486. * @param effect defines the effect to activate
  45487. */
  45488. enableEffect(effect: Nullable<Effect>): void;
  45489. /** @hidden */
  45490. _releaseEffect(effect: Effect): void;
  45491. /**
  45492. * 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
  45493. */
  45494. releaseEffects(): void;
  45495. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45496. /**
  45497. * Gets a boolean indicating that only power of 2 textures are supported
  45498. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45499. */
  45500. get needPOTTextures(): boolean;
  45501. /** @hidden */
  45502. _createHardwareTexture(): HardwareTextureWrapper;
  45503. /** @hidden */
  45504. _releaseTexture(texture: InternalTexture): void;
  45505. /** @hidden */
  45506. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45507. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45508. /**
  45509. * Usually called from Texture.ts.
  45510. * Passed information to create a hardware texture
  45511. * @param url defines a value which contains one of the following:
  45512. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45513. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45514. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45515. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45516. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  45517. * @param scene needed for loading to the correct scene
  45518. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45519. * @param onLoad optional callback to be called upon successful completion
  45520. * @param onError optional callback to be called upon failure
  45521. * @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
  45522. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45523. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45524. * @param forcedExtension defines the extension to use to pick the right loader
  45525. * @param mimeType defines an optional mime type
  45526. * @param loaderOptions options to be passed to the loader
  45527. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45528. */
  45529. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  45530. /** @hidden */
  45531. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45532. /**
  45533. * Creates a cube texture
  45534. * @param rootUrl defines the url where the files to load is located
  45535. * @param scene defines the current scene
  45536. * @param files defines the list of files to load (1 per face)
  45537. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45538. * @param onLoad defines an optional callback raised when the texture is loaded
  45539. * @param onError defines an optional callback raised if there is an issue to load the texture
  45540. * @param format defines the format of the data
  45541. * @param forcedExtension defines the extension to use to pick the right loader
  45542. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45543. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45544. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45545. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45546. * @param loaderOptions options to be passed to the loader
  45547. * @returns the cube texture as an InternalTexture
  45548. */
  45549. 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;
  45550. /**
  45551. * Creates a raw texture
  45552. * @param data defines the data to store in the texture
  45553. * @param width defines the width of the texture
  45554. * @param height defines the height of the texture
  45555. * @param format defines the format of the data
  45556. * @param generateMipMaps defines if the engine should generate the mip levels
  45557. * @param invertY defines if data must be stored with Y axis inverted
  45558. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45559. * @param compression defines the compression used (null by default)
  45560. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45561. * @returns the raw texture inside an InternalTexture
  45562. */
  45563. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45564. /**
  45565. * Creates a new raw cube texture
  45566. * @param data defines the array of data to use to create each face
  45567. * @param size defines the size of the textures
  45568. * @param format defines the format of the data
  45569. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45570. * @param generateMipMaps defines if the engine should generate the mip levels
  45571. * @param invertY defines if data must be stored with Y axis inverted
  45572. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45573. * @param compression defines the compression used (null by default)
  45574. * @returns the cube texture as an InternalTexture
  45575. */
  45576. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45577. /**
  45578. * Creates a new raw cube texture from a specified url
  45579. * @param url defines the url where the data is located
  45580. * @param scene defines the current scene
  45581. * @param size defines the size of the textures
  45582. * @param format defines the format of the data
  45583. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45584. * @param noMipmap defines if the engine should avoid generating the mip levels
  45585. * @param callback defines a callback used to extract texture data from loaded data
  45586. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45587. * @param onLoad defines a callback called when texture is loaded
  45588. * @param onError defines a callback called if there is an error
  45589. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45590. * @param invertY defines if data must be stored with Y axis inverted
  45591. * @returns the cube texture as an InternalTexture
  45592. */
  45593. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  45594. /**
  45595. * Creates a new raw 2D array texture
  45596. * @param data defines the data used to create the texture
  45597. * @param width defines the width of the texture
  45598. * @param height defines the height of the texture
  45599. * @param depth defines the number of layers of the texture
  45600. * @param format defines the format of the texture
  45601. * @param generateMipMaps defines if the engine must generate mip levels
  45602. * @param invertY defines if data must be stored with Y axis inverted
  45603. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45604. * @param compression defines the compressed used (can be null)
  45605. * @param textureType defines the compressed used (can be null)
  45606. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45607. */
  45608. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45609. /**
  45610. * Creates a new raw 3D texture
  45611. * @param data defines the data used to create the texture
  45612. * @param width defines the width of the texture
  45613. * @param height defines the height of the texture
  45614. * @param depth defines the depth of the texture
  45615. * @param format defines the format of the texture
  45616. * @param generateMipMaps defines if the engine must generate mip levels
  45617. * @param invertY defines if data must be stored with Y axis inverted
  45618. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45619. * @param compression defines the compressed used (can be null)
  45620. * @param textureType defines the compressed used (can be null)
  45621. * @returns a new raw 3D texture (stored in an InternalTexture)
  45622. */
  45623. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45624. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45625. /**
  45626. * Update the sampling mode of a given texture
  45627. * @param samplingMode defines the required sampling mode
  45628. * @param texture defines the texture to update
  45629. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45630. */
  45631. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45632. /**
  45633. * Update the sampling mode of a given texture
  45634. * @param texture defines the texture to update
  45635. * @param wrapU defines the texture wrap mode of the u coordinates
  45636. * @param wrapV defines the texture wrap mode of the v coordinates
  45637. * @param wrapR defines the texture wrap mode of the r coordinates
  45638. */
  45639. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45640. /**
  45641. * Update the dimensions of a texture
  45642. * @param texture texture to update
  45643. * @param width new width of the texture
  45644. * @param height new height of the texture
  45645. * @param depth new depth of the texture
  45646. */
  45647. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45648. private _setInternalTexture;
  45649. /**
  45650. * Sets a texture to the according uniform.
  45651. * @param channel The texture channel
  45652. * @param unused unused parameter
  45653. * @param texture The texture to apply
  45654. * @param name The name of the uniform in the effect
  45655. */
  45656. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45657. /**
  45658. * Sets an array of texture to the WebGPU context
  45659. * @param channel defines the channel where the texture array must be set
  45660. * @param unused unused parameter
  45661. * @param textures defines the array of textures to bind
  45662. * @param name name of the channel
  45663. */
  45664. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45665. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45666. /** @hidden */
  45667. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45668. /** @hidden */
  45669. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45670. private _generateMipmaps;
  45671. /**
  45672. * Update the content of a texture
  45673. * @param texture defines the texture to update
  45674. * @param canvas defines the source containing the data
  45675. * @param invertY defines if data must be stored with Y axis inverted
  45676. * @param premulAlpha defines if alpha is stored as premultiplied
  45677. * @param format defines the format of the data
  45678. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45679. */
  45680. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45681. /**
  45682. * Update a portion of an internal texture
  45683. * @param texture defines the texture to update
  45684. * @param imageData defines the data to store into the texture
  45685. * @param xOffset defines the x coordinates of the update rectangle
  45686. * @param yOffset defines the y coordinates of the update rectangle
  45687. * @param width defines the width of the update rectangle
  45688. * @param height defines the height of the update rectangle
  45689. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45690. * @param lod defines the lod level to update (0 by default)
  45691. */
  45692. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45693. /**
  45694. * Update a video texture
  45695. * @param texture defines the texture to update
  45696. * @param video defines the video element to use
  45697. * @param invertY defines if data must be stored with Y axis inverted
  45698. */
  45699. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45700. /** @hidden */
  45701. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45702. /** @hidden */
  45703. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45704. /** @hidden */
  45705. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45706. /** @hidden */
  45707. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45708. /**
  45709. * Update a raw texture
  45710. * @param texture defines the texture to update
  45711. * @param bufferView defines the data to store in the texture
  45712. * @param format defines the format of the data
  45713. * @param invertY defines if data must be stored with Y axis inverted
  45714. * @param compression defines the compression used (null by default)
  45715. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45716. */
  45717. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45718. /**
  45719. * Update a raw cube texture
  45720. * @param texture defines the texture to update
  45721. * @param bufferView defines the data to store
  45722. * @param format defines the data format
  45723. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45724. * @param invertY defines if data must be stored with Y axis inverted
  45725. * @param compression defines the compression used (null by default)
  45726. * @param level defines which level of the texture to update
  45727. */
  45728. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45729. /**
  45730. * Update a raw 2D array texture
  45731. * @param texture defines the texture to update
  45732. * @param bufferView defines the data to store
  45733. * @param format defines the data format
  45734. * @param invertY defines if data must be stored with Y axis inverted
  45735. * @param compression defines the used compression (can be null)
  45736. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45737. */
  45738. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45739. /**
  45740. * Update a raw 3D texture
  45741. * @param texture defines the texture to update
  45742. * @param bufferView defines the data to store
  45743. * @param format defines the data format
  45744. * @param invertY defines if data must be stored with Y axis inverted
  45745. * @param compression defines the used compression (can be null)
  45746. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45747. */
  45748. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45749. /**
  45750. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45751. * @param x defines the x coordinate of the rectangle where pixels must be read
  45752. * @param y defines the y coordinate of the rectangle where pixels must be read
  45753. * @param width defines the width of the rectangle where pixels must be read
  45754. * @param height defines the height of the rectangle where pixels must be read
  45755. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45756. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45757. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45758. */
  45759. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45760. /** @hidden */
  45761. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45762. /** @hidden */
  45763. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  45764. /**
  45765. * Creates a new render target texture
  45766. * @param size defines the size of the texture
  45767. * @param options defines the options used to create the texture
  45768. * @returns a new render target texture stored in an InternalTexture
  45769. */
  45770. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45771. /**
  45772. * Create a multi render target texture
  45773. * @param size defines the size of the texture
  45774. * @param options defines the creation options
  45775. * @returns the cube texture as an InternalTexture
  45776. */
  45777. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45778. /**
  45779. * Creates a new render target cube texture
  45780. * @param size defines the size of the texture
  45781. * @param options defines the options used to create the texture
  45782. * @returns a new render target cube texture stored in an InternalTexture
  45783. */
  45784. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45785. /** @hidden */
  45786. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45787. width: number;
  45788. height: number;
  45789. layers?: number;
  45790. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45791. /** @hidden */
  45792. _createDepthStencilTexture(size: number | {
  45793. width: number;
  45794. height: number;
  45795. layers?: number;
  45796. }, options: DepthTextureCreationOptions): InternalTexture;
  45797. /** @hidden */
  45798. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45799. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45800. /**
  45801. * Update the sample count for a given multiple render target texture
  45802. * @param textures defines the textures to update
  45803. * @param samples defines the sample count to set
  45804. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45805. */
  45806. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45807. /**
  45808. * Begin a new frame
  45809. */
  45810. beginFrame(): void;
  45811. /**
  45812. * End the current frame
  45813. */
  45814. endFrame(): void;
  45815. /**
  45816. * Force a WebGPU flush (ie. a flush of all waiting commands)
  45817. */
  45818. flushFramebuffer(): void;
  45819. private _startRenderTargetRenderPass;
  45820. private _endRenderTargetRenderPass;
  45821. private _getCurrentRenderPass;
  45822. private _startMainRenderPass;
  45823. private _endMainRenderPass;
  45824. /**
  45825. * Restores the WebGPU state to only draw on the main color attachment
  45826. */
  45827. restoreSingleAttachment(): void;
  45828. /**
  45829. * Creates a layout object to draw/clear on specific textures in a MRT
  45830. * @param textureStatus textureStatus[i] indicates if the i-th is active
  45831. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  45832. */
  45833. buildTextureLayout(textureStatus: boolean[]): number[];
  45834. /**
  45835. * Select a subsets of attachments to draw to.
  45836. * @param attachments index of attachments
  45837. */
  45838. bindAttachments(attachments: number[]): void;
  45839. /**
  45840. * Binds the frame buffer to the specified texture.
  45841. * @param texture The texture to render to or null for the default canvas
  45842. * @param faceIndex The face of the texture to render to in case of cube texture
  45843. * @param requiredWidth The width of the target to render to
  45844. * @param requiredHeight The height of the target to render to
  45845. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45846. * @param lodLevel defines the lod level to bind to the frame buffer
  45847. * @param layer defines the 2d array index to bind to frame buffer to
  45848. */
  45849. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  45850. /**
  45851. * Unbind the current render target texture from the WebGPU context
  45852. * @param texture defines the render target texture to unbind
  45853. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45854. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45855. */
  45856. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45857. /**
  45858. * Unbind a list of render target textures from the WebGPU context
  45859. * @param textures defines the render target textures to unbind
  45860. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45861. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45862. */
  45863. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45864. /**
  45865. * Unbind the current render target and bind the default framebuffer
  45866. */
  45867. restoreDefaultFramebuffer(): void;
  45868. setZOffset(value: number): void;
  45869. private _setColorFormat;
  45870. private _setDepthTextureFormat;
  45871. setDepthBuffer(enable: boolean): void;
  45872. setDepthWrite(enable: boolean): void;
  45873. setStencilBuffer(enable: boolean): void;
  45874. setStencilMask(mask: number): void;
  45875. setStencilFunction(stencilFunc: number): void;
  45876. setStencilFunctionReference(reference: number): void;
  45877. setStencilFunctionMask(mask: number): void;
  45878. setStencilOperationFail(operation: number): void;
  45879. setStencilOperationDepthFail(operation: number): void;
  45880. setStencilOperationPass(operation: number): void;
  45881. setDitheringState(value: boolean): void;
  45882. setRasterizerState(value: boolean): void;
  45883. setDepthFunction(depthFunc: number): void;
  45884. setDepthFunctionToGreater(): void;
  45885. setDepthFunctionToGreaterOrEqual(): void;
  45886. setDepthFunctionToLess(): void;
  45887. setDepthFunctionToLessOrEqual(): void;
  45888. /**
  45889. * Set various states to the context
  45890. * @param culling defines backface culling state
  45891. * @param zOffset defines the value to apply to zOffset (0 by default)
  45892. * @param force defines if states must be applied even if cache is up to date
  45893. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45894. */
  45895. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45896. /**
  45897. * Sets the current alpha mode
  45898. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45899. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45900. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45901. */
  45902. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45903. /**
  45904. * Sets the current alpha equation
  45905. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  45906. */
  45907. setAlphaEquation(equation: number): void;
  45908. private _getBindGroupsToRender;
  45909. private _bindVertexInputs;
  45910. private _setRenderBindGroups;
  45911. private _setRenderPipeline;
  45912. /**
  45913. * Draw a list of indexed primitives
  45914. * @param fillMode defines the primitive to use
  45915. * @param indexStart defines the starting index
  45916. * @param indexCount defines the number of index to draw
  45917. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  45918. */
  45919. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45920. /**
  45921. * Draw a list of unindexed primitives
  45922. * @param fillMode defines the primitive to use
  45923. * @param verticesStart defines the index of first vertex to draw
  45924. * @param verticesCount defines the count of vertices to draw
  45925. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  45926. */
  45927. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45928. private _bundleEncoder;
  45929. /**
  45930. * Start recording all the gpu calls into a bundle.
  45931. */
  45932. startRecordBundle(): void;
  45933. /**
  45934. * Stops recording the bundle.
  45935. * @returns the recorded bundle
  45936. */
  45937. stopRecordBundle(): GPURenderBundle;
  45938. /**
  45939. * Execute the previously recorded bundle.
  45940. * @param bundles defines the bundle to replay
  45941. */
  45942. executeBundles(bundles: GPURenderBundle[]): void;
  45943. /**
  45944. * Dispose and release all associated resources
  45945. */
  45946. dispose(): void;
  45947. /**
  45948. * Gets the current render width
  45949. * @param useScreen defines if screen size must be used (or the current render target if any)
  45950. * @returns a number defining the current render width
  45951. */
  45952. getRenderWidth(useScreen?: boolean): number;
  45953. /**
  45954. * Gets the current render height
  45955. * @param useScreen defines if screen size must be used (or the current render target if any)
  45956. * @returns a number defining the current render height
  45957. */
  45958. getRenderHeight(useScreen?: boolean): number;
  45959. /**
  45960. * Gets the HTML canvas attached with the current WebGPU context
  45961. * @returns a HTML canvas
  45962. */
  45963. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  45964. /** @hidden */
  45965. _debugPushGroup(groupName: string, targetObject?: number): void;
  45966. /** @hidden */
  45967. _debugPopGroup(targetObject?: number): void;
  45968. /** @hidden */
  45969. _debugInsertMarker(text: string, targetObject?: number): void;
  45970. private _debugFlushPendingCommands;
  45971. /**
  45972. * Get the current error code of the WebGPU context
  45973. * @returns the error code
  45974. */
  45975. getError(): number;
  45976. /** @hidden */
  45977. bindSamplers(effect: Effect): void;
  45978. /** @hidden */
  45979. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  45980. /** @hidden */
  45981. _releaseFramebufferObjects(texture: InternalTexture): void;
  45982. /** @hidden */
  45983. applyStates(): void;
  45984. /**
  45985. * Gets a boolean indicating if all created effects are ready
  45986. * @returns always true - No parallel shader compilation
  45987. */
  45988. areAllEffectsReady(): boolean;
  45989. /** @hidden */
  45990. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45991. /** @hidden */
  45992. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45993. /** @hidden */
  45994. _getUnpackAlignement(): number;
  45995. /** @hidden */
  45996. _unpackFlipY(value: boolean): void;
  45997. /** @hidden */
  45998. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  45999. min: number;
  46000. mag: number;
  46001. };
  46002. /** @hidden */
  46003. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46004. /** @hidden */
  46005. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46006. /** @hidden */
  46007. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46008. /** @hidden */
  46009. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46010. /** @hidden */
  46011. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46012. /** @hidden */
  46013. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46014. /** @hidden */
  46015. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  46016. /** @hidden */
  46017. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  46018. /** @hidden */
  46019. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  46020. /** @hidden */
  46021. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  46022. /** @hidden */
  46023. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  46024. /** @hidden */
  46025. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46026. /** @hidden */
  46027. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46028. /** @hidden */
  46029. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  46030. /** @hidden */
  46031. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  46032. /** @hidden */
  46033. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  46034. /** @hidden */
  46035. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  46036. }
  46037. }
  46038. declare module BABYLON {
  46039. /**
  46040. * Define an interface for all classes that will hold resources
  46041. */
  46042. export interface IDisposable {
  46043. /**
  46044. * Releases all held resources
  46045. */
  46046. dispose(): void;
  46047. }
  46048. /** Interface defining initialization parameters for Scene class */
  46049. export interface SceneOptions {
  46050. /**
  46051. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  46052. * It will improve performance when the number of geometries becomes important.
  46053. */
  46054. useGeometryUniqueIdsMap?: boolean;
  46055. /**
  46056. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  46057. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46058. */
  46059. useMaterialMeshMap?: boolean;
  46060. /**
  46061. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  46062. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46063. */
  46064. useClonedMeshMap?: boolean;
  46065. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  46066. virtual?: boolean;
  46067. }
  46068. /**
  46069. * Represents a scene to be rendered by the engine.
  46070. * @see https://doc.babylonjs.com/features/scene
  46071. */
  46072. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  46073. /** The fog is deactivated */
  46074. static readonly FOGMODE_NONE: number;
  46075. /** The fog density is following an exponential function */
  46076. static readonly FOGMODE_EXP: number;
  46077. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  46078. static readonly FOGMODE_EXP2: number;
  46079. /** The fog density is following a linear function. */
  46080. static readonly FOGMODE_LINEAR: number;
  46081. /**
  46082. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  46083. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46084. */
  46085. static MinDeltaTime: number;
  46086. /**
  46087. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  46088. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46089. */
  46090. static MaxDeltaTime: number;
  46091. /**
  46092. * Factory used to create the default material.
  46093. * @param name The name of the material to create
  46094. * @param scene The scene to create the material for
  46095. * @returns The default material
  46096. */
  46097. static DefaultMaterialFactory(scene: Scene): Material;
  46098. /**
  46099. * Factory used to create the a collision coordinator.
  46100. * @returns The collision coordinator
  46101. */
  46102. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  46103. /** @hidden */
  46104. _inputManager: InputManager;
  46105. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  46106. cameraToUseForPointers: Nullable<Camera>;
  46107. /** @hidden */
  46108. readonly _isScene: boolean;
  46109. /** @hidden */
  46110. _blockEntityCollection: boolean;
  46111. /**
  46112. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  46113. */
  46114. autoClear: boolean;
  46115. /**
  46116. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  46117. */
  46118. autoClearDepthAndStencil: boolean;
  46119. /**
  46120. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  46121. */
  46122. clearColor: Color4;
  46123. /**
  46124. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  46125. */
  46126. ambientColor: Color3;
  46127. /**
  46128. * This is use to store the default BRDF lookup for PBR materials in your scene.
  46129. * It should only be one of the following (if not the default embedded one):
  46130. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46131. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  46132. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46133. * The material properties need to be setup according to the type of texture in use.
  46134. */
  46135. environmentBRDFTexture: BaseTexture;
  46136. /**
  46137. * Texture used in all pbr material as the reflection texture.
  46138. * As in the majority of the scene they are the same (exception for multi room and so on),
  46139. * this is easier to reference from here than from all the materials.
  46140. */
  46141. get environmentTexture(): Nullable<BaseTexture>;
  46142. /**
  46143. * Texture used in all pbr material as the reflection texture.
  46144. * As in the majority of the scene they are the same (exception for multi room and so on),
  46145. * this is easier to set here than in all the materials.
  46146. */
  46147. set environmentTexture(value: Nullable<BaseTexture>);
  46148. /** @hidden */
  46149. protected _environmentIntensity: number;
  46150. /**
  46151. * Intensity of the environment in all pbr material.
  46152. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46153. * As in the majority of the scene they are the same (exception for multi room and so on),
  46154. * this is easier to reference from here than from all the materials.
  46155. */
  46156. get environmentIntensity(): number;
  46157. /**
  46158. * Intensity of the environment in all pbr material.
  46159. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46160. * As in the majority of the scene they are the same (exception for multi room and so on),
  46161. * this is easier to set here than in all the materials.
  46162. */
  46163. set environmentIntensity(value: number);
  46164. /** @hidden */
  46165. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46166. /**
  46167. * Default image processing configuration used either in the rendering
  46168. * Forward main pass or through the imageProcessingPostProcess if present.
  46169. * As in the majority of the scene they are the same (exception for multi camera),
  46170. * this is easier to reference from here than from all the materials and post process.
  46171. *
  46172. * No setter as we it is a shared configuration, you can set the values instead.
  46173. */
  46174. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46175. private _forceWireframe;
  46176. /**
  46177. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  46178. */
  46179. set forceWireframe(value: boolean);
  46180. get forceWireframe(): boolean;
  46181. private _skipFrustumClipping;
  46182. /**
  46183. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  46184. */
  46185. set skipFrustumClipping(value: boolean);
  46186. get skipFrustumClipping(): boolean;
  46187. private _forcePointsCloud;
  46188. /**
  46189. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  46190. */
  46191. set forcePointsCloud(value: boolean);
  46192. get forcePointsCloud(): boolean;
  46193. /**
  46194. * Gets or sets the active clipplane 1
  46195. */
  46196. clipPlane: Nullable<Plane>;
  46197. /**
  46198. * Gets or sets the active clipplane 2
  46199. */
  46200. clipPlane2: Nullable<Plane>;
  46201. /**
  46202. * Gets or sets the active clipplane 3
  46203. */
  46204. clipPlane3: Nullable<Plane>;
  46205. /**
  46206. * Gets or sets the active clipplane 4
  46207. */
  46208. clipPlane4: Nullable<Plane>;
  46209. /**
  46210. * Gets or sets the active clipplane 5
  46211. */
  46212. clipPlane5: Nullable<Plane>;
  46213. /**
  46214. * Gets or sets the active clipplane 6
  46215. */
  46216. clipPlane6: Nullable<Plane>;
  46217. /**
  46218. * Gets or sets a boolean indicating if animations are enabled
  46219. */
  46220. animationsEnabled: boolean;
  46221. private _animationPropertiesOverride;
  46222. /**
  46223. * Gets or sets the animation properties override
  46224. */
  46225. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  46226. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  46227. /**
  46228. * Gets or sets a boolean indicating if a constant deltatime has to be used
  46229. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  46230. */
  46231. useConstantAnimationDeltaTime: boolean;
  46232. /**
  46233. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  46234. * Please note that it requires to run a ray cast through the scene on every frame
  46235. */
  46236. constantlyUpdateMeshUnderPointer: boolean;
  46237. /**
  46238. * Defines the HTML cursor to use when hovering over interactive elements
  46239. */
  46240. hoverCursor: string;
  46241. /**
  46242. * Defines the HTML default cursor to use (empty by default)
  46243. */
  46244. defaultCursor: string;
  46245. /**
  46246. * Defines whether cursors are handled by the scene.
  46247. */
  46248. doNotHandleCursors: boolean;
  46249. /**
  46250. * This is used to call preventDefault() on pointer down
  46251. * in order to block unwanted artifacts like system double clicks
  46252. */
  46253. preventDefaultOnPointerDown: boolean;
  46254. /**
  46255. * This is used to call preventDefault() on pointer up
  46256. * in order to block unwanted artifacts like system double clicks
  46257. */
  46258. preventDefaultOnPointerUp: boolean;
  46259. /**
  46260. * Gets or sets user defined metadata
  46261. */
  46262. metadata: any;
  46263. /**
  46264. * For internal use only. Please do not use.
  46265. */
  46266. reservedDataStore: any;
  46267. /**
  46268. * Gets the name of the plugin used to load this scene (null by default)
  46269. */
  46270. loadingPluginName: string;
  46271. /**
  46272. * Use this array to add regular expressions used to disable offline support for specific urls
  46273. */
  46274. disableOfflineSupportExceptionRules: RegExp[];
  46275. /**
  46276. * An event triggered when the scene is disposed.
  46277. */
  46278. onDisposeObservable: Observable<Scene>;
  46279. private _onDisposeObserver;
  46280. /** Sets a function to be executed when this scene is disposed. */
  46281. set onDispose(callback: () => void);
  46282. /**
  46283. * An event triggered before rendering the scene (right after animations and physics)
  46284. */
  46285. onBeforeRenderObservable: Observable<Scene>;
  46286. private _onBeforeRenderObserver;
  46287. /** Sets a function to be executed before rendering this scene */
  46288. set beforeRender(callback: Nullable<() => void>);
  46289. /**
  46290. * An event triggered after rendering the scene
  46291. */
  46292. onAfterRenderObservable: Observable<Scene>;
  46293. /**
  46294. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  46295. */
  46296. onAfterRenderCameraObservable: Observable<Camera>;
  46297. private _onAfterRenderObserver;
  46298. /** Sets a function to be executed after rendering this scene */
  46299. set afterRender(callback: Nullable<() => void>);
  46300. /**
  46301. * An event triggered before animating the scene
  46302. */
  46303. onBeforeAnimationsObservable: Observable<Scene>;
  46304. /**
  46305. * An event triggered after animations processing
  46306. */
  46307. onAfterAnimationsObservable: Observable<Scene>;
  46308. /**
  46309. * An event triggered before draw calls are ready to be sent
  46310. */
  46311. onBeforeDrawPhaseObservable: Observable<Scene>;
  46312. /**
  46313. * An event triggered after draw calls have been sent
  46314. */
  46315. onAfterDrawPhaseObservable: Observable<Scene>;
  46316. /**
  46317. * An event triggered when the scene is ready
  46318. */
  46319. onReadyObservable: Observable<Scene>;
  46320. /**
  46321. * An event triggered before rendering a camera
  46322. */
  46323. onBeforeCameraRenderObservable: Observable<Camera>;
  46324. private _onBeforeCameraRenderObserver;
  46325. /** Sets a function to be executed before rendering a camera*/
  46326. set beforeCameraRender(callback: () => void);
  46327. /**
  46328. * An event triggered after rendering a camera
  46329. */
  46330. onAfterCameraRenderObservable: Observable<Camera>;
  46331. private _onAfterCameraRenderObserver;
  46332. /** Sets a function to be executed after rendering a camera*/
  46333. set afterCameraRender(callback: () => void);
  46334. /**
  46335. * An event triggered when active meshes evaluation is about to start
  46336. */
  46337. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  46338. /**
  46339. * An event triggered when active meshes evaluation is done
  46340. */
  46341. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  46342. /**
  46343. * An event triggered when particles rendering is about to start
  46344. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46345. */
  46346. onBeforeParticlesRenderingObservable: Observable<Scene>;
  46347. /**
  46348. * An event triggered when particles rendering is done
  46349. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46350. */
  46351. onAfterParticlesRenderingObservable: Observable<Scene>;
  46352. /**
  46353. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  46354. */
  46355. onDataLoadedObservable: Observable<Scene>;
  46356. /**
  46357. * An event triggered when a camera is created
  46358. */
  46359. onNewCameraAddedObservable: Observable<Camera>;
  46360. /**
  46361. * An event triggered when a camera is removed
  46362. */
  46363. onCameraRemovedObservable: Observable<Camera>;
  46364. /**
  46365. * An event triggered when a light is created
  46366. */
  46367. onNewLightAddedObservable: Observable<Light>;
  46368. /**
  46369. * An event triggered when a light is removed
  46370. */
  46371. onLightRemovedObservable: Observable<Light>;
  46372. /**
  46373. * An event triggered when a geometry is created
  46374. */
  46375. onNewGeometryAddedObservable: Observable<Geometry>;
  46376. /**
  46377. * An event triggered when a geometry is removed
  46378. */
  46379. onGeometryRemovedObservable: Observable<Geometry>;
  46380. /**
  46381. * An event triggered when a transform node is created
  46382. */
  46383. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  46384. /**
  46385. * An event triggered when a transform node is removed
  46386. */
  46387. onTransformNodeRemovedObservable: Observable<TransformNode>;
  46388. /**
  46389. * An event triggered when a mesh is created
  46390. */
  46391. onNewMeshAddedObservable: Observable<AbstractMesh>;
  46392. /**
  46393. * An event triggered when a mesh is removed
  46394. */
  46395. onMeshRemovedObservable: Observable<AbstractMesh>;
  46396. /**
  46397. * An event triggered when a skeleton is created
  46398. */
  46399. onNewSkeletonAddedObservable: Observable<Skeleton>;
  46400. /**
  46401. * An event triggered when a skeleton is removed
  46402. */
  46403. onSkeletonRemovedObservable: Observable<Skeleton>;
  46404. /**
  46405. * An event triggered when a material is created
  46406. */
  46407. onNewMaterialAddedObservable: Observable<Material>;
  46408. /**
  46409. * An event triggered when a multi material is created
  46410. */
  46411. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  46412. /**
  46413. * An event triggered when a material is removed
  46414. */
  46415. onMaterialRemovedObservable: Observable<Material>;
  46416. /**
  46417. * An event triggered when a multi material is removed
  46418. */
  46419. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  46420. /**
  46421. * An event triggered when a texture is created
  46422. */
  46423. onNewTextureAddedObservable: Observable<BaseTexture>;
  46424. /**
  46425. * An event triggered when a texture is removed
  46426. */
  46427. onTextureRemovedObservable: Observable<BaseTexture>;
  46428. /**
  46429. * An event triggered when render targets are about to be rendered
  46430. * Can happen multiple times per frame.
  46431. */
  46432. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  46433. /**
  46434. * An event triggered when render targets were rendered.
  46435. * Can happen multiple times per frame.
  46436. */
  46437. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  46438. /**
  46439. * An event triggered before calculating deterministic simulation step
  46440. */
  46441. onBeforeStepObservable: Observable<Scene>;
  46442. /**
  46443. * An event triggered after calculating deterministic simulation step
  46444. */
  46445. onAfterStepObservable: Observable<Scene>;
  46446. /**
  46447. * An event triggered when the activeCamera property is updated
  46448. */
  46449. onActiveCameraChanged: Observable<Scene>;
  46450. /**
  46451. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46452. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46453. * 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)
  46454. */
  46455. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46456. /**
  46457. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46458. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46459. * 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)
  46460. */
  46461. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46462. /**
  46463. * This Observable will when a mesh has been imported into the scene.
  46464. */
  46465. onMeshImportedObservable: Observable<AbstractMesh>;
  46466. /**
  46467. * This Observable will when an animation file has been imported into the scene.
  46468. */
  46469. onAnimationFileImportedObservable: Observable<Scene>;
  46470. /**
  46471. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46472. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46473. */
  46474. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46475. /** @hidden */
  46476. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46477. /**
  46478. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46479. */
  46480. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46481. /**
  46482. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46483. */
  46484. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46485. /**
  46486. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46487. */
  46488. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46489. /** Callback called when a pointer move is detected */
  46490. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46491. /** Callback called when a pointer down is detected */
  46492. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46493. /** Callback called when a pointer up is detected */
  46494. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46495. /** Callback called when a pointer pick is detected */
  46496. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46497. /**
  46498. * 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).
  46499. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46500. */
  46501. onPrePointerObservable: Observable<PointerInfoPre>;
  46502. /**
  46503. * Observable event triggered each time an input event is received from the rendering canvas
  46504. */
  46505. onPointerObservable: Observable<PointerInfo>;
  46506. /**
  46507. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46508. */
  46509. get unTranslatedPointer(): Vector2;
  46510. /**
  46511. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46512. */
  46513. static get DragMovementThreshold(): number;
  46514. static set DragMovementThreshold(value: number);
  46515. /**
  46516. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46517. */
  46518. static get LongPressDelay(): number;
  46519. static set LongPressDelay(value: number);
  46520. /**
  46521. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46522. */
  46523. static get DoubleClickDelay(): number;
  46524. static set DoubleClickDelay(value: number);
  46525. /** If you need to check double click without raising a single click at first click, enable this flag */
  46526. static get ExclusiveDoubleClickMode(): boolean;
  46527. static set ExclusiveDoubleClickMode(value: boolean);
  46528. /** @hidden */
  46529. _mirroredCameraPosition: Nullable<Vector3>;
  46530. /**
  46531. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46532. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46533. */
  46534. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46535. /**
  46536. * Observable event triggered each time an keyboard event is received from the hosting window
  46537. */
  46538. onKeyboardObservable: Observable<KeyboardInfo>;
  46539. private _useRightHandedSystem;
  46540. /**
  46541. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46542. */
  46543. set useRightHandedSystem(value: boolean);
  46544. get useRightHandedSystem(): boolean;
  46545. private _timeAccumulator;
  46546. private _currentStepId;
  46547. private _currentInternalStep;
  46548. /**
  46549. * Sets the step Id used by deterministic lock step
  46550. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46551. * @param newStepId defines the step Id
  46552. */
  46553. setStepId(newStepId: number): void;
  46554. /**
  46555. * Gets the step Id used by deterministic lock step
  46556. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46557. * @returns the step Id
  46558. */
  46559. getStepId(): number;
  46560. /**
  46561. * Gets the internal step used by deterministic lock step
  46562. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46563. * @returns the internal step
  46564. */
  46565. getInternalStep(): number;
  46566. private _fogEnabled;
  46567. /**
  46568. * Gets or sets a boolean indicating if fog is enabled on this scene
  46569. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46570. * (Default is true)
  46571. */
  46572. set fogEnabled(value: boolean);
  46573. get fogEnabled(): boolean;
  46574. private _fogMode;
  46575. /**
  46576. * Gets or sets the fog mode to use
  46577. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46578. * | mode | value |
  46579. * | --- | --- |
  46580. * | FOGMODE_NONE | 0 |
  46581. * | FOGMODE_EXP | 1 |
  46582. * | FOGMODE_EXP2 | 2 |
  46583. * | FOGMODE_LINEAR | 3 |
  46584. */
  46585. set fogMode(value: number);
  46586. get fogMode(): number;
  46587. /**
  46588. * Gets or sets the fog color to use
  46589. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46590. * (Default is Color3(0.2, 0.2, 0.3))
  46591. */
  46592. fogColor: Color3;
  46593. /**
  46594. * Gets or sets the fog density to use
  46595. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46596. * (Default is 0.1)
  46597. */
  46598. fogDensity: number;
  46599. /**
  46600. * Gets or sets the fog start distance to use
  46601. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46602. * (Default is 0)
  46603. */
  46604. fogStart: number;
  46605. /**
  46606. * Gets or sets the fog end distance to use
  46607. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46608. * (Default is 1000)
  46609. */
  46610. fogEnd: number;
  46611. /**
  46612. * Flag indicating that the frame buffer binding is handled by another component
  46613. */
  46614. get prePass(): boolean;
  46615. private _shadowsEnabled;
  46616. /**
  46617. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46618. */
  46619. set shadowsEnabled(value: boolean);
  46620. get shadowsEnabled(): boolean;
  46621. private _lightsEnabled;
  46622. /**
  46623. * Gets or sets a boolean indicating if lights are enabled on this scene
  46624. */
  46625. set lightsEnabled(value: boolean);
  46626. get lightsEnabled(): boolean;
  46627. /** All of the active cameras added to this scene. */
  46628. activeCameras: Nullable<Camera[]>;
  46629. /** @hidden */
  46630. _activeCamera: Nullable<Camera>;
  46631. /** Gets or sets the current active camera */
  46632. get activeCamera(): Nullable<Camera>;
  46633. set activeCamera(value: Nullable<Camera>);
  46634. private _defaultMaterial;
  46635. /** The default material used on meshes when no material is affected */
  46636. get defaultMaterial(): Material;
  46637. /** The default material used on meshes when no material is affected */
  46638. set defaultMaterial(value: Material);
  46639. private _texturesEnabled;
  46640. /**
  46641. * Gets or sets a boolean indicating if textures are enabled on this scene
  46642. */
  46643. set texturesEnabled(value: boolean);
  46644. get texturesEnabled(): boolean;
  46645. /**
  46646. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46647. */
  46648. physicsEnabled: boolean;
  46649. /**
  46650. * Gets or sets a boolean indicating if particles are enabled on this scene
  46651. */
  46652. particlesEnabled: boolean;
  46653. /**
  46654. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46655. */
  46656. spritesEnabled: boolean;
  46657. private _skeletonsEnabled;
  46658. /**
  46659. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46660. */
  46661. set skeletonsEnabled(value: boolean);
  46662. get skeletonsEnabled(): boolean;
  46663. /**
  46664. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46665. */
  46666. lensFlaresEnabled: boolean;
  46667. /**
  46668. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46669. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46670. */
  46671. collisionsEnabled: boolean;
  46672. private _collisionCoordinator;
  46673. /** @hidden */
  46674. get collisionCoordinator(): ICollisionCoordinator;
  46675. /**
  46676. * Defines the gravity applied to this scene (used only for collisions)
  46677. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46678. */
  46679. gravity: Vector3;
  46680. /**
  46681. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46682. */
  46683. postProcessesEnabled: boolean;
  46684. /**
  46685. * Gets the current postprocess manager
  46686. */
  46687. postProcessManager: PostProcessManager;
  46688. /**
  46689. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46690. */
  46691. renderTargetsEnabled: boolean;
  46692. /**
  46693. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46694. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46695. */
  46696. dumpNextRenderTargets: boolean;
  46697. /**
  46698. * The list of user defined render targets added to the scene
  46699. */
  46700. customRenderTargets: RenderTargetTexture[];
  46701. /**
  46702. * Defines if texture loading must be delayed
  46703. * If true, textures will only be loaded when they need to be rendered
  46704. */
  46705. useDelayedTextureLoading: boolean;
  46706. /**
  46707. * Gets the list of meshes imported to the scene through SceneLoader
  46708. */
  46709. importedMeshesFiles: String[];
  46710. /**
  46711. * Gets or sets a boolean indicating if probes are enabled on this scene
  46712. */
  46713. probesEnabled: boolean;
  46714. /**
  46715. * Gets or sets the current offline provider to use to store scene data
  46716. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46717. */
  46718. offlineProvider: IOfflineProvider;
  46719. /**
  46720. * Gets or sets the action manager associated with the scene
  46721. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46722. */
  46723. actionManager: AbstractActionManager;
  46724. private _meshesForIntersections;
  46725. /**
  46726. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46727. */
  46728. proceduralTexturesEnabled: boolean;
  46729. private _engine;
  46730. private _totalVertices;
  46731. /** @hidden */
  46732. _activeIndices: PerfCounter;
  46733. /** @hidden */
  46734. _activeParticles: PerfCounter;
  46735. /** @hidden */
  46736. _activeBones: PerfCounter;
  46737. private _animationRatio;
  46738. /** @hidden */
  46739. _animationTimeLast: number;
  46740. /** @hidden */
  46741. _animationTime: number;
  46742. /**
  46743. * Gets or sets a general scale for animation speed
  46744. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46745. */
  46746. animationTimeScale: number;
  46747. /** @hidden */
  46748. _cachedMaterial: Nullable<Material>;
  46749. /** @hidden */
  46750. _cachedEffect: Nullable<Effect>;
  46751. /** @hidden */
  46752. _cachedVisibility: Nullable<number>;
  46753. private _renderId;
  46754. private _frameId;
  46755. private _executeWhenReadyTimeoutId;
  46756. private _intermediateRendering;
  46757. private _viewUpdateFlag;
  46758. private _projectionUpdateFlag;
  46759. /** @hidden */
  46760. _toBeDisposed: Nullable<IDisposable>[];
  46761. private _activeRequests;
  46762. /** @hidden */
  46763. _pendingData: any[];
  46764. private _isDisposed;
  46765. /**
  46766. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46767. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46768. */
  46769. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46770. private _activeMeshes;
  46771. private _processedMaterials;
  46772. private _renderTargets;
  46773. /** @hidden */
  46774. _activeParticleSystems: SmartArray<IParticleSystem>;
  46775. private _activeSkeletons;
  46776. private _softwareSkinnedMeshes;
  46777. private _renderingManager;
  46778. /** @hidden */
  46779. _activeAnimatables: Animatable[];
  46780. private _transformMatrix;
  46781. private _sceneUbo;
  46782. /** @hidden */
  46783. _viewMatrix: Matrix;
  46784. /** @hidden */
  46785. _projectionMatrix: Matrix;
  46786. /** @hidden */
  46787. _forcedViewPosition: Nullable<Vector3>;
  46788. /** @hidden */
  46789. _frustumPlanes: Plane[];
  46790. /**
  46791. * Gets the list of frustum planes (built from the active camera)
  46792. */
  46793. get frustumPlanes(): Plane[];
  46794. /**
  46795. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46796. * This is useful if there are more lights that the maximum simulteanous authorized
  46797. */
  46798. requireLightSorting: boolean;
  46799. /** @hidden */
  46800. readonly useMaterialMeshMap: boolean;
  46801. /** @hidden */
  46802. readonly useClonedMeshMap: boolean;
  46803. private _externalData;
  46804. private _uid;
  46805. /**
  46806. * @hidden
  46807. * Backing store of defined scene components.
  46808. */
  46809. _components: ISceneComponent[];
  46810. /**
  46811. * @hidden
  46812. * Backing store of defined scene components.
  46813. */
  46814. _serializableComponents: ISceneSerializableComponent[];
  46815. /**
  46816. * List of components to register on the next registration step.
  46817. */
  46818. private _transientComponents;
  46819. /**
  46820. * Registers the transient components if needed.
  46821. */
  46822. private _registerTransientComponents;
  46823. /**
  46824. * @hidden
  46825. * Add a component to the scene.
  46826. * Note that the ccomponent could be registered on th next frame if this is called after
  46827. * the register component stage.
  46828. * @param component Defines the component to add to the scene
  46829. */
  46830. _addComponent(component: ISceneComponent): void;
  46831. /**
  46832. * @hidden
  46833. * Gets a component from the scene.
  46834. * @param name defines the name of the component to retrieve
  46835. * @returns the component or null if not present
  46836. */
  46837. _getComponent(name: string): Nullable<ISceneComponent>;
  46838. /**
  46839. * @hidden
  46840. * Defines the actions happening before camera updates.
  46841. */
  46842. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  46843. /**
  46844. * @hidden
  46845. * Defines the actions happening before clear the canvas.
  46846. */
  46847. _beforeClearStage: Stage<SimpleStageAction>;
  46848. /**
  46849. * @hidden
  46850. * Defines the actions happening before clear the canvas.
  46851. */
  46852. _beforeRenderTargetClearStage: Stage<RenderTargetStageAction>;
  46853. /**
  46854. * @hidden
  46855. * Defines the actions when collecting render targets for the frame.
  46856. */
  46857. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46858. /**
  46859. * @hidden
  46860. * Defines the actions happening for one camera in the frame.
  46861. */
  46862. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46863. /**
  46864. * @hidden
  46865. * Defines the actions happening during the per mesh ready checks.
  46866. */
  46867. _isReadyForMeshStage: Stage<MeshStageAction>;
  46868. /**
  46869. * @hidden
  46870. * Defines the actions happening before evaluate active mesh checks.
  46871. */
  46872. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  46873. /**
  46874. * @hidden
  46875. * Defines the actions happening during the evaluate sub mesh checks.
  46876. */
  46877. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  46878. /**
  46879. * @hidden
  46880. * Defines the actions happening during the active mesh stage.
  46881. */
  46882. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  46883. /**
  46884. * @hidden
  46885. * Defines the actions happening during the per camera render target step.
  46886. */
  46887. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  46888. /**
  46889. * @hidden
  46890. * Defines the actions happening just before the active camera is drawing.
  46891. */
  46892. _beforeCameraDrawStage: Stage<CameraStageAction>;
  46893. /**
  46894. * @hidden
  46895. * Defines the actions happening just before a render target is drawing.
  46896. */
  46897. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46898. /**
  46899. * @hidden
  46900. * Defines the actions happening just before a rendering group is drawing.
  46901. */
  46902. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46903. /**
  46904. * @hidden
  46905. * Defines the actions happening just before a mesh is drawing.
  46906. */
  46907. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46908. /**
  46909. * @hidden
  46910. * Defines the actions happening just after a mesh has been drawn.
  46911. */
  46912. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46913. /**
  46914. * @hidden
  46915. * Defines the actions happening just after a rendering group has been drawn.
  46916. */
  46917. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46918. /**
  46919. * @hidden
  46920. * Defines the actions happening just after the active camera has been drawn.
  46921. */
  46922. _afterCameraDrawStage: Stage<CameraStageAction>;
  46923. /**
  46924. * @hidden
  46925. * Defines the actions happening just after a render target has been drawn.
  46926. */
  46927. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46928. /**
  46929. * @hidden
  46930. * Defines the actions happening just after rendering all cameras and computing intersections.
  46931. */
  46932. _afterRenderStage: Stage<SimpleStageAction>;
  46933. /**
  46934. * @hidden
  46935. * Defines the actions happening when a pointer move event happens.
  46936. */
  46937. _pointerMoveStage: Stage<PointerMoveStageAction>;
  46938. /**
  46939. * @hidden
  46940. * Defines the actions happening when a pointer down event happens.
  46941. */
  46942. _pointerDownStage: Stage<PointerUpDownStageAction>;
  46943. /**
  46944. * @hidden
  46945. * Defines the actions happening when a pointer up event happens.
  46946. */
  46947. _pointerUpStage: Stage<PointerUpDownStageAction>;
  46948. /**
  46949. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  46950. */
  46951. private geometriesByUniqueId;
  46952. private _renderBundles;
  46953. /**
  46954. * Creates a new Scene
  46955. * @param engine defines the engine to use to render this scene
  46956. * @param options defines the scene options
  46957. */
  46958. constructor(engine: Engine, options?: SceneOptions);
  46959. /**
  46960. * Gets a string identifying the name of the class
  46961. * @returns "Scene" string
  46962. */
  46963. getClassName(): string;
  46964. private _defaultMeshCandidates;
  46965. /**
  46966. * @hidden
  46967. */
  46968. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46969. private _defaultSubMeshCandidates;
  46970. /**
  46971. * @hidden
  46972. */
  46973. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46974. /**
  46975. * Sets the default candidate providers for the scene.
  46976. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  46977. * and getCollidingSubMeshCandidates to their default function
  46978. */
  46979. setDefaultCandidateProviders(): void;
  46980. /**
  46981. * Gets the mesh that is currently under the pointer
  46982. */
  46983. get meshUnderPointer(): Nullable<AbstractMesh>;
  46984. /**
  46985. * Gets or sets the current on-screen X position of the pointer
  46986. */
  46987. get pointerX(): number;
  46988. set pointerX(value: number);
  46989. /**
  46990. * Gets or sets the current on-screen Y position of the pointer
  46991. */
  46992. get pointerY(): number;
  46993. set pointerY(value: number);
  46994. /**
  46995. * Gets the cached material (ie. the latest rendered one)
  46996. * @returns the cached material
  46997. */
  46998. getCachedMaterial(): Nullable<Material>;
  46999. /**
  47000. * Gets the cached effect (ie. the latest rendered one)
  47001. * @returns the cached effect
  47002. */
  47003. getCachedEffect(): Nullable<Effect>;
  47004. /**
  47005. * Gets the cached visibility state (ie. the latest rendered one)
  47006. * @returns the cached visibility state
  47007. */
  47008. getCachedVisibility(): Nullable<number>;
  47009. /**
  47010. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  47011. * @param material defines the current material
  47012. * @param effect defines the current effect
  47013. * @param visibility defines the current visibility state
  47014. * @returns true if one parameter is not cached
  47015. */
  47016. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  47017. /**
  47018. * Gets the engine associated with the scene
  47019. * @returns an Engine
  47020. */
  47021. getEngine(): Engine;
  47022. /**
  47023. * Gets the total number of vertices rendered per frame
  47024. * @returns the total number of vertices rendered per frame
  47025. */
  47026. getTotalVertices(): number;
  47027. /**
  47028. * Gets the performance counter for total vertices
  47029. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47030. */
  47031. get totalVerticesPerfCounter(): PerfCounter;
  47032. /**
  47033. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  47034. * @returns the total number of active indices rendered per frame
  47035. */
  47036. getActiveIndices(): number;
  47037. /**
  47038. * Gets the performance counter for active indices
  47039. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47040. */
  47041. get totalActiveIndicesPerfCounter(): PerfCounter;
  47042. /**
  47043. * Gets the total number of active particles rendered per frame
  47044. * @returns the total number of active particles rendered per frame
  47045. */
  47046. getActiveParticles(): number;
  47047. /**
  47048. * Gets the performance counter for active particles
  47049. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47050. */
  47051. get activeParticlesPerfCounter(): PerfCounter;
  47052. /**
  47053. * Gets the total number of active bones rendered per frame
  47054. * @returns the total number of active bones rendered per frame
  47055. */
  47056. getActiveBones(): number;
  47057. /**
  47058. * Gets the performance counter for active bones
  47059. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47060. */
  47061. get activeBonesPerfCounter(): PerfCounter;
  47062. /**
  47063. * Gets the array of active meshes
  47064. * @returns an array of AbstractMesh
  47065. */
  47066. getActiveMeshes(): SmartArray<AbstractMesh>;
  47067. /**
  47068. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  47069. * @returns a number
  47070. */
  47071. getAnimationRatio(): number;
  47072. /**
  47073. * Gets an unique Id for the current render phase
  47074. * @returns a number
  47075. */
  47076. getRenderId(): number;
  47077. /**
  47078. * Gets an unique Id for the current frame
  47079. * @returns a number
  47080. */
  47081. getFrameId(): number;
  47082. /** Call this function if you want to manually increment the render Id*/
  47083. incrementRenderId(): void;
  47084. private _createUbo;
  47085. /**
  47086. * Use this method to simulate a pointer move on a mesh
  47087. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47088. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47089. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47090. * @returns the current scene
  47091. */
  47092. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47093. /**
  47094. * Use this method to simulate a pointer down on a mesh
  47095. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47096. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47097. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47098. * @returns the current scene
  47099. */
  47100. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47101. /**
  47102. * Use this method to simulate a pointer up on a mesh
  47103. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47104. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47105. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47106. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  47107. * @returns the current scene
  47108. */
  47109. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  47110. /**
  47111. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  47112. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  47113. * @returns true if the pointer was captured
  47114. */
  47115. isPointerCaptured(pointerId?: number): boolean;
  47116. /**
  47117. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  47118. * @param attachUp defines if you want to attach events to pointerup
  47119. * @param attachDown defines if you want to attach events to pointerdown
  47120. * @param attachMove defines if you want to attach events to pointermove
  47121. */
  47122. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  47123. /** Detaches all event handlers*/
  47124. detachControl(): void;
  47125. /**
  47126. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  47127. * Delay loaded resources are not taking in account
  47128. * @return true if all required resources are ready
  47129. */
  47130. isReady(): boolean;
  47131. /** Resets all cached information relative to material (including effect and visibility) */
  47132. resetCachedMaterial(): void;
  47133. /**
  47134. * Registers a function to be called before every frame render
  47135. * @param func defines the function to register
  47136. */
  47137. registerBeforeRender(func: () => void): void;
  47138. /**
  47139. * Unregisters a function called before every frame render
  47140. * @param func defines the function to unregister
  47141. */
  47142. unregisterBeforeRender(func: () => void): void;
  47143. /**
  47144. * Registers a function to be called after every frame render
  47145. * @param func defines the function to register
  47146. */
  47147. registerAfterRender(func: () => void): void;
  47148. /**
  47149. * Unregisters a function called after every frame render
  47150. * @param func defines the function to unregister
  47151. */
  47152. unregisterAfterRender(func: () => void): void;
  47153. private _executeOnceBeforeRender;
  47154. /**
  47155. * The provided function will run before render once and will be disposed afterwards.
  47156. * A timeout delay can be provided so that the function will be executed in N ms.
  47157. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  47158. * @param func The function to be executed.
  47159. * @param timeout optional delay in ms
  47160. */
  47161. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  47162. /** @hidden */
  47163. _addPendingData(data: any): void;
  47164. /** @hidden */
  47165. _removePendingData(data: any): void;
  47166. /**
  47167. * Returns the number of items waiting to be loaded
  47168. * @returns the number of items waiting to be loaded
  47169. */
  47170. getWaitingItemsCount(): number;
  47171. /**
  47172. * Returns a boolean indicating if the scene is still loading data
  47173. */
  47174. get isLoading(): boolean;
  47175. /**
  47176. * Registers a function to be executed when the scene is ready
  47177. * @param {Function} func - the function to be executed
  47178. */
  47179. executeWhenReady(func: () => void): void;
  47180. /**
  47181. * Returns a promise that resolves when the scene is ready
  47182. * @returns A promise that resolves when the scene is ready
  47183. */
  47184. whenReadyAsync(): Promise<void>;
  47185. /** @hidden */
  47186. _checkIsReady(): void;
  47187. /**
  47188. * Gets all animatable attached to the scene
  47189. */
  47190. get animatables(): Animatable[];
  47191. /**
  47192. * Resets the last animation time frame.
  47193. * Useful to override when animations start running when loading a scene for the first time.
  47194. */
  47195. resetLastAnimationTimeFrame(): void;
  47196. /**
  47197. * Gets the current view matrix
  47198. * @returns a Matrix
  47199. */
  47200. getViewMatrix(): Matrix;
  47201. /**
  47202. * Gets the current projection matrix
  47203. * @returns a Matrix
  47204. */
  47205. getProjectionMatrix(): Matrix;
  47206. /**
  47207. * Gets the current transform matrix
  47208. * @returns a Matrix made of View * Projection
  47209. */
  47210. getTransformMatrix(): Matrix;
  47211. /**
  47212. * Sets the current transform matrix
  47213. * @param viewL defines the View matrix to use
  47214. * @param projectionL defines the Projection matrix to use
  47215. * @param viewR defines the right View matrix to use (if provided)
  47216. * @param projectionR defines the right Projection matrix to use (if provided)
  47217. */
  47218. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  47219. /**
  47220. * Gets the uniform buffer used to store scene data
  47221. * @returns a UniformBuffer
  47222. */
  47223. getSceneUniformBuffer(): UniformBuffer;
  47224. /**
  47225. * Gets an unique (relatively to the current scene) Id
  47226. * @returns an unique number for the scene
  47227. */
  47228. getUniqueId(): number;
  47229. /**
  47230. * Add a mesh to the list of scene's meshes
  47231. * @param newMesh defines the mesh to add
  47232. * @param recursive if all child meshes should also be added to the scene
  47233. */
  47234. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  47235. /**
  47236. * Remove a mesh for the list of scene's meshes
  47237. * @param toRemove defines the mesh to remove
  47238. * @param recursive if all child meshes should also be removed from the scene
  47239. * @returns the index where the mesh was in the mesh list
  47240. */
  47241. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  47242. /**
  47243. * Add a transform node to the list of scene's transform nodes
  47244. * @param newTransformNode defines the transform node to add
  47245. */
  47246. addTransformNode(newTransformNode: TransformNode): void;
  47247. /**
  47248. * Remove a transform node for the list of scene's transform nodes
  47249. * @param toRemove defines the transform node to remove
  47250. * @returns the index where the transform node was in the transform node list
  47251. */
  47252. removeTransformNode(toRemove: TransformNode): number;
  47253. /**
  47254. * Remove a skeleton for the list of scene's skeletons
  47255. * @param toRemove defines the skeleton to remove
  47256. * @returns the index where the skeleton was in the skeleton list
  47257. */
  47258. removeSkeleton(toRemove: Skeleton): number;
  47259. /**
  47260. * Remove a morph target for the list of scene's morph targets
  47261. * @param toRemove defines the morph target to remove
  47262. * @returns the index where the morph target was in the morph target list
  47263. */
  47264. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  47265. /**
  47266. * Remove a light for the list of scene's lights
  47267. * @param toRemove defines the light to remove
  47268. * @returns the index where the light was in the light list
  47269. */
  47270. removeLight(toRemove: Light): number;
  47271. /**
  47272. * Remove a camera for the list of scene's cameras
  47273. * @param toRemove defines the camera to remove
  47274. * @returns the index where the camera was in the camera list
  47275. */
  47276. removeCamera(toRemove: Camera): number;
  47277. /**
  47278. * Remove a particle system for the list of scene's particle systems
  47279. * @param toRemove defines the particle system to remove
  47280. * @returns the index where the particle system was in the particle system list
  47281. */
  47282. removeParticleSystem(toRemove: IParticleSystem): number;
  47283. /**
  47284. * Remove a animation for the list of scene's animations
  47285. * @param toRemove defines the animation to remove
  47286. * @returns the index where the animation was in the animation list
  47287. */
  47288. removeAnimation(toRemove: Animation): number;
  47289. /**
  47290. * Will stop the animation of the given target
  47291. * @param target - the target
  47292. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  47293. * @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)
  47294. */
  47295. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  47296. /**
  47297. * Removes the given animation group from this scene.
  47298. * @param toRemove The animation group to remove
  47299. * @returns The index of the removed animation group
  47300. */
  47301. removeAnimationGroup(toRemove: AnimationGroup): number;
  47302. /**
  47303. * Removes the given multi-material from this scene.
  47304. * @param toRemove The multi-material to remove
  47305. * @returns The index of the removed multi-material
  47306. */
  47307. removeMultiMaterial(toRemove: MultiMaterial): number;
  47308. /**
  47309. * Removes the given material from this scene.
  47310. * @param toRemove The material to remove
  47311. * @returns The index of the removed material
  47312. */
  47313. removeMaterial(toRemove: Material): number;
  47314. /**
  47315. * Removes the given action manager from this scene.
  47316. * @param toRemove The action manager to remove
  47317. * @returns The index of the removed action manager
  47318. */
  47319. removeActionManager(toRemove: AbstractActionManager): number;
  47320. /**
  47321. * Removes the given texture from this scene.
  47322. * @param toRemove The texture to remove
  47323. * @returns The index of the removed texture
  47324. */
  47325. removeTexture(toRemove: BaseTexture): number;
  47326. /**
  47327. * Adds the given light to this scene
  47328. * @param newLight The light to add
  47329. */
  47330. addLight(newLight: Light): void;
  47331. /**
  47332. * Sorts the list list based on light priorities
  47333. */
  47334. sortLightsByPriority(): void;
  47335. /**
  47336. * Adds the given camera to this scene
  47337. * @param newCamera The camera to add
  47338. */
  47339. addCamera(newCamera: Camera): void;
  47340. /**
  47341. * Adds the given skeleton to this scene
  47342. * @param newSkeleton The skeleton to add
  47343. */
  47344. addSkeleton(newSkeleton: Skeleton): void;
  47345. /**
  47346. * Adds the given particle system to this scene
  47347. * @param newParticleSystem The particle system to add
  47348. */
  47349. addParticleSystem(newParticleSystem: IParticleSystem): void;
  47350. /**
  47351. * Adds the given animation to this scene
  47352. * @param newAnimation The animation to add
  47353. */
  47354. addAnimation(newAnimation: Animation): void;
  47355. /**
  47356. * Adds the given animation group to this scene.
  47357. * @param newAnimationGroup The animation group to add
  47358. */
  47359. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  47360. /**
  47361. * Adds the given multi-material to this scene
  47362. * @param newMultiMaterial The multi-material to add
  47363. */
  47364. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  47365. /**
  47366. * Adds the given material to this scene
  47367. * @param newMaterial The material to add
  47368. */
  47369. addMaterial(newMaterial: Material): void;
  47370. /**
  47371. * Adds the given morph target to this scene
  47372. * @param newMorphTargetManager The morph target to add
  47373. */
  47374. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  47375. /**
  47376. * Adds the given geometry to this scene
  47377. * @param newGeometry The geometry to add
  47378. */
  47379. addGeometry(newGeometry: Geometry): void;
  47380. /**
  47381. * Adds the given action manager to this scene
  47382. * @param newActionManager The action manager to add
  47383. */
  47384. addActionManager(newActionManager: AbstractActionManager): void;
  47385. /**
  47386. * Adds the given texture to this scene.
  47387. * @param newTexture The texture to add
  47388. */
  47389. addTexture(newTexture: BaseTexture): void;
  47390. /**
  47391. * Switch active camera
  47392. * @param newCamera defines the new active camera
  47393. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  47394. */
  47395. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  47396. /**
  47397. * sets the active camera of the scene using its ID
  47398. * @param id defines the camera's ID
  47399. * @return the new active camera or null if none found.
  47400. */
  47401. setActiveCameraByID(id: string): Nullable<Camera>;
  47402. /**
  47403. * sets the active camera of the scene using its name
  47404. * @param name defines the camera's name
  47405. * @returns the new active camera or null if none found.
  47406. */
  47407. setActiveCameraByName(name: string): Nullable<Camera>;
  47408. /**
  47409. * get an animation group using its name
  47410. * @param name defines the material's name
  47411. * @return the animation group or null if none found.
  47412. */
  47413. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  47414. /**
  47415. * Get a material using its unique id
  47416. * @param uniqueId defines the material's unique id
  47417. * @return the material or null if none found.
  47418. */
  47419. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  47420. /**
  47421. * get a material using its id
  47422. * @param id defines the material's ID
  47423. * @return the material or null if none found.
  47424. */
  47425. getMaterialByID(id: string): Nullable<Material>;
  47426. /**
  47427. * Gets a the last added material using a given id
  47428. * @param id defines the material's ID
  47429. * @return the last material with the given id or null if none found.
  47430. */
  47431. getLastMaterialByID(id: string): Nullable<Material>;
  47432. /**
  47433. * Gets a material using its name
  47434. * @param name defines the material's name
  47435. * @return the material or null if none found.
  47436. */
  47437. getMaterialByName(name: string): Nullable<Material>;
  47438. /**
  47439. * Get a texture using its unique id
  47440. * @param uniqueId defines the texture's unique id
  47441. * @return the texture or null if none found.
  47442. */
  47443. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  47444. /**
  47445. * Gets a camera using its id
  47446. * @param id defines the id to look for
  47447. * @returns the camera or null if not found
  47448. */
  47449. getCameraByID(id: string): Nullable<Camera>;
  47450. /**
  47451. * Gets a camera using its unique id
  47452. * @param uniqueId defines the unique id to look for
  47453. * @returns the camera or null if not found
  47454. */
  47455. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  47456. /**
  47457. * Gets a camera using its name
  47458. * @param name defines the camera's name
  47459. * @return the camera or null if none found.
  47460. */
  47461. getCameraByName(name: string): Nullable<Camera>;
  47462. /**
  47463. * Gets a bone using its id
  47464. * @param id defines the bone's id
  47465. * @return the bone or null if not found
  47466. */
  47467. getBoneByID(id: string): Nullable<Bone>;
  47468. /**
  47469. * Gets a bone using its id
  47470. * @param name defines the bone's name
  47471. * @return the bone or null if not found
  47472. */
  47473. getBoneByName(name: string): Nullable<Bone>;
  47474. /**
  47475. * Gets a light node using its name
  47476. * @param name defines the the light's name
  47477. * @return the light or null if none found.
  47478. */
  47479. getLightByName(name: string): Nullable<Light>;
  47480. /**
  47481. * Gets a light node using its id
  47482. * @param id defines the light's id
  47483. * @return the light or null if none found.
  47484. */
  47485. getLightByID(id: string): Nullable<Light>;
  47486. /**
  47487. * Gets a light node using its scene-generated unique ID
  47488. * @param uniqueId defines the light's unique id
  47489. * @return the light or null if none found.
  47490. */
  47491. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47492. /**
  47493. * Gets a particle system by id
  47494. * @param id defines the particle system id
  47495. * @return the corresponding system or null if none found
  47496. */
  47497. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47498. /**
  47499. * Gets a geometry using its ID
  47500. * @param id defines the geometry's id
  47501. * @return the geometry or null if none found.
  47502. */
  47503. getGeometryByID(id: string): Nullable<Geometry>;
  47504. private _getGeometryByUniqueID;
  47505. /**
  47506. * Add a new geometry to this scene
  47507. * @param geometry defines the geometry to be added to the scene.
  47508. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47509. * @return a boolean defining if the geometry was added or not
  47510. */
  47511. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47512. /**
  47513. * Removes an existing geometry
  47514. * @param geometry defines the geometry to be removed from the scene
  47515. * @return a boolean defining if the geometry was removed or not
  47516. */
  47517. removeGeometry(geometry: Geometry): boolean;
  47518. /**
  47519. * Gets the list of geometries attached to the scene
  47520. * @returns an array of Geometry
  47521. */
  47522. getGeometries(): Geometry[];
  47523. /**
  47524. * Gets the first added mesh found of a given ID
  47525. * @param id defines the id to search for
  47526. * @return the mesh found or null if not found at all
  47527. */
  47528. getMeshByID(id: string): Nullable<AbstractMesh>;
  47529. /**
  47530. * Gets a list of meshes using their id
  47531. * @param id defines the id to search for
  47532. * @returns a list of meshes
  47533. */
  47534. getMeshesByID(id: string): Array<AbstractMesh>;
  47535. /**
  47536. * Gets the first added transform node found of a given ID
  47537. * @param id defines the id to search for
  47538. * @return the found transform node or null if not found at all.
  47539. */
  47540. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47541. /**
  47542. * Gets a transform node with its auto-generated unique id
  47543. * @param uniqueId efines the unique id to search for
  47544. * @return the found transform node or null if not found at all.
  47545. */
  47546. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47547. /**
  47548. * Gets a list of transform nodes using their id
  47549. * @param id defines the id to search for
  47550. * @returns a list of transform nodes
  47551. */
  47552. getTransformNodesByID(id: string): Array<TransformNode>;
  47553. /**
  47554. * Gets a mesh with its auto-generated unique id
  47555. * @param uniqueId defines the unique id to search for
  47556. * @return the found mesh or null if not found at all.
  47557. */
  47558. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47559. /**
  47560. * Gets a the last added mesh using a given id
  47561. * @param id defines the id to search for
  47562. * @return the found mesh or null if not found at all.
  47563. */
  47564. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47565. /**
  47566. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47567. * @param id defines the id to search for
  47568. * @return the found node or null if not found at all
  47569. */
  47570. getLastEntryByID(id: string): Nullable<Node>;
  47571. /**
  47572. * Gets a node (Mesh, Camera, Light) using a given id
  47573. * @param id defines the id to search for
  47574. * @return the found node or null if not found at all
  47575. */
  47576. getNodeByID(id: string): Nullable<Node>;
  47577. /**
  47578. * Gets a node (Mesh, Camera, Light) using a given name
  47579. * @param name defines the name to search for
  47580. * @return the found node or null if not found at all.
  47581. */
  47582. getNodeByName(name: string): Nullable<Node>;
  47583. /**
  47584. * Gets a mesh using a given name
  47585. * @param name defines the name to search for
  47586. * @return the found mesh or null if not found at all.
  47587. */
  47588. getMeshByName(name: string): Nullable<AbstractMesh>;
  47589. /**
  47590. * Gets a transform node using a given name
  47591. * @param name defines the name to search for
  47592. * @return the found transform node or null if not found at all.
  47593. */
  47594. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47595. /**
  47596. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47597. * @param id defines the id to search for
  47598. * @return the found skeleton or null if not found at all.
  47599. */
  47600. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47601. /**
  47602. * Gets a skeleton using a given auto generated unique id
  47603. * @param uniqueId defines the unique id to search for
  47604. * @return the found skeleton or null if not found at all.
  47605. */
  47606. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47607. /**
  47608. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47609. * @param id defines the id to search for
  47610. * @return the found skeleton or null if not found at all.
  47611. */
  47612. getSkeletonById(id: string): Nullable<Skeleton>;
  47613. /**
  47614. * Gets a skeleton using a given name
  47615. * @param name defines the name to search for
  47616. * @return the found skeleton or null if not found at all.
  47617. */
  47618. getSkeletonByName(name: string): Nullable<Skeleton>;
  47619. /**
  47620. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47621. * @param id defines the id to search for
  47622. * @return the found morph target manager or null if not found at all.
  47623. */
  47624. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47625. /**
  47626. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47627. * @param id defines the id to search for
  47628. * @return the found morph target or null if not found at all.
  47629. */
  47630. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47631. /**
  47632. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47633. * @param name defines the name to search for
  47634. * @return the found morph target or null if not found at all.
  47635. */
  47636. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47637. /**
  47638. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47639. * @param name defines the name to search for
  47640. * @return the found post process or null if not found at all.
  47641. */
  47642. getPostProcessByName(name: string): Nullable<PostProcess>;
  47643. /**
  47644. * Gets a boolean indicating if the given mesh is active
  47645. * @param mesh defines the mesh to look for
  47646. * @returns true if the mesh is in the active list
  47647. */
  47648. isActiveMesh(mesh: AbstractMesh): boolean;
  47649. /**
  47650. * Return a unique id as a string which can serve as an identifier for the scene
  47651. */
  47652. get uid(): string;
  47653. /**
  47654. * Add an externaly attached data from its key.
  47655. * This method call will fail and return false, if such key already exists.
  47656. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47657. * @param key the unique key that identifies the data
  47658. * @param data the data object to associate to the key for this Engine instance
  47659. * @return true if no such key were already present and the data was added successfully, false otherwise
  47660. */
  47661. addExternalData<T>(key: string, data: T): boolean;
  47662. /**
  47663. * Get an externaly attached data from its key
  47664. * @param key the unique key that identifies the data
  47665. * @return the associated data, if present (can be null), or undefined if not present
  47666. */
  47667. getExternalData<T>(key: string): Nullable<T>;
  47668. /**
  47669. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47670. * @param key the unique key that identifies the data
  47671. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47672. * @return the associated data, can be null if the factory returned null.
  47673. */
  47674. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47675. /**
  47676. * Remove an externaly attached data from the Engine instance
  47677. * @param key the unique key that identifies the data
  47678. * @return true if the data was successfully removed, false if it doesn't exist
  47679. */
  47680. removeExternalData(key: string): boolean;
  47681. private _evaluateSubMesh;
  47682. /**
  47683. * Clear the processed materials smart array preventing retention point in material dispose.
  47684. */
  47685. freeProcessedMaterials(): void;
  47686. private _preventFreeActiveMeshesAndRenderingGroups;
  47687. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47688. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47689. * when disposing several meshes in a row or a hierarchy of meshes.
  47690. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47691. */
  47692. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47693. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47694. /**
  47695. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47696. */
  47697. freeActiveMeshes(): void;
  47698. /**
  47699. * Clear the info related to rendering groups preventing retention points during dispose.
  47700. */
  47701. freeRenderingGroups(): void;
  47702. /** @hidden */
  47703. _isInIntermediateRendering(): boolean;
  47704. /**
  47705. * Lambda returning the list of potentially active meshes.
  47706. */
  47707. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47708. /**
  47709. * Lambda returning the list of potentially active sub meshes.
  47710. */
  47711. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47712. /**
  47713. * Lambda returning the list of potentially intersecting sub meshes.
  47714. */
  47715. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47716. /**
  47717. * Lambda returning the list of potentially colliding sub meshes.
  47718. */
  47719. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47720. /** @hidden */
  47721. _activeMeshesFrozen: boolean;
  47722. private _skipEvaluateActiveMeshesCompletely;
  47723. /**
  47724. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47725. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47726. * @param onSuccess optional success callback
  47727. * @param onError optional error callback
  47728. * @returns the current scene
  47729. */
  47730. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47731. /**
  47732. * Use this function to restart evaluating active meshes on every frame
  47733. * @returns the current scene
  47734. */
  47735. unfreezeActiveMeshes(): Scene;
  47736. private _evaluateActiveMeshes;
  47737. private _activeMesh;
  47738. /**
  47739. * Update the transform matrix to update from the current active camera
  47740. * @param force defines a boolean used to force the update even if cache is up to date
  47741. */
  47742. updateTransformMatrix(force?: boolean): void;
  47743. private _bindFrameBuffer;
  47744. /** @hidden */
  47745. _allowPostProcessClearColor: boolean;
  47746. /** @hidden */
  47747. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47748. private _processSubCameras;
  47749. private _checkIntersections;
  47750. /** @hidden */
  47751. _advancePhysicsEngineStep(step: number): void;
  47752. /**
  47753. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47754. */
  47755. getDeterministicFrameTime: () => number;
  47756. /** @hidden */
  47757. _animate(): void;
  47758. /** Execute all animations (for a frame) */
  47759. animate(): void;
  47760. /**
  47761. * Render the scene
  47762. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47763. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47764. */
  47765. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47766. /**
  47767. * Freeze all materials
  47768. * A frozen material will not be updatable but should be faster to render
  47769. */
  47770. freezeMaterials(): void;
  47771. /**
  47772. * Unfreeze all materials
  47773. * A frozen material will not be updatable but should be faster to render
  47774. */
  47775. unfreezeMaterials(): void;
  47776. /**
  47777. * Releases all held ressources
  47778. */
  47779. dispose(): void;
  47780. /**
  47781. * Gets if the scene is already disposed
  47782. */
  47783. get isDisposed(): boolean;
  47784. /**
  47785. * Call this function to reduce memory footprint of the scene.
  47786. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47787. */
  47788. clearCachedVertexData(): void;
  47789. /**
  47790. * This function will remove the local cached buffer data from texture.
  47791. * It will save memory but will prevent the texture from being rebuilt
  47792. */
  47793. cleanCachedTextureBuffer(): void;
  47794. /**
  47795. * Get the world extend vectors with an optional filter
  47796. *
  47797. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47798. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47799. */
  47800. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47801. min: Vector3;
  47802. max: Vector3;
  47803. };
  47804. /**
  47805. * Creates a ray that can be used to pick in the scene
  47806. * @param x defines the x coordinate of the origin (on-screen)
  47807. * @param y defines the y coordinate of the origin (on-screen)
  47808. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47809. * @param camera defines the camera to use for the picking
  47810. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47811. * @returns a Ray
  47812. */
  47813. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47814. /**
  47815. * Creates a ray that can be used to pick in the scene
  47816. * @param x defines the x coordinate of the origin (on-screen)
  47817. * @param y defines the y coordinate of the origin (on-screen)
  47818. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47819. * @param result defines the ray where to store the picking ray
  47820. * @param camera defines the camera to use for the picking
  47821. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47822. * @returns the current scene
  47823. */
  47824. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  47825. /**
  47826. * Creates a ray that can be used to pick in the scene
  47827. * @param x defines the x coordinate of the origin (on-screen)
  47828. * @param y defines the y coordinate of the origin (on-screen)
  47829. * @param camera defines the camera to use for the picking
  47830. * @returns a Ray
  47831. */
  47832. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  47833. /**
  47834. * Creates a ray that can be used to pick in the scene
  47835. * @param x defines the x coordinate of the origin (on-screen)
  47836. * @param y defines the y coordinate of the origin (on-screen)
  47837. * @param result defines the ray where to store the picking ray
  47838. * @param camera defines the camera to use for the picking
  47839. * @returns the current scene
  47840. */
  47841. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  47842. /** Launch a ray to try to pick a mesh in the scene
  47843. * @param x position on screen
  47844. * @param y position on screen
  47845. * @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
  47846. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47847. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47848. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47849. * @returns a PickingInfo
  47850. */
  47851. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47852. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  47853. * @param x position on screen
  47854. * @param y position on screen
  47855. * @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
  47856. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47857. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47858. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  47859. */
  47860. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  47861. /** Use the given ray to pick a mesh in the scene
  47862. * @param ray The ray to use to pick meshes
  47863. * @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
  47864. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47865. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47866. * @returns a PickingInfo
  47867. */
  47868. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47869. /**
  47870. * Launch a ray to try to pick a mesh in the scene
  47871. * @param x X position on screen
  47872. * @param y Y position on screen
  47873. * @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
  47874. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47875. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47876. * @returns an array of PickingInfo
  47877. */
  47878. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47879. /**
  47880. * Launch a ray to try to pick a mesh in the scene
  47881. * @param ray Ray to use
  47882. * @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
  47883. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47884. * @returns an array of PickingInfo
  47885. */
  47886. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47887. /**
  47888. * Force the value of meshUnderPointer
  47889. * @param mesh defines the mesh to use
  47890. * @param pointerId optional pointer id when using more than one pointer
  47891. */
  47892. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  47893. /**
  47894. * Gets the mesh under the pointer
  47895. * @returns a Mesh or null if no mesh is under the pointer
  47896. */
  47897. getPointerOverMesh(): Nullable<AbstractMesh>;
  47898. /** @hidden */
  47899. _rebuildGeometries(): void;
  47900. /** @hidden */
  47901. _rebuildTextures(): void;
  47902. private _getByTags;
  47903. /**
  47904. * Get a list of meshes by tags
  47905. * @param tagsQuery defines the tags query to use
  47906. * @param forEach defines a predicate used to filter results
  47907. * @returns an array of Mesh
  47908. */
  47909. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  47910. /**
  47911. * Get a list of cameras by tags
  47912. * @param tagsQuery defines the tags query to use
  47913. * @param forEach defines a predicate used to filter results
  47914. * @returns an array of Camera
  47915. */
  47916. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  47917. /**
  47918. * Get a list of lights by tags
  47919. * @param tagsQuery defines the tags query to use
  47920. * @param forEach defines a predicate used to filter results
  47921. * @returns an array of Light
  47922. */
  47923. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  47924. /**
  47925. * Get a list of materials by tags
  47926. * @param tagsQuery defines the tags query to use
  47927. * @param forEach defines a predicate used to filter results
  47928. * @returns an array of Material
  47929. */
  47930. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  47931. /**
  47932. * Get a list of transform nodes by tags
  47933. * @param tagsQuery defines the tags query to use
  47934. * @param forEach defines a predicate used to filter results
  47935. * @returns an array of TransformNode
  47936. */
  47937. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  47938. /**
  47939. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47940. * This allowed control for front to back rendering or reversly depending of the special needs.
  47941. *
  47942. * @param renderingGroupId The rendering group id corresponding to its index
  47943. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47944. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47945. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47946. */
  47947. 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;
  47948. /**
  47949. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47950. *
  47951. * @param renderingGroupId The rendering group id corresponding to its index
  47952. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47953. * @param depth Automatically clears depth between groups if true and autoClear is true.
  47954. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  47955. */
  47956. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  47957. /**
  47958. * Gets the current auto clear configuration for one rendering group of the rendering
  47959. * manager.
  47960. * @param index the rendering group index to get the information for
  47961. * @returns The auto clear setup for the requested rendering group
  47962. */
  47963. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  47964. private _blockMaterialDirtyMechanism;
  47965. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  47966. get blockMaterialDirtyMechanism(): boolean;
  47967. set blockMaterialDirtyMechanism(value: boolean);
  47968. /**
  47969. * Will flag all materials as dirty to trigger new shader compilation
  47970. * @param flag defines the flag used to specify which material part must be marked as dirty
  47971. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  47972. */
  47973. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  47974. /** @hidden */
  47975. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  47976. /** @hidden */
  47977. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47978. /** @hidden */
  47979. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  47980. /** @hidden */
  47981. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  47982. /** @hidden */
  47983. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  47984. /** @hidden */
  47985. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47986. }
  47987. }
  47988. declare module BABYLON {
  47989. /**
  47990. * Set of assets to keep when moving a scene into an asset container.
  47991. */
  47992. export class KeepAssets extends AbstractScene {
  47993. }
  47994. /**
  47995. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  47996. */
  47997. export class InstantiatedEntries {
  47998. /**
  47999. * List of new root nodes (eg. nodes with no parent)
  48000. */
  48001. rootNodes: TransformNode[];
  48002. /**
  48003. * List of new skeletons
  48004. */
  48005. skeletons: Skeleton[];
  48006. /**
  48007. * List of new animation groups
  48008. */
  48009. animationGroups: AnimationGroup[];
  48010. }
  48011. /**
  48012. * Container with a set of assets that can be added or removed from a scene.
  48013. */
  48014. export class AssetContainer extends AbstractScene {
  48015. private _wasAddedToScene;
  48016. /**
  48017. * The scene the AssetContainer belongs to.
  48018. */
  48019. scene: Scene;
  48020. /**
  48021. * Instantiates an AssetContainer.
  48022. * @param scene The scene the AssetContainer belongs to.
  48023. */
  48024. constructor(scene: Scene);
  48025. /**
  48026. * Instantiate or clone all meshes and add the new ones to the scene.
  48027. * Skeletons and animation groups will all be cloned
  48028. * @param nameFunction defines an optional function used to get new names for clones
  48029. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  48030. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  48031. */
  48032. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  48033. /**
  48034. * Adds all the assets from the container to the scene.
  48035. */
  48036. addAllToScene(): void;
  48037. /**
  48038. * Removes all the assets in the container from the scene
  48039. */
  48040. removeAllFromScene(): void;
  48041. /**
  48042. * Disposes all the assets in the container
  48043. */
  48044. dispose(): void;
  48045. private _moveAssets;
  48046. /**
  48047. * Removes all the assets contained in the scene and adds them to the container.
  48048. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  48049. */
  48050. moveAllFromScene(keepAssets?: KeepAssets): void;
  48051. /**
  48052. * 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.
  48053. * @returns the root mesh
  48054. */
  48055. createRootMesh(): Mesh;
  48056. /**
  48057. * Merge animations (direct and animation groups) from this asset container into a scene
  48058. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48059. * @param animatables set of animatables to retarget to a node from the scene
  48060. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  48061. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  48062. */
  48063. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  48064. }
  48065. }
  48066. declare module BABYLON {
  48067. /**
  48068. * Defines how the parser contract is defined.
  48069. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  48070. */
  48071. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  48072. /**
  48073. * Defines how the individual parser contract is defined.
  48074. * These parser can parse an individual asset
  48075. */
  48076. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  48077. /**
  48078. * Base class of the scene acting as a container for the different elements composing a scene.
  48079. * This class is dynamically extended by the different components of the scene increasing
  48080. * flexibility and reducing coupling
  48081. */
  48082. export abstract class AbstractScene {
  48083. /**
  48084. * Stores the list of available parsers in the application.
  48085. */
  48086. private static _BabylonFileParsers;
  48087. /**
  48088. * Stores the list of available individual parsers in the application.
  48089. */
  48090. private static _IndividualBabylonFileParsers;
  48091. /**
  48092. * Adds a parser in the list of available ones
  48093. * @param name Defines the name of the parser
  48094. * @param parser Defines the parser to add
  48095. */
  48096. static AddParser(name: string, parser: BabylonFileParser): void;
  48097. /**
  48098. * Gets a general parser from the list of avaialble ones
  48099. * @param name Defines the name of the parser
  48100. * @returns the requested parser or null
  48101. */
  48102. static GetParser(name: string): Nullable<BabylonFileParser>;
  48103. /**
  48104. * Adds n individual parser in the list of available ones
  48105. * @param name Defines the name of the parser
  48106. * @param parser Defines the parser to add
  48107. */
  48108. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  48109. /**
  48110. * Gets an individual parser from the list of avaialble ones
  48111. * @param name Defines the name of the parser
  48112. * @returns the requested parser or null
  48113. */
  48114. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  48115. /**
  48116. * Parser json data and populate both a scene and its associated container object
  48117. * @param jsonData Defines the data to parse
  48118. * @param scene Defines the scene to parse the data for
  48119. * @param container Defines the container attached to the parsing sequence
  48120. * @param rootUrl Defines the root url of the data
  48121. */
  48122. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  48123. /**
  48124. * Gets the list of root nodes (ie. nodes with no parent)
  48125. */
  48126. rootNodes: Node[];
  48127. /** All of the cameras added to this scene
  48128. * @see https://doc.babylonjs.com/babylon101/cameras
  48129. */
  48130. cameras: Camera[];
  48131. /**
  48132. * All of the lights added to this scene
  48133. * @see https://doc.babylonjs.com/babylon101/lights
  48134. */
  48135. lights: Light[];
  48136. /**
  48137. * All of the (abstract) meshes added to this scene
  48138. */
  48139. meshes: AbstractMesh[];
  48140. /**
  48141. * The list of skeletons added to the scene
  48142. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  48143. */
  48144. skeletons: Skeleton[];
  48145. /**
  48146. * All of the particle systems added to this scene
  48147. * @see https://doc.babylonjs.com/babylon101/particles
  48148. */
  48149. particleSystems: IParticleSystem[];
  48150. /**
  48151. * Gets a list of Animations associated with the scene
  48152. */
  48153. animations: Animation[];
  48154. /**
  48155. * All of the animation groups added to this scene
  48156. * @see https://doc.babylonjs.com/how_to/group
  48157. */
  48158. animationGroups: AnimationGroup[];
  48159. /**
  48160. * All of the multi-materials added to this scene
  48161. * @see https://doc.babylonjs.com/how_to/multi_materials
  48162. */
  48163. multiMaterials: MultiMaterial[];
  48164. /**
  48165. * All of the materials added to this scene
  48166. * In the context of a Scene, it is not supposed to be modified manually.
  48167. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  48168. * Note also that the order of the Material within the array is not significant and might change.
  48169. * @see https://doc.babylonjs.com/babylon101/materials
  48170. */
  48171. materials: Material[];
  48172. /**
  48173. * The list of morph target managers added to the scene
  48174. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  48175. */
  48176. morphTargetManagers: MorphTargetManager[];
  48177. /**
  48178. * The list of geometries used in the scene.
  48179. */
  48180. geometries: Geometry[];
  48181. /**
  48182. * All of the tranform nodes added to this scene
  48183. * In the context of a Scene, it is not supposed to be modified manually.
  48184. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  48185. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  48186. * @see https://doc.babylonjs.com/how_to/transformnode
  48187. */
  48188. transformNodes: TransformNode[];
  48189. /**
  48190. * ActionManagers available on the scene.
  48191. */
  48192. actionManagers: AbstractActionManager[];
  48193. /**
  48194. * Textures to keep.
  48195. */
  48196. textures: BaseTexture[];
  48197. /** @hidden */
  48198. protected _environmentTexture: Nullable<BaseTexture>;
  48199. /**
  48200. * Texture used in all pbr material as the reflection texture.
  48201. * As in the majority of the scene they are the same (exception for multi room and so on),
  48202. * this is easier to reference from here than from all the materials.
  48203. */
  48204. get environmentTexture(): Nullable<BaseTexture>;
  48205. set environmentTexture(value: Nullable<BaseTexture>);
  48206. /**
  48207. * The list of postprocesses added to the scene
  48208. */
  48209. postProcesses: PostProcess[];
  48210. /**
  48211. * @returns all meshes, lights, cameras, transformNodes and bones
  48212. */
  48213. getNodes(): Array<Node>;
  48214. }
  48215. }
  48216. declare module BABYLON {
  48217. /**
  48218. * Interface used to define options for Sound class
  48219. */
  48220. export interface ISoundOptions {
  48221. /**
  48222. * Does the sound autoplay once loaded.
  48223. */
  48224. autoplay?: boolean;
  48225. /**
  48226. * Does the sound loop after it finishes playing once.
  48227. */
  48228. loop?: boolean;
  48229. /**
  48230. * Sound's volume
  48231. */
  48232. volume?: number;
  48233. /**
  48234. * Is it a spatial sound?
  48235. */
  48236. spatialSound?: boolean;
  48237. /**
  48238. * Maximum distance to hear that sound
  48239. */
  48240. maxDistance?: number;
  48241. /**
  48242. * Uses user defined attenuation function
  48243. */
  48244. useCustomAttenuation?: boolean;
  48245. /**
  48246. * Define the roll off factor of spatial sounds.
  48247. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48248. */
  48249. rolloffFactor?: number;
  48250. /**
  48251. * Define the reference distance the sound should be heard perfectly.
  48252. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48253. */
  48254. refDistance?: number;
  48255. /**
  48256. * Define the distance attenuation model the sound will follow.
  48257. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48258. */
  48259. distanceModel?: string;
  48260. /**
  48261. * Defines the playback speed (1 by default)
  48262. */
  48263. playbackRate?: number;
  48264. /**
  48265. * Defines if the sound is from a streaming source
  48266. */
  48267. streaming?: boolean;
  48268. /**
  48269. * Defines an optional length (in seconds) inside the sound file
  48270. */
  48271. length?: number;
  48272. /**
  48273. * Defines an optional offset (in seconds) inside the sound file
  48274. */
  48275. offset?: number;
  48276. /**
  48277. * If true, URLs will not be required to state the audio file codec to use.
  48278. */
  48279. skipCodecCheck?: boolean;
  48280. }
  48281. }
  48282. declare module BABYLON {
  48283. /**
  48284. * Defines a sound that can be played in the application.
  48285. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  48286. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48287. */
  48288. export class Sound {
  48289. /**
  48290. * The name of the sound in the scene.
  48291. */
  48292. name: string;
  48293. /**
  48294. * Does the sound autoplay once loaded.
  48295. */
  48296. autoplay: boolean;
  48297. private _loop;
  48298. /**
  48299. * Does the sound loop after it finishes playing once.
  48300. */
  48301. get loop(): boolean;
  48302. set loop(value: boolean);
  48303. /**
  48304. * Does the sound use a custom attenuation curve to simulate the falloff
  48305. * happening when the source gets further away from the camera.
  48306. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48307. */
  48308. useCustomAttenuation: boolean;
  48309. /**
  48310. * The sound track id this sound belongs to.
  48311. */
  48312. soundTrackId: number;
  48313. /**
  48314. * Is this sound currently played.
  48315. */
  48316. isPlaying: boolean;
  48317. /**
  48318. * Is this sound currently paused.
  48319. */
  48320. isPaused: boolean;
  48321. /**
  48322. * Does this sound enables spatial sound.
  48323. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48324. */
  48325. spatialSound: boolean;
  48326. /**
  48327. * Define the reference distance the sound should be heard perfectly.
  48328. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48329. */
  48330. refDistance: number;
  48331. /**
  48332. * Define the roll off factor of spatial sounds.
  48333. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48334. */
  48335. rolloffFactor: number;
  48336. /**
  48337. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  48338. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48339. */
  48340. maxDistance: number;
  48341. /**
  48342. * Define the distance attenuation model the sound will follow.
  48343. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48344. */
  48345. distanceModel: string;
  48346. /**
  48347. * @hidden
  48348. * Back Compat
  48349. **/
  48350. onended: () => any;
  48351. /**
  48352. * Gets or sets an object used to store user defined information for the sound.
  48353. */
  48354. metadata: any;
  48355. /**
  48356. * Observable event when the current playing sound finishes.
  48357. */
  48358. onEndedObservable: Observable<Sound>;
  48359. /**
  48360. * Gets the current time for the sound.
  48361. */
  48362. get currentTime(): number;
  48363. private _panningModel;
  48364. private _playbackRate;
  48365. private _streaming;
  48366. private _startTime;
  48367. private _startOffset;
  48368. private _position;
  48369. /** @hidden */
  48370. _positionInEmitterSpace: boolean;
  48371. private _localDirection;
  48372. private _volume;
  48373. private _isReadyToPlay;
  48374. private _isDirectional;
  48375. private _readyToPlayCallback;
  48376. private _audioBuffer;
  48377. private _soundSource;
  48378. private _streamingSource;
  48379. private _soundPanner;
  48380. private _soundGain;
  48381. private _inputAudioNode;
  48382. private _outputAudioNode;
  48383. private _coneInnerAngle;
  48384. private _coneOuterAngle;
  48385. private _coneOuterGain;
  48386. private _scene;
  48387. private _connectedTransformNode;
  48388. private _customAttenuationFunction;
  48389. private _registerFunc;
  48390. private _isOutputConnected;
  48391. private _htmlAudioElement;
  48392. private _urlType;
  48393. private _length?;
  48394. private _offset?;
  48395. /** @hidden */
  48396. static _SceneComponentInitialization: (scene: Scene) => void;
  48397. /**
  48398. * Create a sound and attach it to a scene
  48399. * @param name Name of your sound
  48400. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  48401. * @param scene defines the scene the sound belongs to
  48402. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  48403. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  48404. */
  48405. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  48406. /**
  48407. * Release the sound and its associated resources
  48408. */
  48409. dispose(): void;
  48410. /**
  48411. * Gets if the sounds is ready to be played or not.
  48412. * @returns true if ready, otherwise false
  48413. */
  48414. isReady(): boolean;
  48415. /**
  48416. * Get the current class name.
  48417. * @returns current class name
  48418. */
  48419. getClassName(): string;
  48420. private _soundLoaded;
  48421. /**
  48422. * Sets the data of the sound from an audiobuffer
  48423. * @param audioBuffer The audioBuffer containing the data
  48424. */
  48425. setAudioBuffer(audioBuffer: AudioBuffer): void;
  48426. /**
  48427. * Updates the current sounds options such as maxdistance, loop...
  48428. * @param options A JSON object containing values named as the object properties
  48429. */
  48430. updateOptions(options: ISoundOptions): void;
  48431. private _createSpatialParameters;
  48432. private _updateSpatialParameters;
  48433. /**
  48434. * Switch the panning model to HRTF:
  48435. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48436. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48437. */
  48438. switchPanningModelToHRTF(): void;
  48439. /**
  48440. * Switch the panning model to Equal Power:
  48441. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48442. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48443. */
  48444. switchPanningModelToEqualPower(): void;
  48445. private _switchPanningModel;
  48446. /**
  48447. * Connect this sound to a sound track audio node like gain...
  48448. * @param soundTrackAudioNode the sound track audio node to connect to
  48449. */
  48450. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  48451. /**
  48452. * Transform this sound into a directional source
  48453. * @param coneInnerAngle Size of the inner cone in degree
  48454. * @param coneOuterAngle Size of the outer cone in degree
  48455. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  48456. */
  48457. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48458. /**
  48459. * Gets or sets the inner angle for the directional cone.
  48460. */
  48461. get directionalConeInnerAngle(): number;
  48462. /**
  48463. * Gets or sets the inner angle for the directional cone.
  48464. */
  48465. set directionalConeInnerAngle(value: number);
  48466. /**
  48467. * Gets or sets the outer angle for the directional cone.
  48468. */
  48469. get directionalConeOuterAngle(): number;
  48470. /**
  48471. * Gets or sets the outer angle for the directional cone.
  48472. */
  48473. set directionalConeOuterAngle(value: number);
  48474. /**
  48475. * Sets the position of the emitter if spatial sound is enabled
  48476. * @param newPosition Defines the new position
  48477. */
  48478. setPosition(newPosition: Vector3): void;
  48479. /**
  48480. * Sets the local direction of the emitter if spatial sound is enabled
  48481. * @param newLocalDirection Defines the new local direction
  48482. */
  48483. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48484. private _updateDirection;
  48485. /** @hidden */
  48486. updateDistanceFromListener(): void;
  48487. /**
  48488. * Sets a new custom attenuation function for the sound.
  48489. * @param callback Defines the function used for the attenuation
  48490. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48491. */
  48492. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48493. /**
  48494. * Play the sound
  48495. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48496. * @param offset (optional) Start the sound at a specific time in seconds
  48497. * @param length (optional) Sound duration (in seconds)
  48498. */
  48499. play(time?: number, offset?: number, length?: number): void;
  48500. private _onended;
  48501. /**
  48502. * Stop the sound
  48503. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48504. */
  48505. stop(time?: number): void;
  48506. /**
  48507. * Put the sound in pause
  48508. */
  48509. pause(): void;
  48510. /**
  48511. * Sets a dedicated volume for this sounds
  48512. * @param newVolume Define the new volume of the sound
  48513. * @param time Define time for gradual change to new volume
  48514. */
  48515. setVolume(newVolume: number, time?: number): void;
  48516. /**
  48517. * Set the sound play back rate
  48518. * @param newPlaybackRate Define the playback rate the sound should be played at
  48519. */
  48520. setPlaybackRate(newPlaybackRate: number): void;
  48521. /**
  48522. * Gets the volume of the sound.
  48523. * @returns the volume of the sound
  48524. */
  48525. getVolume(): number;
  48526. /**
  48527. * Attach the sound to a dedicated mesh
  48528. * @param transformNode The transform node to connect the sound with
  48529. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48530. */
  48531. attachToMesh(transformNode: TransformNode): void;
  48532. /**
  48533. * Detach the sound from the previously attached mesh
  48534. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48535. */
  48536. detachFromMesh(): void;
  48537. private _onRegisterAfterWorldMatrixUpdate;
  48538. /**
  48539. * Clone the current sound in the scene.
  48540. * @returns the new sound clone
  48541. */
  48542. clone(): Nullable<Sound>;
  48543. /**
  48544. * Gets the current underlying audio buffer containing the data
  48545. * @returns the audio buffer
  48546. */
  48547. getAudioBuffer(): Nullable<AudioBuffer>;
  48548. /**
  48549. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48550. * @returns the source node
  48551. */
  48552. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48553. /**
  48554. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48555. * @returns the gain node
  48556. */
  48557. getSoundGain(): Nullable<GainNode>;
  48558. /**
  48559. * Serializes the Sound in a JSON representation
  48560. * @returns the JSON representation of the sound
  48561. */
  48562. serialize(): any;
  48563. /**
  48564. * Parse a JSON representation of a sound to instantiate in a given scene
  48565. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48566. * @param scene Define the scene the new parsed sound should be created in
  48567. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48568. * @param sourceSound Define a sound place holder if do not need to instantiate a new one
  48569. * @returns the newly parsed sound
  48570. */
  48571. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48572. }
  48573. }
  48574. declare module BABYLON {
  48575. /**
  48576. * This defines an action helpful to play a defined sound on a triggered action.
  48577. */
  48578. export class PlaySoundAction extends Action {
  48579. private _sound;
  48580. /**
  48581. * Instantiate the action
  48582. * @param triggerOptions defines the trigger options
  48583. * @param sound defines the sound to play
  48584. * @param condition defines the trigger related conditions
  48585. */
  48586. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48587. /** @hidden */
  48588. _prepare(): void;
  48589. /**
  48590. * Execute the action and play the sound.
  48591. */
  48592. execute(): void;
  48593. /**
  48594. * Serializes the actions and its related information.
  48595. * @param parent defines the object to serialize in
  48596. * @returns the serialized object
  48597. */
  48598. serialize(parent: any): any;
  48599. }
  48600. /**
  48601. * This defines an action helpful to stop a defined sound on a triggered action.
  48602. */
  48603. export class StopSoundAction extends Action {
  48604. private _sound;
  48605. /**
  48606. * Instantiate the action
  48607. * @param triggerOptions defines the trigger options
  48608. * @param sound defines the sound to stop
  48609. * @param condition defines the trigger related conditions
  48610. */
  48611. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48612. /** @hidden */
  48613. _prepare(): void;
  48614. /**
  48615. * Execute the action and stop the sound.
  48616. */
  48617. execute(): void;
  48618. /**
  48619. * Serializes the actions and its related information.
  48620. * @param parent defines the object to serialize in
  48621. * @returns the serialized object
  48622. */
  48623. serialize(parent: any): any;
  48624. }
  48625. }
  48626. declare module BABYLON {
  48627. /**
  48628. * This defines an action responsible to change the value of a property
  48629. * by interpolating between its current value and the newly set one once triggered.
  48630. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48631. */
  48632. export class InterpolateValueAction extends Action {
  48633. /**
  48634. * Defines the path of the property where the value should be interpolated
  48635. */
  48636. propertyPath: string;
  48637. /**
  48638. * Defines the target value at the end of the interpolation.
  48639. */
  48640. value: any;
  48641. /**
  48642. * Defines the time it will take for the property to interpolate to the value.
  48643. */
  48644. duration: number;
  48645. /**
  48646. * Defines if the other scene animations should be stopped when the action has been triggered
  48647. */
  48648. stopOtherAnimations?: boolean;
  48649. /**
  48650. * Defines a callback raised once the interpolation animation has been done.
  48651. */
  48652. onInterpolationDone?: () => void;
  48653. /**
  48654. * Observable triggered once the interpolation animation has been done.
  48655. */
  48656. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48657. private _target;
  48658. private _effectiveTarget;
  48659. private _property;
  48660. /**
  48661. * Instantiate the action
  48662. * @param triggerOptions defines the trigger options
  48663. * @param target defines the object containing the value to interpolate
  48664. * @param propertyPath defines the path to the property in the target object
  48665. * @param value defines the target value at the end of the interpolation
  48666. * @param duration defines the time it will take for the property to interpolate to the value.
  48667. * @param condition defines the trigger related conditions
  48668. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48669. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48670. */
  48671. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48672. /** @hidden */
  48673. _prepare(): void;
  48674. /**
  48675. * Execute the action starts the value interpolation.
  48676. */
  48677. execute(): void;
  48678. /**
  48679. * Serializes the actions and its related information.
  48680. * @param parent defines the object to serialize in
  48681. * @returns the serialized object
  48682. */
  48683. serialize(parent: any): any;
  48684. }
  48685. }
  48686. declare module BABYLON {
  48687. /**
  48688. * This represents the default audio engine used in babylon.
  48689. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48690. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48691. */
  48692. export class AudioEngine implements IAudioEngine {
  48693. private _audioContext;
  48694. private _audioContextInitialized;
  48695. private _muteButton;
  48696. private _hostElement;
  48697. /**
  48698. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48699. */
  48700. canUseWebAudio: boolean;
  48701. /**
  48702. * The master gain node defines the global audio volume of your audio engine.
  48703. */
  48704. masterGain: GainNode;
  48705. /**
  48706. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48707. * @ignoreNaming
  48708. */
  48709. WarnedWebAudioUnsupported: boolean;
  48710. /**
  48711. * Gets whether or not mp3 are supported by your browser.
  48712. */
  48713. isMP3supported: boolean;
  48714. /**
  48715. * Gets whether or not ogg are supported by your browser.
  48716. */
  48717. isOGGsupported: boolean;
  48718. /**
  48719. * Gets whether audio has been unlocked on the device.
  48720. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48721. * a user interaction has happened.
  48722. */
  48723. unlocked: boolean;
  48724. /**
  48725. * Defines if the audio engine relies on a custom unlocked button.
  48726. * In this case, the embedded button will not be displayed.
  48727. */
  48728. useCustomUnlockedButton: boolean;
  48729. /**
  48730. * Event raised when audio has been unlocked on the browser.
  48731. */
  48732. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48733. /**
  48734. * Event raised when audio has been locked on the browser.
  48735. */
  48736. onAudioLockedObservable: Observable<IAudioEngine>;
  48737. /**
  48738. * Gets the current AudioContext if available.
  48739. */
  48740. get audioContext(): Nullable<AudioContext>;
  48741. private _connectedAnalyser;
  48742. /**
  48743. * Instantiates a new audio engine.
  48744. *
  48745. * There should be only one per page as some browsers restrict the number
  48746. * of audio contexts you can create.
  48747. * @param hostElement defines the host element where to display the mute icon if necessary
  48748. */
  48749. constructor(hostElement?: Nullable<HTMLElement>);
  48750. /**
  48751. * Flags the audio engine in Locked state.
  48752. * This happens due to new browser policies preventing audio to autoplay.
  48753. */
  48754. lock(): void;
  48755. /**
  48756. * Unlocks the audio engine once a user action has been done on the dom.
  48757. * This is helpful to resume play once browser policies have been satisfied.
  48758. */
  48759. unlock(): void;
  48760. private _resumeAudioContext;
  48761. private _initializeAudioContext;
  48762. private _tryToRun;
  48763. private _triggerRunningState;
  48764. private _triggerSuspendedState;
  48765. private _displayMuteButton;
  48766. private _moveButtonToTopLeft;
  48767. private _onResize;
  48768. private _hideMuteButton;
  48769. /**
  48770. * Destroy and release the resources associated with the audio context.
  48771. */
  48772. dispose(): void;
  48773. /**
  48774. * Gets the global volume sets on the master gain.
  48775. * @returns the global volume if set or -1 otherwise
  48776. */
  48777. getGlobalVolume(): number;
  48778. /**
  48779. * Sets the global volume of your experience (sets on the master gain).
  48780. * @param newVolume Defines the new global volume of the application
  48781. */
  48782. setGlobalVolume(newVolume: number): void;
  48783. /**
  48784. * Connect the audio engine to an audio analyser allowing some amazing
  48785. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  48786. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48787. * @param analyser The analyser to connect to the engine
  48788. */
  48789. connectToAnalyser(analyser: Analyser): void;
  48790. }
  48791. }
  48792. declare module BABYLON {
  48793. /**
  48794. * Options allowed during the creation of a sound track.
  48795. */
  48796. export interface ISoundTrackOptions {
  48797. /**
  48798. * The volume the sound track should take during creation
  48799. */
  48800. volume?: number;
  48801. /**
  48802. * Define if the sound track is the main sound track of the scene
  48803. */
  48804. mainTrack?: boolean;
  48805. }
  48806. /**
  48807. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  48808. * It will be also used in a future release to apply effects on a specific track.
  48809. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48810. */
  48811. export class SoundTrack {
  48812. /**
  48813. * The unique identifier of the sound track in the scene.
  48814. */
  48815. id: number;
  48816. /**
  48817. * The list of sounds included in the sound track.
  48818. */
  48819. soundCollection: Array<Sound>;
  48820. private _outputAudioNode;
  48821. private _scene;
  48822. private _connectedAnalyser;
  48823. private _options;
  48824. private _isInitialized;
  48825. /**
  48826. * Creates a new sound track.
  48827. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48828. * @param scene Define the scene the sound track belongs to
  48829. * @param options
  48830. */
  48831. constructor(scene: Scene, options?: ISoundTrackOptions);
  48832. private _initializeSoundTrackAudioGraph;
  48833. /**
  48834. * Release the sound track and its associated resources
  48835. */
  48836. dispose(): void;
  48837. /**
  48838. * Adds a sound to this sound track
  48839. * @param sound define the sound to add
  48840. * @ignoreNaming
  48841. */
  48842. addSound(sound: Sound): void;
  48843. /**
  48844. * Removes a sound to this sound track
  48845. * @param sound define the sound to remove
  48846. * @ignoreNaming
  48847. */
  48848. removeSound(sound: Sound): void;
  48849. /**
  48850. * Set a global volume for the full sound track.
  48851. * @param newVolume Define the new volume of the sound track
  48852. */
  48853. setVolume(newVolume: number): void;
  48854. /**
  48855. * Switch the panning model to HRTF:
  48856. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48857. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48858. */
  48859. switchPanningModelToHRTF(): void;
  48860. /**
  48861. * Switch the panning model to Equal Power:
  48862. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48863. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48864. */
  48865. switchPanningModelToEqualPower(): void;
  48866. /**
  48867. * Connect the sound track to an audio analyser allowing some amazing
  48868. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  48869. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48870. * @param analyser The analyser to connect to the engine
  48871. */
  48872. connectToAnalyser(analyser: Analyser): void;
  48873. }
  48874. }
  48875. declare module BABYLON {
  48876. interface AbstractScene {
  48877. /**
  48878. * The list of sounds used in the scene.
  48879. */
  48880. sounds: Nullable<Array<Sound>>;
  48881. }
  48882. interface Scene {
  48883. /**
  48884. * @hidden
  48885. * Backing field
  48886. */
  48887. _mainSoundTrack: SoundTrack;
  48888. /**
  48889. * The main sound track played by the scene.
  48890. * It contains your primary collection of sounds.
  48891. */
  48892. mainSoundTrack: SoundTrack;
  48893. /**
  48894. * The list of sound tracks added to the scene
  48895. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48896. */
  48897. soundTracks: Nullable<Array<SoundTrack>>;
  48898. /**
  48899. * Gets a sound using a given name
  48900. * @param name defines the name to search for
  48901. * @return the found sound or null if not found at all.
  48902. */
  48903. getSoundByName(name: string): Nullable<Sound>;
  48904. /**
  48905. * Gets or sets if audio support is enabled
  48906. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48907. */
  48908. audioEnabled: boolean;
  48909. /**
  48910. * Gets or sets if audio will be output to headphones
  48911. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48912. */
  48913. headphone: boolean;
  48914. /**
  48915. * Gets or sets custom audio listener position provider
  48916. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48917. */
  48918. audioListenerPositionProvider: Nullable<() => Vector3>;
  48919. /**
  48920. * Gets or sets a refresh rate when using 3D audio positioning
  48921. */
  48922. audioPositioningRefreshRate: number;
  48923. }
  48924. /**
  48925. * Defines the sound scene component responsible to manage any sounds
  48926. * in a given scene.
  48927. */
  48928. export class AudioSceneComponent implements ISceneSerializableComponent {
  48929. private static _CameraDirectionLH;
  48930. private static _CameraDirectionRH;
  48931. /**
  48932. * The component name helpful to identify the component in the list of scene components.
  48933. */
  48934. readonly name: string;
  48935. /**
  48936. * The scene the component belongs to.
  48937. */
  48938. scene: Scene;
  48939. private _audioEnabled;
  48940. /**
  48941. * Gets whether audio is enabled or not.
  48942. * Please use related enable/disable method to switch state.
  48943. */
  48944. get audioEnabled(): boolean;
  48945. private _headphone;
  48946. /**
  48947. * Gets whether audio is outputting to headphone or not.
  48948. * Please use the according Switch methods to change output.
  48949. */
  48950. get headphone(): boolean;
  48951. /**
  48952. * Gets or sets a refresh rate when using 3D audio positioning
  48953. */
  48954. audioPositioningRefreshRate: number;
  48955. private _audioListenerPositionProvider;
  48956. /**
  48957. * Gets the current audio listener position provider
  48958. */
  48959. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  48960. /**
  48961. * Sets a custom listener position for all sounds in the scene
  48962. * By default, this is the position of the first active camera
  48963. */
  48964. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  48965. /**
  48966. * Creates a new instance of the component for the given scene
  48967. * @param scene Defines the scene to register the component in
  48968. */
  48969. constructor(scene: Scene);
  48970. /**
  48971. * Registers the component in a given scene
  48972. */
  48973. register(): void;
  48974. /**
  48975. * Rebuilds the elements related to this component in case of
  48976. * context lost for instance.
  48977. */
  48978. rebuild(): void;
  48979. /**
  48980. * Serializes the component data to the specified json object
  48981. * @param serializationObject The object to serialize to
  48982. */
  48983. serialize(serializationObject: any): void;
  48984. /**
  48985. * Adds all the elements from the container to the scene
  48986. * @param container the container holding the elements
  48987. */
  48988. addFromContainer(container: AbstractScene): void;
  48989. /**
  48990. * Removes all the elements in the container from the scene
  48991. * @param container contains the elements to remove
  48992. * @param dispose if the removed element should be disposed (default: false)
  48993. */
  48994. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48995. /**
  48996. * Disposes the component and the associated resources.
  48997. */
  48998. dispose(): void;
  48999. /**
  49000. * Disables audio in the associated scene.
  49001. */
  49002. disableAudio(): void;
  49003. /**
  49004. * Enables audio in the associated scene.
  49005. */
  49006. enableAudio(): void;
  49007. /**
  49008. * Switch audio to headphone output.
  49009. */
  49010. switchAudioModeForHeadphones(): void;
  49011. /**
  49012. * Switch audio to normal speakers.
  49013. */
  49014. switchAudioModeForNormalSpeakers(): void;
  49015. private _cachedCameraDirection;
  49016. private _cachedCameraPosition;
  49017. private _lastCheck;
  49018. private _afterRender;
  49019. }
  49020. }
  49021. declare module BABYLON {
  49022. /**
  49023. * Wraps one or more Sound objects and selects one with random weight for playback.
  49024. */
  49025. export class WeightedSound {
  49026. /** When true a Sound will be selected and played when the current playing Sound completes. */
  49027. loop: boolean;
  49028. private _coneInnerAngle;
  49029. private _coneOuterAngle;
  49030. private _volume;
  49031. /** A Sound is currently playing. */
  49032. isPlaying: boolean;
  49033. /** A Sound is currently paused. */
  49034. isPaused: boolean;
  49035. private _sounds;
  49036. private _weights;
  49037. private _currentIndex?;
  49038. /**
  49039. * Creates a new WeightedSound from the list of sounds given.
  49040. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  49041. * @param sounds Array of Sounds that will be selected from.
  49042. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  49043. */
  49044. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  49045. /**
  49046. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49047. */
  49048. get directionalConeInnerAngle(): number;
  49049. /**
  49050. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49051. */
  49052. set directionalConeInnerAngle(value: number);
  49053. /**
  49054. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49055. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49056. */
  49057. get directionalConeOuterAngle(): number;
  49058. /**
  49059. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49060. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49061. */
  49062. set directionalConeOuterAngle(value: number);
  49063. /**
  49064. * Playback volume.
  49065. */
  49066. get volume(): number;
  49067. /**
  49068. * Playback volume.
  49069. */
  49070. set volume(value: number);
  49071. private _onended;
  49072. /**
  49073. * Suspend playback
  49074. */
  49075. pause(): void;
  49076. /**
  49077. * Stop playback
  49078. */
  49079. stop(): void;
  49080. /**
  49081. * Start playback.
  49082. * @param startOffset Position the clip head at a specific time in seconds.
  49083. */
  49084. play(startOffset?: number): void;
  49085. }
  49086. }
  49087. declare module BABYLON {
  49088. /**
  49089. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  49090. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49091. */
  49092. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  49093. /**
  49094. * Gets the name of the behavior.
  49095. */
  49096. get name(): string;
  49097. /**
  49098. * The easing function used by animations
  49099. */
  49100. static EasingFunction: BackEase;
  49101. /**
  49102. * The easing mode used by animations
  49103. */
  49104. static EasingMode: number;
  49105. /**
  49106. * The duration of the animation, in milliseconds
  49107. */
  49108. transitionDuration: number;
  49109. /**
  49110. * Length of the distance animated by the transition when lower radius is reached
  49111. */
  49112. lowerRadiusTransitionRange: number;
  49113. /**
  49114. * Length of the distance animated by the transition when upper radius is reached
  49115. */
  49116. upperRadiusTransitionRange: number;
  49117. private _autoTransitionRange;
  49118. /**
  49119. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49120. */
  49121. get autoTransitionRange(): boolean;
  49122. /**
  49123. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49124. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  49125. */
  49126. set autoTransitionRange(value: boolean);
  49127. private _attachedCamera;
  49128. private _onAfterCheckInputsObserver;
  49129. private _onMeshTargetChangedObserver;
  49130. /**
  49131. * Initializes the behavior.
  49132. */
  49133. init(): void;
  49134. /**
  49135. * Attaches the behavior to its arc rotate camera.
  49136. * @param camera Defines the camera to attach the behavior to
  49137. */
  49138. attach(camera: ArcRotateCamera): void;
  49139. /**
  49140. * Detaches the behavior from its current arc rotate camera.
  49141. */
  49142. detach(): void;
  49143. private _radiusIsAnimating;
  49144. private _radiusBounceTransition;
  49145. private _animatables;
  49146. private _cachedWheelPrecision;
  49147. /**
  49148. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  49149. * @param radiusLimit The limit to check against.
  49150. * @return Bool to indicate if at limit.
  49151. */
  49152. private _isRadiusAtLimit;
  49153. /**
  49154. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  49155. * @param radiusDelta The delta by which to animate to. Can be negative.
  49156. */
  49157. private _applyBoundRadiusAnimation;
  49158. /**
  49159. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  49160. */
  49161. protected _clearAnimationLocks(): void;
  49162. /**
  49163. * Stops and removes all animations that have been applied to the camera
  49164. */
  49165. stopAllAnimations(): void;
  49166. }
  49167. }
  49168. declare module BABYLON {
  49169. /**
  49170. * The framing behavior (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.
  49171. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49172. */
  49173. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  49174. /**
  49175. * Gets the name of the behavior.
  49176. */
  49177. get name(): string;
  49178. private _mode;
  49179. private _radiusScale;
  49180. private _positionScale;
  49181. private _defaultElevation;
  49182. private _elevationReturnTime;
  49183. private _elevationReturnWaitTime;
  49184. private _zoomStopsAnimation;
  49185. private _framingTime;
  49186. /**
  49187. * The easing function used by animations
  49188. */
  49189. static EasingFunction: ExponentialEase;
  49190. /**
  49191. * The easing mode used by animations
  49192. */
  49193. static EasingMode: number;
  49194. /**
  49195. * Sets the current mode used by the behavior
  49196. */
  49197. set mode(mode: number);
  49198. /**
  49199. * Gets current mode used by the behavior.
  49200. */
  49201. get mode(): number;
  49202. /**
  49203. * Sets the scale applied to the radius (1 by default)
  49204. */
  49205. set radiusScale(radius: number);
  49206. /**
  49207. * Gets the scale applied to the radius
  49208. */
  49209. get radiusScale(): number;
  49210. /**
  49211. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49212. */
  49213. set positionScale(scale: number);
  49214. /**
  49215. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49216. */
  49217. get positionScale(): number;
  49218. /**
  49219. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49220. * behaviour is triggered, in radians.
  49221. */
  49222. set defaultElevation(elevation: number);
  49223. /**
  49224. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49225. * behaviour is triggered, in radians.
  49226. */
  49227. get defaultElevation(): number;
  49228. /**
  49229. * Sets the time (in milliseconds) taken to return to the default beta position.
  49230. * Negative value indicates camera should not return to default.
  49231. */
  49232. set elevationReturnTime(speed: number);
  49233. /**
  49234. * Gets the time (in milliseconds) taken to return to the default beta position.
  49235. * Negative value indicates camera should not return to default.
  49236. */
  49237. get elevationReturnTime(): number;
  49238. /**
  49239. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49240. */
  49241. set elevationReturnWaitTime(time: number);
  49242. /**
  49243. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49244. */
  49245. get elevationReturnWaitTime(): number;
  49246. /**
  49247. * Sets the flag that indicates if user zooming should stop animation.
  49248. */
  49249. set zoomStopsAnimation(flag: boolean);
  49250. /**
  49251. * Gets the flag that indicates if user zooming should stop animation.
  49252. */
  49253. get zoomStopsAnimation(): boolean;
  49254. /**
  49255. * Sets the transition time when framing the mesh, in milliseconds
  49256. */
  49257. set framingTime(time: number);
  49258. /**
  49259. * Gets the transition time when framing the mesh, in milliseconds
  49260. */
  49261. get framingTime(): number;
  49262. /**
  49263. * Define if the behavior should automatically change the configured
  49264. * camera limits and sensibilities.
  49265. */
  49266. autoCorrectCameraLimitsAndSensibility: boolean;
  49267. private _onPrePointerObservableObserver;
  49268. private _onAfterCheckInputsObserver;
  49269. private _onMeshTargetChangedObserver;
  49270. private _attachedCamera;
  49271. private _isPointerDown;
  49272. private _lastInteractionTime;
  49273. /**
  49274. * Initializes the behavior.
  49275. */
  49276. init(): void;
  49277. /**
  49278. * Attaches the behavior to its arc rotate camera.
  49279. * @param camera Defines the camera to attach the behavior to
  49280. */
  49281. attach(camera: ArcRotateCamera): void;
  49282. /**
  49283. * Detaches the behavior from its current arc rotate camera.
  49284. */
  49285. detach(): void;
  49286. private _animatables;
  49287. private _betaIsAnimating;
  49288. private _betaTransition;
  49289. private _radiusTransition;
  49290. private _vectorTransition;
  49291. /**
  49292. * Targets the given mesh and updates zoom level accordingly.
  49293. * @param mesh The mesh to target.
  49294. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49295. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49296. */
  49297. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49298. /**
  49299. * Targets the given mesh with its children and updates zoom level accordingly.
  49300. * @param mesh The mesh to target.
  49301. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49302. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49303. */
  49304. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49305. /**
  49306. * Targets the given meshes with their children and updates zoom level accordingly.
  49307. * @param meshes The mesh to target.
  49308. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49309. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49310. */
  49311. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49312. /**
  49313. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  49314. * @param minimumWorld Determines the smaller position of the bounding box extend
  49315. * @param maximumWorld Determines the bigger position of the bounding box extend
  49316. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49317. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49318. */
  49319. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49320. /**
  49321. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  49322. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  49323. * frustum width.
  49324. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  49325. * to fully enclose the mesh in the viewing frustum.
  49326. */
  49327. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  49328. /**
  49329. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  49330. * is automatically returned to its default position (expected to be above ground plane).
  49331. */
  49332. private _maintainCameraAboveGround;
  49333. /**
  49334. * Returns the frustum slope based on the canvas ratio and camera FOV
  49335. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  49336. */
  49337. private _getFrustumSlope;
  49338. /**
  49339. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  49340. */
  49341. private _clearAnimationLocks;
  49342. /**
  49343. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49344. */
  49345. private _applyUserInteraction;
  49346. /**
  49347. * Stops and removes all animations that have been applied to the camera
  49348. */
  49349. stopAllAnimations(): void;
  49350. /**
  49351. * Gets a value indicating if the user is moving the camera
  49352. */
  49353. get isUserIsMoving(): boolean;
  49354. /**
  49355. * The camera can move all the way towards the mesh.
  49356. */
  49357. static IgnoreBoundsSizeMode: number;
  49358. /**
  49359. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  49360. */
  49361. static FitFrustumSidesMode: number;
  49362. }
  49363. }
  49364. declare module BABYLON {
  49365. /**
  49366. * Base class for Camera Pointer Inputs.
  49367. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  49368. * for example usage.
  49369. */
  49370. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  49371. /**
  49372. * Defines the camera the input is attached to.
  49373. */
  49374. abstract camera: Camera;
  49375. /**
  49376. * Whether keyboard modifier keys are pressed at time of last mouse event.
  49377. */
  49378. protected _altKey: boolean;
  49379. protected _ctrlKey: boolean;
  49380. protected _metaKey: boolean;
  49381. protected _shiftKey: boolean;
  49382. /**
  49383. * Which mouse buttons were pressed at time of last mouse event.
  49384. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  49385. */
  49386. protected _buttonsPressed: number;
  49387. /**
  49388. * Defines the buttons associated with the input to handle camera move.
  49389. */
  49390. buttons: number[];
  49391. /**
  49392. * Attach the input controls to a specific dom element to get the input from.
  49393. * @param element Defines the element the controls should be listened from
  49394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49395. */
  49396. attachControl(noPreventDefault?: boolean): void;
  49397. /**
  49398. * Detach the current controls from the specified dom element.
  49399. */
  49400. detachControl(): void;
  49401. /**
  49402. * Gets the class name of the current input.
  49403. * @returns the class name
  49404. */
  49405. getClassName(): string;
  49406. /**
  49407. * Get the friendly name associated with the input class.
  49408. * @returns the input friendly name
  49409. */
  49410. getSimpleName(): string;
  49411. /**
  49412. * Called on pointer POINTERDOUBLETAP event.
  49413. * Override this method to provide functionality on POINTERDOUBLETAP event.
  49414. */
  49415. protected onDoubleTap(type: string): void;
  49416. /**
  49417. * Called on pointer POINTERMOVE event if only a single touch is active.
  49418. * Override this method to provide functionality.
  49419. */
  49420. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49421. /**
  49422. * Called on pointer POINTERMOVE event if multiple touches are active.
  49423. * Override this method to provide functionality.
  49424. */
  49425. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49426. /**
  49427. * Called on JS contextmenu event.
  49428. * Override this method to provide functionality.
  49429. */
  49430. protected onContextMenu(evt: PointerEvent): void;
  49431. /**
  49432. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49433. * press.
  49434. * Override this method to provide functionality.
  49435. */
  49436. protected onButtonDown(evt: PointerEvent): void;
  49437. /**
  49438. * Called each time a new POINTERUP event occurs. Ie, for each button
  49439. * release.
  49440. * Override this method to provide functionality.
  49441. */
  49442. protected onButtonUp(evt: PointerEvent): void;
  49443. /**
  49444. * Called when window becomes inactive.
  49445. * Override this method to provide functionality.
  49446. */
  49447. protected onLostFocus(): void;
  49448. private _pointerInput;
  49449. private _observer;
  49450. private _onLostFocus;
  49451. private pointA;
  49452. private pointB;
  49453. }
  49454. }
  49455. declare module BABYLON {
  49456. /**
  49457. * Manage the pointers inputs to control an arc rotate camera.
  49458. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49459. */
  49460. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49461. /**
  49462. * Defines the camera the input is attached to.
  49463. */
  49464. camera: ArcRotateCamera;
  49465. /**
  49466. * Gets the class name of the current input.
  49467. * @returns the class name
  49468. */
  49469. getClassName(): string;
  49470. /**
  49471. * Defines the buttons associated with the input to handle camera move.
  49472. */
  49473. buttons: number[];
  49474. /**
  49475. * Defines the pointer angular sensibility along the X axis or how fast is
  49476. * the camera rotating.
  49477. */
  49478. angularSensibilityX: number;
  49479. /**
  49480. * Defines the pointer angular sensibility along the Y axis or how fast is
  49481. * the camera rotating.
  49482. */
  49483. angularSensibilityY: number;
  49484. /**
  49485. * Defines the pointer pinch precision or how fast is the camera zooming.
  49486. */
  49487. pinchPrecision: number;
  49488. /**
  49489. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49490. * from 0.
  49491. * It defines the percentage of current camera.radius to use as delta when
  49492. * pinch zoom is used.
  49493. */
  49494. pinchDeltaPercentage: number;
  49495. /**
  49496. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49497. * that any object in the plane at the camera's target point will scale
  49498. * perfectly with finger motion.
  49499. * Overrides pinchDeltaPercentage and pinchPrecision.
  49500. */
  49501. useNaturalPinchZoom: boolean;
  49502. /**
  49503. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  49504. */
  49505. pinchZoom: boolean;
  49506. /**
  49507. * Defines the pointer panning sensibility or how fast is the camera moving.
  49508. */
  49509. panningSensibility: number;
  49510. /**
  49511. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49512. */
  49513. multiTouchPanning: boolean;
  49514. /**
  49515. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49516. * zoom (pinch) through multitouch.
  49517. */
  49518. multiTouchPanAndZoom: boolean;
  49519. /**
  49520. * Revers pinch action direction.
  49521. */
  49522. pinchInwards: boolean;
  49523. private _isPanClick;
  49524. private _twoFingerActivityCount;
  49525. private _isPinching;
  49526. /**
  49527. * Move camera from multi touch panning positions.
  49528. */
  49529. private _computeMultiTouchPanning;
  49530. /**
  49531. * Move camera from pinch zoom distances.
  49532. */
  49533. private _computePinchZoom;
  49534. /**
  49535. * Called on pointer POINTERMOVE event if only a single touch is active.
  49536. */
  49537. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49538. /**
  49539. * Called on pointer POINTERDOUBLETAP event.
  49540. */
  49541. protected onDoubleTap(type: string): void;
  49542. /**
  49543. * Called on pointer POINTERMOVE event if multiple touches are active.
  49544. */
  49545. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49546. /**
  49547. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49548. * press.
  49549. */
  49550. protected onButtonDown(evt: PointerEvent): void;
  49551. /**
  49552. * Called each time a new POINTERUP event occurs. Ie, for each button
  49553. * release.
  49554. */
  49555. protected onButtonUp(evt: PointerEvent): void;
  49556. /**
  49557. * Called when window becomes inactive.
  49558. */
  49559. protected onLostFocus(): void;
  49560. }
  49561. }
  49562. declare module BABYLON {
  49563. /**
  49564. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49565. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49566. */
  49567. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49568. /**
  49569. * Defines the camera the input is attached to.
  49570. */
  49571. camera: ArcRotateCamera;
  49572. /**
  49573. * Defines the list of key codes associated with the up action (increase alpha)
  49574. */
  49575. keysUp: number[];
  49576. /**
  49577. * Defines the list of key codes associated with the down action (decrease alpha)
  49578. */
  49579. keysDown: number[];
  49580. /**
  49581. * Defines the list of key codes associated with the left action (increase beta)
  49582. */
  49583. keysLeft: number[];
  49584. /**
  49585. * Defines the list of key codes associated with the right action (decrease beta)
  49586. */
  49587. keysRight: number[];
  49588. /**
  49589. * Defines the list of key codes associated with the reset action.
  49590. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49591. */
  49592. keysReset: number[];
  49593. /**
  49594. * Defines the panning sensibility of the inputs.
  49595. * (How fast is the camera panning)
  49596. */
  49597. panningSensibility: number;
  49598. /**
  49599. * Defines the zooming sensibility of the inputs.
  49600. * (How fast is the camera zooming)
  49601. */
  49602. zoomingSensibility: number;
  49603. /**
  49604. * Defines whether maintaining the alt key down switch the movement mode from
  49605. * orientation to zoom.
  49606. */
  49607. useAltToZoom: boolean;
  49608. /**
  49609. * Rotation speed of the camera
  49610. */
  49611. angularSpeed: number;
  49612. private _keys;
  49613. private _ctrlPressed;
  49614. private _altPressed;
  49615. private _onCanvasBlurObserver;
  49616. private _onKeyboardObserver;
  49617. private _engine;
  49618. private _scene;
  49619. /**
  49620. * Attach the input controls to a specific dom element to get the input from.
  49621. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49622. */
  49623. attachControl(noPreventDefault?: boolean): void;
  49624. /**
  49625. * Detach the current controls from the specified dom element.
  49626. */
  49627. detachControl(): void;
  49628. /**
  49629. * Update the current camera state depending on the inputs that have been used this frame.
  49630. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49631. */
  49632. checkInputs(): void;
  49633. /**
  49634. * Gets the class name of the current input.
  49635. * @returns the class name
  49636. */
  49637. getClassName(): string;
  49638. /**
  49639. * Get the friendly name associated with the input class.
  49640. * @returns the input friendly name
  49641. */
  49642. getSimpleName(): string;
  49643. }
  49644. }
  49645. declare module BABYLON {
  49646. /**
  49647. * Manage the mouse wheel inputs to control an arc rotate camera.
  49648. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49649. */
  49650. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49651. /**
  49652. * Defines the camera the input is attached to.
  49653. */
  49654. camera: ArcRotateCamera;
  49655. /**
  49656. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49657. */
  49658. wheelPrecision: number;
  49659. /**
  49660. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49661. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49662. */
  49663. wheelDeltaPercentage: number;
  49664. private _wheel;
  49665. private _observer;
  49666. private computeDeltaFromMouseWheelLegacyEvent;
  49667. /**
  49668. * Attach the input controls to a specific dom element to get the input from.
  49669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49670. */
  49671. attachControl(noPreventDefault?: boolean): void;
  49672. /**
  49673. * Detach the current controls from the specified dom element.
  49674. */
  49675. detachControl(): void;
  49676. /**
  49677. * Gets the class name of the current input.
  49678. * @returns the class name
  49679. */
  49680. getClassName(): string;
  49681. /**
  49682. * Get the friendly name associated with the input class.
  49683. * @returns the input friendly name
  49684. */
  49685. getSimpleName(): string;
  49686. }
  49687. }
  49688. declare module BABYLON {
  49689. /**
  49690. * Default Inputs manager for the ArcRotateCamera.
  49691. * It groups all the default supported inputs for ease of use.
  49692. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49693. */
  49694. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49695. /**
  49696. * Instantiates a new ArcRotateCameraInputsManager.
  49697. * @param camera Defines the camera the inputs belong to
  49698. */
  49699. constructor(camera: ArcRotateCamera);
  49700. /**
  49701. * Add mouse wheel input support to the input manager.
  49702. * @returns the current input manager
  49703. */
  49704. addMouseWheel(): ArcRotateCameraInputsManager;
  49705. /**
  49706. * Add pointers input support to the input manager.
  49707. * @returns the current input manager
  49708. */
  49709. addPointers(): ArcRotateCameraInputsManager;
  49710. /**
  49711. * Add keyboard input support to the input manager.
  49712. * @returns the current input manager
  49713. */
  49714. addKeyboard(): ArcRotateCameraInputsManager;
  49715. }
  49716. }
  49717. declare module BABYLON {
  49718. /**
  49719. * This represents an orbital type of camera.
  49720. *
  49721. * 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.
  49722. * 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.
  49723. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49724. */
  49725. export class ArcRotateCamera extends TargetCamera {
  49726. /**
  49727. * Defines the rotation angle of the camera along the longitudinal axis.
  49728. */
  49729. alpha: number;
  49730. /**
  49731. * Defines the rotation angle of the camera along the latitudinal axis.
  49732. */
  49733. beta: number;
  49734. /**
  49735. * Defines the radius of the camera from it s target point.
  49736. */
  49737. radius: number;
  49738. protected _target: Vector3;
  49739. protected _targetHost: Nullable<AbstractMesh>;
  49740. /**
  49741. * Defines the target point of the camera.
  49742. * The camera looks towards it form the radius distance.
  49743. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49744. */
  49745. get target(): Vector3;
  49746. set target(value: Vector3);
  49747. /**
  49748. * Define the current local position of the camera in the scene
  49749. */
  49750. get position(): Vector3;
  49751. set position(newPosition: Vector3);
  49752. protected _upToYMatrix: Matrix;
  49753. protected _YToUpMatrix: Matrix;
  49754. /**
  49755. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49756. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  49757. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  49758. */
  49759. set upVector(vec: Vector3);
  49760. get upVector(): Vector3;
  49761. /**
  49762. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  49763. */
  49764. setMatUp(): void;
  49765. /**
  49766. * Current inertia value on the longitudinal axis.
  49767. * The bigger this number the longer it will take for the camera to stop.
  49768. */
  49769. inertialAlphaOffset: number;
  49770. /**
  49771. * Current inertia value on the latitudinal axis.
  49772. * The bigger this number the longer it will take for the camera to stop.
  49773. */
  49774. inertialBetaOffset: number;
  49775. /**
  49776. * Current inertia value on the radius axis.
  49777. * The bigger this number the longer it will take for the camera to stop.
  49778. */
  49779. inertialRadiusOffset: number;
  49780. /**
  49781. * Minimum allowed angle on the longitudinal axis.
  49782. * This can help limiting how the Camera is able to move in the scene.
  49783. */
  49784. lowerAlphaLimit: Nullable<number>;
  49785. /**
  49786. * Maximum allowed angle on the longitudinal axis.
  49787. * This can help limiting how the Camera is able to move in the scene.
  49788. */
  49789. upperAlphaLimit: Nullable<number>;
  49790. /**
  49791. * Minimum allowed angle on the latitudinal axis.
  49792. * This can help limiting how the Camera is able to move in the scene.
  49793. */
  49794. lowerBetaLimit: number;
  49795. /**
  49796. * Maximum allowed angle on the latitudinal axis.
  49797. * This can help limiting how the Camera is able to move in the scene.
  49798. */
  49799. upperBetaLimit: number;
  49800. /**
  49801. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  49802. * This can help limiting how the Camera is able to move in the scene.
  49803. */
  49804. lowerRadiusLimit: Nullable<number>;
  49805. /**
  49806. * Maximum allowed distance of the camera to the target (The camera can not get further).
  49807. * This can help limiting how the Camera is able to move in the scene.
  49808. */
  49809. upperRadiusLimit: Nullable<number>;
  49810. /**
  49811. * Defines the current inertia value used during panning of the camera along the X axis.
  49812. */
  49813. inertialPanningX: number;
  49814. /**
  49815. * Defines the current inertia value used during panning of the camera along the Y axis.
  49816. */
  49817. inertialPanningY: number;
  49818. /**
  49819. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  49820. * Basically if your fingers moves away from more than this distance you will be considered
  49821. * in pinch mode.
  49822. */
  49823. pinchToPanMaxDistance: number;
  49824. /**
  49825. * Defines the maximum distance the camera can pan.
  49826. * This could help keeping the camera always in your scene.
  49827. */
  49828. panningDistanceLimit: Nullable<number>;
  49829. /**
  49830. * Defines the target of the camera before panning.
  49831. */
  49832. panningOriginTarget: Vector3;
  49833. /**
  49834. * Defines the value of the inertia used during panning.
  49835. * 0 would mean stop inertia and one would mean no decelleration at all.
  49836. */
  49837. panningInertia: number;
  49838. /**
  49839. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  49840. */
  49841. get angularSensibilityX(): number;
  49842. set angularSensibilityX(value: number);
  49843. /**
  49844. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  49845. */
  49846. get angularSensibilityY(): number;
  49847. set angularSensibilityY(value: number);
  49848. /**
  49849. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  49850. */
  49851. get pinchPrecision(): number;
  49852. set pinchPrecision(value: number);
  49853. /**
  49854. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  49855. * It will be used instead of pinchDeltaPrecision if different from 0.
  49856. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49857. */
  49858. get pinchDeltaPercentage(): number;
  49859. set pinchDeltaPercentage(value: number);
  49860. /**
  49861. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  49862. * and pinch delta percentage.
  49863. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49864. * that any object in the plane at the camera's target point will scale
  49865. * perfectly with finger motion.
  49866. */
  49867. get useNaturalPinchZoom(): boolean;
  49868. set useNaturalPinchZoom(value: boolean);
  49869. /**
  49870. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  49871. */
  49872. get panningSensibility(): number;
  49873. set panningSensibility(value: number);
  49874. /**
  49875. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  49876. */
  49877. get keysUp(): number[];
  49878. set keysUp(value: number[]);
  49879. /**
  49880. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  49881. */
  49882. get keysDown(): number[];
  49883. set keysDown(value: number[]);
  49884. /**
  49885. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  49886. */
  49887. get keysLeft(): number[];
  49888. set keysLeft(value: number[]);
  49889. /**
  49890. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  49891. */
  49892. get keysRight(): number[];
  49893. set keysRight(value: number[]);
  49894. /**
  49895. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49896. */
  49897. get wheelPrecision(): number;
  49898. set wheelPrecision(value: number);
  49899. /**
  49900. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  49901. * It will be used instead of pinchDeltaPrecision if different from 0.
  49902. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49903. */
  49904. get wheelDeltaPercentage(): number;
  49905. set wheelDeltaPercentage(value: number);
  49906. /**
  49907. * Defines how much the radius should be scaled while zooming on a particular mesh (through the zoomOn function)
  49908. */
  49909. zoomOnFactor: number;
  49910. /**
  49911. * Defines a screen offset for the camera position.
  49912. */
  49913. targetScreenOffset: Vector2;
  49914. /**
  49915. * Allows the camera to be completely reversed.
  49916. * If false the camera can not arrive upside down.
  49917. */
  49918. allowUpsideDown: boolean;
  49919. /**
  49920. * Define if double tap/click is used to restore the previously saved state of the camera.
  49921. */
  49922. useInputToRestoreState: boolean;
  49923. /** @hidden */
  49924. _viewMatrix: Matrix;
  49925. /** @hidden */
  49926. _useCtrlForPanning: boolean;
  49927. /** @hidden */
  49928. _panningMouseButton: number;
  49929. /**
  49930. * Defines the input associated to the camera.
  49931. */
  49932. inputs: ArcRotateCameraInputsManager;
  49933. /** @hidden */
  49934. _reset: () => void;
  49935. /**
  49936. * Defines the allowed panning axis.
  49937. */
  49938. panningAxis: Vector3;
  49939. protected _transformedDirection: Vector3;
  49940. private _bouncingBehavior;
  49941. /**
  49942. * Gets the bouncing behavior of the camera if it has been enabled.
  49943. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49944. */
  49945. get bouncingBehavior(): Nullable<BouncingBehavior>;
  49946. /**
  49947. * Defines if the bouncing behavior of the camera is enabled on the camera.
  49948. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49949. */
  49950. get useBouncingBehavior(): boolean;
  49951. set useBouncingBehavior(value: boolean);
  49952. private _framingBehavior;
  49953. /**
  49954. * Gets the framing behavior of the camera if it has been enabled.
  49955. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49956. */
  49957. get framingBehavior(): Nullable<FramingBehavior>;
  49958. /**
  49959. * Defines if the framing behavior of the camera is enabled on the camera.
  49960. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49961. */
  49962. get useFramingBehavior(): boolean;
  49963. set useFramingBehavior(value: boolean);
  49964. private _autoRotationBehavior;
  49965. /**
  49966. * Gets the auto rotation behavior of the camera if it has been enabled.
  49967. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49968. */
  49969. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  49970. /**
  49971. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  49972. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49973. */
  49974. get useAutoRotationBehavior(): boolean;
  49975. set useAutoRotationBehavior(value: boolean);
  49976. /**
  49977. * Observable triggered when the mesh target has been changed on the camera.
  49978. */
  49979. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  49980. /**
  49981. * Event raised when the camera is colliding with a mesh.
  49982. */
  49983. onCollide: (collidedMesh: AbstractMesh) => void;
  49984. /**
  49985. * Defines whether the camera should check collision with the objects oh the scene.
  49986. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  49987. */
  49988. checkCollisions: boolean;
  49989. /**
  49990. * Defines the collision radius of the camera.
  49991. * This simulates a sphere around the camera.
  49992. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49993. */
  49994. collisionRadius: Vector3;
  49995. protected _collider: Collider;
  49996. protected _previousPosition: Vector3;
  49997. protected _collisionVelocity: Vector3;
  49998. protected _newPosition: Vector3;
  49999. protected _previousAlpha: number;
  50000. protected _previousBeta: number;
  50001. protected _previousRadius: number;
  50002. protected _collisionTriggered: boolean;
  50003. protected _targetBoundingCenter: Nullable<Vector3>;
  50004. private _computationVector;
  50005. /**
  50006. * Instantiates a new ArcRotateCamera in a given scene
  50007. * @param name Defines the name of the camera
  50008. * @param alpha Defines the camera rotation along the longitudinal axis
  50009. * @param beta Defines the camera rotation along the latitudinal axis
  50010. * @param radius Defines the camera distance from its target
  50011. * @param target Defines the camera target
  50012. * @param scene Defines the scene the camera belongs to
  50013. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  50014. */
  50015. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50016. /** @hidden */
  50017. _initCache(): void;
  50018. /** @hidden */
  50019. _updateCache(ignoreParentClass?: boolean): void;
  50020. protected _getTargetPosition(): Vector3;
  50021. private _storedAlpha;
  50022. private _storedBeta;
  50023. private _storedRadius;
  50024. private _storedTarget;
  50025. private _storedTargetScreenOffset;
  50026. /**
  50027. * Stores the current state of the camera (alpha, beta, radius and target)
  50028. * @returns the camera itself
  50029. */
  50030. storeState(): Camera;
  50031. /**
  50032. * @hidden
  50033. * Restored camera state. You must call storeState() first
  50034. */
  50035. _restoreStateValues(): boolean;
  50036. /** @hidden */
  50037. _isSynchronizedViewMatrix(): boolean;
  50038. /**
  50039. * Attach the input controls to a specific dom element to get the input from.
  50040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50041. */
  50042. attachControl(noPreventDefault?: boolean): void;
  50043. /**
  50044. * Attach the input controls to a specific dom element to get the input from.
  50045. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  50046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50047. */
  50048. attachControl(ignored: any, noPreventDefault?: boolean): void;
  50049. /**
  50050. * Attached controls to the current camera.
  50051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50052. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50053. */
  50054. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50055. /**
  50056. * Attached controls to the current camera.
  50057. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  50058. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50059. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50060. */
  50061. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50062. /**
  50063. * Attached controls to the current camera.
  50064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50065. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50066. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  50067. */
  50068. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  50069. /**
  50070. * Detach the current controls from the specified dom element.
  50071. */
  50072. detachControl(): void;
  50073. /**
  50074. * Detach the current controls from the specified dom element.
  50075. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  50076. */
  50077. detachControl(ignored: any): void;
  50078. /** @hidden */
  50079. _checkInputs(): void;
  50080. protected _checkLimits(): void;
  50081. /**
  50082. * Rebuilds angles (alpha, beta) and radius from the give position and target
  50083. */
  50084. rebuildAnglesAndRadius(): void;
  50085. /**
  50086. * Use a position to define the current camera related information like alpha, beta and radius
  50087. * @param position Defines the position to set the camera at
  50088. */
  50089. setPosition(position: Vector3): void;
  50090. /**
  50091. * Defines the target the camera should look at.
  50092. * This will automatically adapt alpha beta and radius to fit within the new target.
  50093. * @param target Defines the new target as a Vector or a mesh
  50094. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  50095. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  50096. */
  50097. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  50098. /** @hidden */
  50099. _getViewMatrix(): Matrix;
  50100. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  50101. /**
  50102. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  50103. * @param meshes Defines the mesh to zoom on
  50104. * @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)
  50105. */
  50106. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  50107. /**
  50108. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  50109. * The target will be changed but the radius
  50110. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  50111. * @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)
  50112. */
  50113. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  50114. min: Vector3;
  50115. max: Vector3;
  50116. distance: number;
  50117. }, doNotUpdateMaxZ?: boolean): void;
  50118. /**
  50119. * @override
  50120. * Override Camera.createRigCamera
  50121. */
  50122. createRigCamera(name: string, cameraIndex: number): Camera;
  50123. /**
  50124. * @hidden
  50125. * @override
  50126. * Override Camera._updateRigCameras
  50127. */
  50128. _updateRigCameras(): void;
  50129. /**
  50130. * Destroy the camera and release the current resources hold by it.
  50131. */
  50132. dispose(): void;
  50133. /**
  50134. * Gets the current object class name.
  50135. * @return the class name
  50136. */
  50137. getClassName(): string;
  50138. }
  50139. }
  50140. declare module BABYLON {
  50141. /**
  50142. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  50143. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50144. */
  50145. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  50146. /**
  50147. * Gets the name of the behavior.
  50148. */
  50149. get name(): string;
  50150. private _zoomStopsAnimation;
  50151. private _idleRotationSpeed;
  50152. private _idleRotationWaitTime;
  50153. private _idleRotationSpinupTime;
  50154. /**
  50155. * Sets the flag that indicates if user zooming should stop animation.
  50156. */
  50157. set zoomStopsAnimation(flag: boolean);
  50158. /**
  50159. * Gets the flag that indicates if user zooming should stop animation.
  50160. */
  50161. get zoomStopsAnimation(): boolean;
  50162. /**
  50163. * Sets the default speed at which the camera rotates around the model.
  50164. */
  50165. set idleRotationSpeed(speed: number);
  50166. /**
  50167. * Gets the default speed at which the camera rotates around the model.
  50168. */
  50169. get idleRotationSpeed(): number;
  50170. /**
  50171. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  50172. */
  50173. set idleRotationWaitTime(time: number);
  50174. /**
  50175. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  50176. */
  50177. get idleRotationWaitTime(): number;
  50178. /**
  50179. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  50180. */
  50181. set idleRotationSpinupTime(time: number);
  50182. /**
  50183. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  50184. */
  50185. get idleRotationSpinupTime(): number;
  50186. /**
  50187. * Gets a value indicating if the camera is currently rotating because of this behavior
  50188. */
  50189. get rotationInProgress(): boolean;
  50190. private _onPrePointerObservableObserver;
  50191. private _onAfterCheckInputsObserver;
  50192. private _attachedCamera;
  50193. private _isPointerDown;
  50194. private _lastFrameTime;
  50195. private _lastInteractionTime;
  50196. private _cameraRotationSpeed;
  50197. /**
  50198. * Initializes the behavior.
  50199. */
  50200. init(): void;
  50201. /**
  50202. * Attaches the behavior to its arc rotate camera.
  50203. * @param camera Defines the camera to attach the behavior to
  50204. */
  50205. attach(camera: ArcRotateCamera): void;
  50206. /**
  50207. * Detaches the behavior from its current arc rotate camera.
  50208. */
  50209. detach(): void;
  50210. /**
  50211. * Returns true if user is scrolling.
  50212. * @return true if user is scrolling.
  50213. */
  50214. private _userIsZooming;
  50215. private _lastFrameRadius;
  50216. private _shouldAnimationStopForInteraction;
  50217. /**
  50218. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50219. */
  50220. private _applyUserInteraction;
  50221. private _userIsMoving;
  50222. }
  50223. }
  50224. declare module BABYLON {
  50225. /**
  50226. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  50227. */
  50228. export class AttachToBoxBehavior implements Behavior<Mesh> {
  50229. private ui;
  50230. /**
  50231. * The name of the behavior
  50232. */
  50233. name: string;
  50234. /**
  50235. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  50236. */
  50237. distanceAwayFromFace: number;
  50238. /**
  50239. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  50240. */
  50241. distanceAwayFromBottomOfFace: number;
  50242. private _faceVectors;
  50243. private _target;
  50244. private _scene;
  50245. private _onRenderObserver;
  50246. private _tmpMatrix;
  50247. private _tmpVector;
  50248. /**
  50249. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  50250. * @param ui The transform node that should be attached to the mesh
  50251. */
  50252. constructor(ui: TransformNode);
  50253. /**
  50254. * Initializes the behavior
  50255. */
  50256. init(): void;
  50257. private _closestFace;
  50258. private _zeroVector;
  50259. private _lookAtTmpMatrix;
  50260. private _lookAtToRef;
  50261. /**
  50262. * Attaches the AttachToBoxBehavior to the passed in mesh
  50263. * @param target The mesh that the specified node will be attached to
  50264. */
  50265. attach(target: Mesh): void;
  50266. /**
  50267. * Detaches the behavior from the mesh
  50268. */
  50269. detach(): void;
  50270. }
  50271. }
  50272. declare module BABYLON {
  50273. /**
  50274. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  50275. */
  50276. export class FadeInOutBehavior implements Behavior<Mesh> {
  50277. /**
  50278. * Time in milliseconds to delay before fading in (Default: 0)
  50279. */
  50280. delay: number;
  50281. /**
  50282. * Time in milliseconds for the mesh to fade in (Default: 300)
  50283. */
  50284. fadeInTime: number;
  50285. private _millisecondsPerFrame;
  50286. private _hovered;
  50287. private _hoverValue;
  50288. private _ownerNode;
  50289. /**
  50290. * Instantiates the FadeInOutBehavior
  50291. */
  50292. constructor();
  50293. /**
  50294. * The name of the behavior
  50295. */
  50296. get name(): string;
  50297. /**
  50298. * Initializes the behavior
  50299. */
  50300. init(): void;
  50301. /**
  50302. * Attaches the fade behavior on the passed in mesh
  50303. * @param ownerNode The mesh that will be faded in/out once attached
  50304. */
  50305. attach(ownerNode: Mesh): void;
  50306. /**
  50307. * Detaches the behavior from the mesh
  50308. */
  50309. detach(): void;
  50310. /**
  50311. * Triggers the mesh to begin fading in or out
  50312. * @param value if the object should fade in or out (true to fade in)
  50313. */
  50314. fadeIn(value: boolean): void;
  50315. private _update;
  50316. private _setAllVisibility;
  50317. }
  50318. }
  50319. declare module BABYLON {
  50320. /**
  50321. * Class containing a set of static utilities functions for managing Pivots
  50322. * @hidden
  50323. */
  50324. export class PivotTools {
  50325. private static _PivotCached;
  50326. private static _OldPivotPoint;
  50327. private static _PivotTranslation;
  50328. private static _PivotTmpVector;
  50329. private static _PivotPostMultiplyPivotMatrix;
  50330. /** @hidden */
  50331. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  50332. /** @hidden */
  50333. static _RestorePivotPoint(mesh: AbstractMesh): void;
  50334. }
  50335. }
  50336. declare module BABYLON {
  50337. /**
  50338. * Class containing static functions to help procedurally build meshes
  50339. */
  50340. export class PlaneBuilder {
  50341. /**
  50342. * Creates a plane mesh
  50343. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50344. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50345. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50347. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50349. * @param name defines the name of the mesh
  50350. * @param options defines the options used to create the mesh
  50351. * @param scene defines the hosting scene
  50352. * @returns the plane mesh
  50353. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50354. */
  50355. static CreatePlane(name: string, options: {
  50356. size?: number;
  50357. width?: number;
  50358. height?: number;
  50359. sideOrientation?: number;
  50360. frontUVs?: Vector4;
  50361. backUVs?: Vector4;
  50362. updatable?: boolean;
  50363. sourcePlane?: Plane;
  50364. }, scene?: Nullable<Scene>): Mesh;
  50365. }
  50366. }
  50367. declare module BABYLON {
  50368. /**
  50369. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  50370. */
  50371. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  50372. private static _AnyMouseID;
  50373. /**
  50374. * Abstract mesh the behavior is set on
  50375. */
  50376. attachedNode: AbstractMesh;
  50377. private _dragPlane;
  50378. private _scene;
  50379. private _pointerObserver;
  50380. private _beforeRenderObserver;
  50381. private static _planeScene;
  50382. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  50383. /**
  50384. * 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)
  50385. */
  50386. maxDragAngle: number;
  50387. /**
  50388. * @hidden
  50389. */
  50390. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  50391. /**
  50392. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50393. */
  50394. currentDraggingPointerID: number;
  50395. /**
  50396. * The last position where the pointer hit the drag plane in world space
  50397. */
  50398. lastDragPosition: Vector3;
  50399. /**
  50400. * If the behavior is currently in a dragging state
  50401. */
  50402. dragging: boolean;
  50403. /**
  50404. * 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)
  50405. */
  50406. dragDeltaRatio: number;
  50407. /**
  50408. * If the drag plane orientation should be updated during the dragging (Default: true)
  50409. */
  50410. updateDragPlane: boolean;
  50411. private _debugMode;
  50412. private _moving;
  50413. /**
  50414. * Fires each time the attached mesh is dragged with the pointer
  50415. * * delta between last drag position and current drag position in world space
  50416. * * dragDistance along the drag axis
  50417. * * dragPlaneNormal normal of the current drag plane used during the drag
  50418. * * dragPlanePoint in world space where the drag intersects the drag plane
  50419. */
  50420. onDragObservable: Observable<{
  50421. delta: Vector3;
  50422. dragPlanePoint: Vector3;
  50423. dragPlaneNormal: Vector3;
  50424. dragDistance: number;
  50425. pointerId: number;
  50426. }>;
  50427. /**
  50428. * Fires each time a drag begins (eg. mouse down on mesh)
  50429. */
  50430. onDragStartObservable: Observable<{
  50431. dragPlanePoint: Vector3;
  50432. pointerId: number;
  50433. }>;
  50434. /**
  50435. * Fires each time a drag ends (eg. mouse release after drag)
  50436. */
  50437. onDragEndObservable: Observable<{
  50438. dragPlanePoint: Vector3;
  50439. pointerId: number;
  50440. }>;
  50441. /**
  50442. * If the attached mesh should be moved when dragged
  50443. */
  50444. moveAttached: boolean;
  50445. /**
  50446. * If the drag behavior will react to drag events (Default: true)
  50447. */
  50448. enabled: boolean;
  50449. /**
  50450. * If pointer events should start and release the drag (Default: true)
  50451. */
  50452. startAndReleaseDragOnPointerEvents: boolean;
  50453. /**
  50454. * If camera controls should be detached during the drag
  50455. */
  50456. detachCameraControls: boolean;
  50457. /**
  50458. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  50459. */
  50460. useObjectOrientationForDragging: boolean;
  50461. private _options;
  50462. /**
  50463. * Gets the options used by the behavior
  50464. */
  50465. get options(): {
  50466. dragAxis?: Vector3;
  50467. dragPlaneNormal?: Vector3;
  50468. };
  50469. /**
  50470. * Sets the options used by the behavior
  50471. */
  50472. set options(options: {
  50473. dragAxis?: Vector3;
  50474. dragPlaneNormal?: Vector3;
  50475. });
  50476. /**
  50477. * Creates a pointer drag behavior that can be attached to a mesh
  50478. * @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)
  50479. */
  50480. constructor(options?: {
  50481. dragAxis?: Vector3;
  50482. dragPlaneNormal?: Vector3;
  50483. });
  50484. /**
  50485. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50486. */
  50487. validateDrag: (targetPosition: Vector3) => boolean;
  50488. /**
  50489. * The name of the behavior
  50490. */
  50491. get name(): string;
  50492. /**
  50493. * Initializes the behavior
  50494. */
  50495. init(): void;
  50496. private _tmpVector;
  50497. private _alternatePickedPoint;
  50498. private _worldDragAxis;
  50499. private _targetPosition;
  50500. private _attachedToElement;
  50501. /**
  50502. * Attaches the drag behavior the passed in mesh
  50503. * @param ownerNode The mesh that will be dragged around once attached
  50504. * @param predicate Predicate to use for pick filtering
  50505. */
  50506. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50507. /**
  50508. * Force release the drag action by code.
  50509. */
  50510. releaseDrag(): void;
  50511. private _startDragRay;
  50512. private _lastPointerRay;
  50513. /**
  50514. * Simulates the start of a pointer drag event on the behavior
  50515. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50516. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50517. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50518. */
  50519. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50520. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50521. private _dragDelta;
  50522. protected _moveDrag(ray: Ray): void;
  50523. private _pickWithRayOnDragPlane;
  50524. private _pointA;
  50525. private _pointC;
  50526. private _localAxis;
  50527. private _lookAt;
  50528. private _updateDragPlanePosition;
  50529. /**
  50530. * Detaches the behavior from the mesh
  50531. */
  50532. detach(): void;
  50533. }
  50534. }
  50535. declare module BABYLON {
  50536. /**
  50537. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50538. */
  50539. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50540. private _dragBehaviorA;
  50541. private _dragBehaviorB;
  50542. private _startDistance;
  50543. private _initialScale;
  50544. private _targetScale;
  50545. private _ownerNode;
  50546. private _sceneRenderObserver;
  50547. /**
  50548. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50549. */
  50550. constructor();
  50551. /**
  50552. * The name of the behavior
  50553. */
  50554. get name(): string;
  50555. /**
  50556. * Initializes the behavior
  50557. */
  50558. init(): void;
  50559. private _getCurrentDistance;
  50560. /**
  50561. * Attaches the scale behavior the passed in mesh
  50562. * @param ownerNode The mesh that will be scaled around once attached
  50563. */
  50564. attach(ownerNode: Mesh): void;
  50565. /**
  50566. * Detaches the behavior from the mesh
  50567. */
  50568. detach(): void;
  50569. }
  50570. }
  50571. declare module BABYLON {
  50572. /**
  50573. * 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
  50574. */
  50575. export class SixDofDragBehavior implements Behavior<Mesh> {
  50576. private static _virtualScene;
  50577. private _ownerNode;
  50578. private _sceneRenderObserver;
  50579. private _scene;
  50580. private _targetPosition;
  50581. private _virtualOriginMesh;
  50582. private _virtualDragMesh;
  50583. private _pointerObserver;
  50584. private _moving;
  50585. private _startingOrientation;
  50586. private _attachedToElement;
  50587. /**
  50588. * 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)
  50589. */
  50590. private zDragFactor;
  50591. /**
  50592. * If the object should rotate to face the drag origin
  50593. */
  50594. rotateDraggedObject: boolean;
  50595. /**
  50596. * If the behavior is currently in a dragging state
  50597. */
  50598. dragging: boolean;
  50599. /**
  50600. * 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)
  50601. */
  50602. dragDeltaRatio: number;
  50603. /**
  50604. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50605. */
  50606. currentDraggingPointerID: number;
  50607. /**
  50608. * If camera controls should be detached during the drag
  50609. */
  50610. detachCameraControls: boolean;
  50611. /**
  50612. * Fires each time a drag starts
  50613. */
  50614. onDragStartObservable: Observable<{}>;
  50615. /**
  50616. * Fires each time a drag happens
  50617. */
  50618. onDragObservable: Observable<void>;
  50619. /**
  50620. * Fires each time a drag ends (eg. mouse release after drag)
  50621. */
  50622. onDragEndObservable: Observable<{}>;
  50623. /**
  50624. * 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
  50625. */
  50626. constructor();
  50627. /**
  50628. * The name of the behavior
  50629. */
  50630. get name(): string;
  50631. /**
  50632. * Initializes the behavior
  50633. */
  50634. init(): void;
  50635. /**
  50636. * In the case of multiple active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50637. */
  50638. private get _pointerCamera();
  50639. /**
  50640. * Attaches the scale behavior the passed in mesh
  50641. * @param ownerNode The mesh that will be scaled around once attached
  50642. */
  50643. attach(ownerNode: Mesh): void;
  50644. /**
  50645. * Detaches the behavior from the mesh
  50646. */
  50647. detach(): void;
  50648. }
  50649. }
  50650. declare module BABYLON {
  50651. /**
  50652. * Class used to apply inverse kinematics to bones
  50653. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50654. */
  50655. export class BoneIKController {
  50656. private static _tmpVecs;
  50657. private static _tmpQuat;
  50658. private static _tmpMats;
  50659. /**
  50660. * Gets or sets the target mesh
  50661. */
  50662. targetMesh: AbstractMesh;
  50663. /** Gets or sets the mesh used as pole */
  50664. poleTargetMesh: AbstractMesh;
  50665. /**
  50666. * Gets or sets the bone used as pole
  50667. */
  50668. poleTargetBone: Nullable<Bone>;
  50669. /**
  50670. * Gets or sets the target position
  50671. */
  50672. targetPosition: Vector3;
  50673. /**
  50674. * Gets or sets the pole target position
  50675. */
  50676. poleTargetPosition: Vector3;
  50677. /**
  50678. * Gets or sets the pole target local offset
  50679. */
  50680. poleTargetLocalOffset: Vector3;
  50681. /**
  50682. * Gets or sets the pole angle
  50683. */
  50684. poleAngle: number;
  50685. /**
  50686. * Gets or sets the mesh associated with the controller
  50687. */
  50688. mesh: AbstractMesh;
  50689. /**
  50690. * 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)
  50691. */
  50692. slerpAmount: number;
  50693. private _bone1Quat;
  50694. private _bone1Mat;
  50695. private _bone2Ang;
  50696. private _bone1;
  50697. private _bone2;
  50698. private _bone1Length;
  50699. private _bone2Length;
  50700. private _maxAngle;
  50701. private _maxReach;
  50702. private _rightHandedSystem;
  50703. private _bendAxis;
  50704. private _slerping;
  50705. private _adjustRoll;
  50706. /**
  50707. * Gets or sets maximum allowed angle
  50708. */
  50709. get maxAngle(): number;
  50710. set maxAngle(value: number);
  50711. /**
  50712. * Creates a new BoneIKController
  50713. * @param mesh defines the mesh to control
  50714. * @param bone defines the bone to control
  50715. * @param options defines options to set up the controller
  50716. */
  50717. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50718. targetMesh?: AbstractMesh;
  50719. poleTargetMesh?: AbstractMesh;
  50720. poleTargetBone?: Bone;
  50721. poleTargetLocalOffset?: Vector3;
  50722. poleAngle?: number;
  50723. bendAxis?: Vector3;
  50724. maxAngle?: number;
  50725. slerpAmount?: number;
  50726. });
  50727. private _setMaxAngle;
  50728. /**
  50729. * Force the controller to update the bones
  50730. */
  50731. update(): void;
  50732. }
  50733. }
  50734. declare module BABYLON {
  50735. /**
  50736. * Class used to make a bone look toward a point in space
  50737. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50738. */
  50739. export class BoneLookController {
  50740. private static _tmpVecs;
  50741. private static _tmpQuat;
  50742. private static _tmpMats;
  50743. /**
  50744. * The target Vector3 that the bone will look at
  50745. */
  50746. target: Vector3;
  50747. /**
  50748. * The mesh that the bone is attached to
  50749. */
  50750. mesh: AbstractMesh;
  50751. /**
  50752. * The bone that will be looking to the target
  50753. */
  50754. bone: Bone;
  50755. /**
  50756. * The up axis of the coordinate system that is used when the bone is rotated
  50757. */
  50758. upAxis: Vector3;
  50759. /**
  50760. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  50761. */
  50762. upAxisSpace: Space;
  50763. /**
  50764. * Used to make an adjustment to the yaw of the bone
  50765. */
  50766. adjustYaw: number;
  50767. /**
  50768. * Used to make an adjustment to the pitch of the bone
  50769. */
  50770. adjustPitch: number;
  50771. /**
  50772. * Used to make an adjustment to the roll of the bone
  50773. */
  50774. adjustRoll: number;
  50775. /**
  50776. * 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)
  50777. */
  50778. slerpAmount: number;
  50779. private _minYaw;
  50780. private _maxYaw;
  50781. private _minPitch;
  50782. private _maxPitch;
  50783. private _minYawSin;
  50784. private _minYawCos;
  50785. private _maxYawSin;
  50786. private _maxYawCos;
  50787. private _midYawConstraint;
  50788. private _minPitchTan;
  50789. private _maxPitchTan;
  50790. private _boneQuat;
  50791. private _slerping;
  50792. private _transformYawPitch;
  50793. private _transformYawPitchInv;
  50794. private _firstFrameSkipped;
  50795. private _yawRange;
  50796. private _fowardAxis;
  50797. /**
  50798. * Gets or sets the minimum yaw angle that the bone can look to
  50799. */
  50800. get minYaw(): number;
  50801. set minYaw(value: number);
  50802. /**
  50803. * Gets or sets the maximum yaw angle that the bone can look to
  50804. */
  50805. get maxYaw(): number;
  50806. set maxYaw(value: number);
  50807. /**
  50808. * Gets or sets the minimum pitch angle that the bone can look to
  50809. */
  50810. get minPitch(): number;
  50811. set minPitch(value: number);
  50812. /**
  50813. * Gets or sets the maximum pitch angle that the bone can look to
  50814. */
  50815. get maxPitch(): number;
  50816. set maxPitch(value: number);
  50817. /**
  50818. * Create a BoneLookController
  50819. * @param mesh the mesh that the bone belongs to
  50820. * @param bone the bone that will be looking to the target
  50821. * @param target the target Vector3 to look at
  50822. * @param options optional settings:
  50823. * * maxYaw: the maximum angle the bone will yaw to
  50824. * * minYaw: the minimum angle the bone will yaw to
  50825. * * maxPitch: the maximum angle the bone will pitch to
  50826. * * minPitch: the minimum angle the bone will yaw to
  50827. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  50828. * * upAxis: the up axis of the coordinate system
  50829. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  50830. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  50831. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  50832. * * adjustYaw: used to make an adjustment to the yaw of the bone
  50833. * * adjustPitch: used to make an adjustment to the pitch of the bone
  50834. * * adjustRoll: used to make an adjustment to the roll of the bone
  50835. **/
  50836. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  50837. maxYaw?: number;
  50838. minYaw?: number;
  50839. maxPitch?: number;
  50840. minPitch?: number;
  50841. slerpAmount?: number;
  50842. upAxis?: Vector3;
  50843. upAxisSpace?: Space;
  50844. yawAxis?: Vector3;
  50845. pitchAxis?: Vector3;
  50846. adjustYaw?: number;
  50847. adjustPitch?: number;
  50848. adjustRoll?: number;
  50849. });
  50850. /**
  50851. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  50852. */
  50853. update(): void;
  50854. private _getAngleDiff;
  50855. private _getAngleBetween;
  50856. private _isAngleBetween;
  50857. }
  50858. }
  50859. declare module BABYLON {
  50860. /**
  50861. * Manage the gamepad inputs to control an arc rotate camera.
  50862. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50863. */
  50864. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  50865. /**
  50866. * Defines the camera the input is attached to.
  50867. */
  50868. camera: ArcRotateCamera;
  50869. /**
  50870. * Defines the gamepad the input is gathering event from.
  50871. */
  50872. gamepad: Nullable<Gamepad>;
  50873. /**
  50874. * Defines the gamepad rotation sensiblity.
  50875. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50876. */
  50877. gamepadRotationSensibility: number;
  50878. /**
  50879. * Defines the gamepad move sensiblity.
  50880. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50881. */
  50882. gamepadMoveSensibility: number;
  50883. private _yAxisScale;
  50884. /**
  50885. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50886. */
  50887. get invertYAxis(): boolean;
  50888. set invertYAxis(value: boolean);
  50889. private _onGamepadConnectedObserver;
  50890. private _onGamepadDisconnectedObserver;
  50891. /**
  50892. * Attach the input controls to a specific dom element to get the input from.
  50893. */
  50894. attachControl(): void;
  50895. /**
  50896. * Detach the current controls from the specified dom element.
  50897. */
  50898. detachControl(): void;
  50899. /**
  50900. * Update the current camera state depending on the inputs that have been used this frame.
  50901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50902. */
  50903. checkInputs(): void;
  50904. /**
  50905. * Gets the class name of the current intput.
  50906. * @returns the class name
  50907. */
  50908. getClassName(): string;
  50909. /**
  50910. * Get the friendly name associated with the input class.
  50911. * @returns the input friendly name
  50912. */
  50913. getSimpleName(): string;
  50914. }
  50915. }
  50916. declare module BABYLON {
  50917. interface ArcRotateCameraInputsManager {
  50918. /**
  50919. * Add orientation input support to the input manager.
  50920. * @returns the current input manager
  50921. */
  50922. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  50923. }
  50924. /**
  50925. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  50926. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50927. */
  50928. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  50929. /**
  50930. * Defines the camera the input is attached to.
  50931. */
  50932. camera: ArcRotateCamera;
  50933. /**
  50934. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  50935. */
  50936. alphaCorrection: number;
  50937. /**
  50938. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  50939. */
  50940. gammaCorrection: number;
  50941. private _alpha;
  50942. private _gamma;
  50943. private _dirty;
  50944. private _deviceOrientationHandler;
  50945. /**
  50946. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  50947. */
  50948. constructor();
  50949. /**
  50950. * Attach the input controls to a specific dom element to get the input from.
  50951. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50952. */
  50953. attachControl(noPreventDefault?: boolean): void;
  50954. /** @hidden */
  50955. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  50956. /**
  50957. * Update the current camera state depending on the inputs that have been used this frame.
  50958. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50959. */
  50960. checkInputs(): void;
  50961. /**
  50962. * Detach the current controls from the specified dom element.
  50963. */
  50964. detachControl(): void;
  50965. /**
  50966. * Gets the class name of the current input.
  50967. * @returns the class name
  50968. */
  50969. getClassName(): string;
  50970. /**
  50971. * Get the friendly name associated with the input class.
  50972. * @returns the input friendly name
  50973. */
  50974. getSimpleName(): string;
  50975. }
  50976. }
  50977. declare module BABYLON {
  50978. /**
  50979. * Listen to mouse events to control the camera.
  50980. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50981. */
  50982. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  50983. /**
  50984. * Defines the camera the input is attached to.
  50985. */
  50986. camera: FlyCamera;
  50987. /**
  50988. * Defines if touch is enabled. (Default is true.)
  50989. */
  50990. touchEnabled: boolean;
  50991. /**
  50992. * Defines the buttons associated with the input to handle camera rotation.
  50993. */
  50994. buttons: number[];
  50995. /**
  50996. * Assign buttons for Yaw control.
  50997. */
  50998. buttonsYaw: number[];
  50999. /**
  51000. * Assign buttons for Pitch control.
  51001. */
  51002. buttonsPitch: number[];
  51003. /**
  51004. * Assign buttons for Roll control.
  51005. */
  51006. buttonsRoll: number[];
  51007. /**
  51008. * Detect if any button is being pressed while mouse is moved.
  51009. * -1 = Mouse locked.
  51010. * 0 = Left button.
  51011. * 1 = Middle Button.
  51012. * 2 = Right Button.
  51013. */
  51014. activeButton: number;
  51015. /**
  51016. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  51017. * Higher values reduce its sensitivity.
  51018. */
  51019. angularSensibility: number;
  51020. private _observer;
  51021. private _rollObserver;
  51022. private previousPosition;
  51023. private noPreventDefault;
  51024. private element;
  51025. /**
  51026. * Listen to mouse events to control the camera.
  51027. * @param touchEnabled Define if touch is enabled. (Default is true.)
  51028. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51029. */
  51030. constructor(touchEnabled?: boolean);
  51031. /**
  51032. * Attach the mouse control to the HTML DOM element.
  51033. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  51034. */
  51035. attachControl(noPreventDefault?: boolean): void;
  51036. /**
  51037. * Detach the current controls from the specified dom element.
  51038. */
  51039. detachControl(): void;
  51040. /**
  51041. * Gets the class name of the current input.
  51042. * @returns the class name.
  51043. */
  51044. getClassName(): string;
  51045. /**
  51046. * Get the friendly name associated with the input class.
  51047. * @returns the input's friendly name.
  51048. */
  51049. getSimpleName(): string;
  51050. private _pointerInput;
  51051. private _onMouseMove;
  51052. /**
  51053. * Rotate camera by mouse offset.
  51054. */
  51055. private rotateCamera;
  51056. }
  51057. }
  51058. declare module BABYLON {
  51059. /**
  51060. * Default Inputs manager for the FlyCamera.
  51061. * It groups all the default supported inputs for ease of use.
  51062. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51063. */
  51064. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  51065. /**
  51066. * Instantiates a new FlyCameraInputsManager.
  51067. * @param camera Defines the camera the inputs belong to.
  51068. */
  51069. constructor(camera: FlyCamera);
  51070. /**
  51071. * Add keyboard input support to the input manager.
  51072. * @returns the new FlyCameraKeyboardMoveInput().
  51073. */
  51074. addKeyboard(): FlyCameraInputsManager;
  51075. /**
  51076. * Add mouse input support to the input manager.
  51077. * @param touchEnabled Enable touch screen support.
  51078. * @returns the new FlyCameraMouseInput().
  51079. */
  51080. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  51081. }
  51082. }
  51083. declare module BABYLON {
  51084. /**
  51085. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51086. * such as in a 3D Space Shooter or a Flight Simulator.
  51087. */
  51088. export class FlyCamera extends TargetCamera {
  51089. /**
  51090. * Define the collision ellipsoid of the camera.
  51091. * This is helpful for simulating a camera body, like a player's body.
  51092. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  51093. */
  51094. ellipsoid: Vector3;
  51095. /**
  51096. * Define an offset for the position of the ellipsoid around the camera.
  51097. * This can be helpful if the camera is attached away from the player's body center,
  51098. * such as at its head.
  51099. */
  51100. ellipsoidOffset: Vector3;
  51101. /**
  51102. * Enable or disable collisions of the camera with the rest of the scene objects.
  51103. */
  51104. checkCollisions: boolean;
  51105. /**
  51106. * Enable or disable gravity on the camera.
  51107. */
  51108. applyGravity: boolean;
  51109. /**
  51110. * Define the current direction the camera is moving to.
  51111. */
  51112. cameraDirection: Vector3;
  51113. /**
  51114. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  51115. * This overrides and empties cameraRotation.
  51116. */
  51117. rotationQuaternion: Quaternion;
  51118. /**
  51119. * Track Roll to maintain the wanted Rolling when looking around.
  51120. */
  51121. _trackRoll: number;
  51122. /**
  51123. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  51124. */
  51125. rollCorrect: number;
  51126. /**
  51127. * Mimic a banked turn, Rolling the camera when Yawing.
  51128. * It's recommended to use rollCorrect = 10 for faster banking correction.
  51129. */
  51130. bankedTurn: boolean;
  51131. /**
  51132. * Limit in radians for how much Roll banking will add. (Default: 90°)
  51133. */
  51134. bankedTurnLimit: number;
  51135. /**
  51136. * Value of 0 disables the banked Roll.
  51137. * Value of 1 is equal to the Yaw angle in radians.
  51138. */
  51139. bankedTurnMultiplier: number;
  51140. /**
  51141. * The inputs manager loads all the input sources, such as keyboard and mouse.
  51142. */
  51143. inputs: FlyCameraInputsManager;
  51144. /**
  51145. * Gets the input sensibility for mouse input.
  51146. * Higher values reduce sensitivity.
  51147. */
  51148. get angularSensibility(): number;
  51149. /**
  51150. * Sets the input sensibility for a mouse input.
  51151. * Higher values reduce sensitivity.
  51152. */
  51153. set angularSensibility(value: number);
  51154. /**
  51155. * Get the keys for camera movement forward.
  51156. */
  51157. get keysForward(): number[];
  51158. /**
  51159. * Set the keys for camera movement forward.
  51160. */
  51161. set keysForward(value: number[]);
  51162. /**
  51163. * Get the keys for camera movement backward.
  51164. */
  51165. get keysBackward(): number[];
  51166. set keysBackward(value: number[]);
  51167. /**
  51168. * Get the keys for camera movement up.
  51169. */
  51170. get keysUp(): number[];
  51171. /**
  51172. * Set the keys for camera movement up.
  51173. */
  51174. set keysUp(value: number[]);
  51175. /**
  51176. * Get the keys for camera movement down.
  51177. */
  51178. get keysDown(): number[];
  51179. /**
  51180. * Set the keys for camera movement down.
  51181. */
  51182. set keysDown(value: number[]);
  51183. /**
  51184. * Get the keys for camera movement left.
  51185. */
  51186. get keysLeft(): number[];
  51187. /**
  51188. * Set the keys for camera movement left.
  51189. */
  51190. set keysLeft(value: number[]);
  51191. /**
  51192. * Set the keys for camera movement right.
  51193. */
  51194. get keysRight(): number[];
  51195. /**
  51196. * Set the keys for camera movement right.
  51197. */
  51198. set keysRight(value: number[]);
  51199. /**
  51200. * Event raised when the camera collides with a mesh in the scene.
  51201. */
  51202. onCollide: (collidedMesh: AbstractMesh) => void;
  51203. private _collider;
  51204. private _needMoveForGravity;
  51205. private _oldPosition;
  51206. private _diffPosition;
  51207. private _newPosition;
  51208. /** @hidden */
  51209. _localDirection: Vector3;
  51210. /** @hidden */
  51211. _transformedDirection: Vector3;
  51212. /**
  51213. * Instantiates a FlyCamera.
  51214. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51215. * such as in a 3D Space Shooter or a Flight Simulator.
  51216. * @param name Define the name of the camera in the scene.
  51217. * @param position Define the starting position of the camera in the scene.
  51218. * @param scene Define the scene the camera belongs to.
  51219. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active, if no other camera has been defined as active.
  51220. */
  51221. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  51222. /**
  51223. * Attach the input controls to a specific dom element to get the input from.
  51224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51225. */
  51226. attachControl(noPreventDefault?: boolean): void;
  51227. /**
  51228. * Detach a control from the HTML DOM element.
  51229. * The camera will stop reacting to that input.
  51230. */
  51231. detachControl(): void;
  51232. private _collisionMask;
  51233. /**
  51234. * Get the mask that the camera ignores in collision events.
  51235. */
  51236. get collisionMask(): number;
  51237. /**
  51238. * Set the mask that the camera ignores in collision events.
  51239. */
  51240. set collisionMask(mask: number);
  51241. /** @hidden */
  51242. _collideWithWorld(displacement: Vector3): void;
  51243. /** @hidden */
  51244. private _onCollisionPositionChange;
  51245. /** @hidden */
  51246. _checkInputs(): void;
  51247. /** @hidden */
  51248. _decideIfNeedsToMove(): boolean;
  51249. /** @hidden */
  51250. _updatePosition(): void;
  51251. /**
  51252. * Restore the Roll to its target value at the rate specified.
  51253. * @param rate - Higher means slower restoring.
  51254. * @hidden
  51255. */
  51256. restoreRoll(rate: number): void;
  51257. /**
  51258. * Destroy the camera and release the current resources held by it.
  51259. */
  51260. dispose(): void;
  51261. /**
  51262. * Get the current object class name.
  51263. * @returns the class name.
  51264. */
  51265. getClassName(): string;
  51266. }
  51267. }
  51268. declare module BABYLON {
  51269. /**
  51270. * Listen to keyboard events to control the camera.
  51271. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51272. */
  51273. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  51274. /**
  51275. * Defines the camera the input is attached to.
  51276. */
  51277. camera: FlyCamera;
  51278. /**
  51279. * The list of keyboard keys used to control the forward move of the camera.
  51280. */
  51281. keysForward: number[];
  51282. /**
  51283. * The list of keyboard keys used to control the backward move of the camera.
  51284. */
  51285. keysBackward: number[];
  51286. /**
  51287. * The list of keyboard keys used to control the forward move of the camera.
  51288. */
  51289. keysUp: number[];
  51290. /**
  51291. * The list of keyboard keys used to control the backward move of the camera.
  51292. */
  51293. keysDown: number[];
  51294. /**
  51295. * The list of keyboard keys used to control the right strafe move of the camera.
  51296. */
  51297. keysRight: number[];
  51298. /**
  51299. * The list of keyboard keys used to control the left strafe move of the camera.
  51300. */
  51301. keysLeft: number[];
  51302. private _keys;
  51303. private _onCanvasBlurObserver;
  51304. private _onKeyboardObserver;
  51305. private _engine;
  51306. private _scene;
  51307. /**
  51308. * Attach the input controls to a specific dom element to get the input from.
  51309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51310. */
  51311. attachControl(noPreventDefault?: boolean): void;
  51312. /**
  51313. * Detach the current controls from the specified dom element.
  51314. */
  51315. detachControl(): void;
  51316. /**
  51317. * Gets the class name of the current intput.
  51318. * @returns the class name
  51319. */
  51320. getClassName(): string;
  51321. /** @hidden */
  51322. _onLostFocus(e: FocusEvent): void;
  51323. /**
  51324. * Get the friendly name associated with the input class.
  51325. * @returns the input friendly name
  51326. */
  51327. getSimpleName(): string;
  51328. /**
  51329. * Update the current camera state depending on the inputs that have been used this frame.
  51330. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51331. */
  51332. checkInputs(): void;
  51333. }
  51334. }
  51335. declare module BABYLON {
  51336. /**
  51337. * Manage the mouse wheel inputs to control a follow camera.
  51338. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51339. */
  51340. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  51341. /**
  51342. * Defines the camera the input is attached to.
  51343. */
  51344. camera: FollowCamera;
  51345. /**
  51346. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  51347. */
  51348. axisControlRadius: boolean;
  51349. /**
  51350. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  51351. */
  51352. axisControlHeight: boolean;
  51353. /**
  51354. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  51355. */
  51356. axisControlRotation: boolean;
  51357. /**
  51358. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  51359. * relation to mouseWheel events.
  51360. */
  51361. wheelPrecision: number;
  51362. /**
  51363. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51364. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51365. */
  51366. wheelDeltaPercentage: number;
  51367. private _wheel;
  51368. private _observer;
  51369. /**
  51370. * Attach the input controls to a specific dom element to get the input from.
  51371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51372. */
  51373. attachControl(noPreventDefault?: boolean): void;
  51374. /**
  51375. * Detach the current controls from the specified dom element.
  51376. */
  51377. detachControl(): void;
  51378. /**
  51379. * Gets the class name of the current input.
  51380. * @returns the class name
  51381. */
  51382. getClassName(): string;
  51383. /**
  51384. * Get the friendly name associated with the input class.
  51385. * @returns the input friendly name
  51386. */
  51387. getSimpleName(): string;
  51388. }
  51389. }
  51390. declare module BABYLON {
  51391. /**
  51392. * Manage the pointers inputs to control an follow camera.
  51393. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51394. */
  51395. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  51396. /**
  51397. * Defines the camera the input is attached to.
  51398. */
  51399. camera: FollowCamera;
  51400. /**
  51401. * Gets the class name of the current input.
  51402. * @returns the class name
  51403. */
  51404. getClassName(): string;
  51405. /**
  51406. * Defines the pointer angular sensibility along the X axis or how fast is
  51407. * the camera rotating.
  51408. * A negative number will reverse the axis direction.
  51409. */
  51410. angularSensibilityX: number;
  51411. /**
  51412. * Defines the pointer angular sensibility along the Y axis or how fast is
  51413. * the camera rotating.
  51414. * A negative number will reverse the axis direction.
  51415. */
  51416. angularSensibilityY: number;
  51417. /**
  51418. * Defines the pointer pinch precision or how fast is the camera zooming.
  51419. * A negative number will reverse the axis direction.
  51420. */
  51421. pinchPrecision: number;
  51422. /**
  51423. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  51424. * from 0.
  51425. * It defines the percentage of current camera.radius to use as delta when
  51426. * pinch zoom is used.
  51427. */
  51428. pinchDeltaPercentage: number;
  51429. /**
  51430. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  51431. */
  51432. axisXControlRadius: boolean;
  51433. /**
  51434. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  51435. */
  51436. axisXControlHeight: boolean;
  51437. /**
  51438. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  51439. */
  51440. axisXControlRotation: boolean;
  51441. /**
  51442. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  51443. */
  51444. axisYControlRadius: boolean;
  51445. /**
  51446. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  51447. */
  51448. axisYControlHeight: boolean;
  51449. /**
  51450. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  51451. */
  51452. axisYControlRotation: boolean;
  51453. /**
  51454. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  51455. */
  51456. axisPinchControlRadius: boolean;
  51457. /**
  51458. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  51459. */
  51460. axisPinchControlHeight: boolean;
  51461. /**
  51462. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  51463. */
  51464. axisPinchControlRotation: boolean;
  51465. /**
  51466. * Log error messages if basic misconfiguration has occurred.
  51467. */
  51468. warningEnable: boolean;
  51469. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51470. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51471. private _warningCounter;
  51472. private _warning;
  51473. }
  51474. }
  51475. declare module BABYLON {
  51476. /**
  51477. * Default Inputs manager for the FollowCamera.
  51478. * It groups all the default supported inputs for ease of use.
  51479. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51480. */
  51481. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51482. /**
  51483. * Instantiates a new FollowCameraInputsManager.
  51484. * @param camera Defines the camera the inputs belong to
  51485. */
  51486. constructor(camera: FollowCamera);
  51487. /**
  51488. * Add keyboard input support to the input manager.
  51489. * @returns the current input manager
  51490. */
  51491. addKeyboard(): FollowCameraInputsManager;
  51492. /**
  51493. * Add mouse wheel input support to the input manager.
  51494. * @returns the current input manager
  51495. */
  51496. addMouseWheel(): FollowCameraInputsManager;
  51497. /**
  51498. * Add pointers input support to the input manager.
  51499. * @returns the current input manager
  51500. */
  51501. addPointers(): FollowCameraInputsManager;
  51502. /**
  51503. * Add orientation input support to the input manager.
  51504. * @returns the current input manager
  51505. */
  51506. addVRDeviceOrientation(): FollowCameraInputsManager;
  51507. }
  51508. }
  51509. declare module BABYLON {
  51510. /**
  51511. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51512. * an arc rotate version arcFollowCamera are available.
  51513. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51514. */
  51515. export class FollowCamera extends TargetCamera {
  51516. /**
  51517. * Distance the follow camera should follow an object at
  51518. */
  51519. radius: number;
  51520. /**
  51521. * Minimum allowed distance of the camera to the axis of rotation
  51522. * (The camera can not get closer).
  51523. * This can help limiting how the Camera is able to move in the scene.
  51524. */
  51525. lowerRadiusLimit: Nullable<number>;
  51526. /**
  51527. * Maximum allowed distance of the camera to the axis of rotation
  51528. * (The camera can not get further).
  51529. * This can help limiting how the Camera is able to move in the scene.
  51530. */
  51531. upperRadiusLimit: Nullable<number>;
  51532. /**
  51533. * Define a rotation offset between the camera and the object it follows
  51534. */
  51535. rotationOffset: number;
  51536. /**
  51537. * Minimum allowed angle to camera position relative to target object.
  51538. * This can help limiting how the Camera is able to move in the scene.
  51539. */
  51540. lowerRotationOffsetLimit: Nullable<number>;
  51541. /**
  51542. * Maximum allowed angle to camera position relative to target object.
  51543. * This can help limiting how the Camera is able to move in the scene.
  51544. */
  51545. upperRotationOffsetLimit: Nullable<number>;
  51546. /**
  51547. * Define a height offset between the camera and the object it follows.
  51548. * It can help following an object from the top (like a car chasing a plane)
  51549. */
  51550. heightOffset: number;
  51551. /**
  51552. * Minimum allowed height of camera position relative to target object.
  51553. * This can help limiting how the Camera is able to move in the scene.
  51554. */
  51555. lowerHeightOffsetLimit: Nullable<number>;
  51556. /**
  51557. * Maximum allowed height of camera position relative to target object.
  51558. * This can help limiting how the Camera is able to move in the scene.
  51559. */
  51560. upperHeightOffsetLimit: Nullable<number>;
  51561. /**
  51562. * Define how fast the camera can accelerate to follow it s target.
  51563. */
  51564. cameraAcceleration: number;
  51565. /**
  51566. * Define the speed limit of the camera following an object.
  51567. */
  51568. maxCameraSpeed: number;
  51569. /**
  51570. * Define the target of the camera.
  51571. */
  51572. lockedTarget: Nullable<AbstractMesh>;
  51573. /**
  51574. * Defines the input associated with the camera.
  51575. */
  51576. inputs: FollowCameraInputsManager;
  51577. /**
  51578. * Instantiates the follow camera.
  51579. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51580. * @param name Define the name of the camera in the scene
  51581. * @param position Define the position of the camera
  51582. * @param scene Define the scene the camera belong to
  51583. * @param lockedTarget Define the target of the camera
  51584. */
  51585. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51586. private _follow;
  51587. /**
  51588. * Attach the input controls to a specific dom element to get the input from.
  51589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51590. */
  51591. attachControl(noPreventDefault?: boolean): void;
  51592. /**
  51593. * Detach the current controls from the specified dom element.
  51594. */
  51595. detachControl(): void;
  51596. /** @hidden */
  51597. _checkInputs(): void;
  51598. private _checkLimits;
  51599. /**
  51600. * Gets the camera class name.
  51601. * @returns the class name
  51602. */
  51603. getClassName(): string;
  51604. }
  51605. /**
  51606. * Arc Rotate version of the follow camera.
  51607. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51608. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51609. */
  51610. export class ArcFollowCamera extends TargetCamera {
  51611. /** The longitudinal angle of the camera */
  51612. alpha: number;
  51613. /** The latitudinal angle of the camera */
  51614. beta: number;
  51615. /** The radius of the camera from its target */
  51616. radius: number;
  51617. private _cartesianCoordinates;
  51618. /** Define the camera target (the mesh it should follow) */
  51619. private _meshTarget;
  51620. /**
  51621. * Instantiates a new ArcFollowCamera
  51622. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51623. * @param name Define the name of the camera
  51624. * @param alpha Define the rotation angle of the camera around the longitudinal axis
  51625. * @param beta Define the rotation angle of the camera around the elevation axis
  51626. * @param radius Define the radius of the camera from its target point
  51627. * @param target Define the target of the camera
  51628. * @param scene Define the scene the camera belongs to
  51629. */
  51630. constructor(name: string,
  51631. /** The longitudinal angle of the camera */
  51632. alpha: number,
  51633. /** The latitudinal angle of the camera */
  51634. beta: number,
  51635. /** The radius of the camera from its target */
  51636. radius: number,
  51637. /** Define the camera target (the mesh it should follow) */
  51638. target: Nullable<AbstractMesh>, scene: Scene);
  51639. private _follow;
  51640. /** @hidden */
  51641. _checkInputs(): void;
  51642. /**
  51643. * Returns the class name of the object.
  51644. * It is mostly used internally for serialization purposes.
  51645. */
  51646. getClassName(): string;
  51647. }
  51648. }
  51649. declare module BABYLON {
  51650. /**
  51651. * Manage the keyboard inputs to control the movement of a follow camera.
  51652. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51653. */
  51654. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51655. /**
  51656. * Defines the camera the input is attached to.
  51657. */
  51658. camera: FollowCamera;
  51659. /**
  51660. * Defines the list of key codes associated with the up action (increase heightOffset)
  51661. */
  51662. keysHeightOffsetIncr: number[];
  51663. /**
  51664. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51665. */
  51666. keysHeightOffsetDecr: number[];
  51667. /**
  51668. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51669. */
  51670. keysHeightOffsetModifierAlt: boolean;
  51671. /**
  51672. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51673. */
  51674. keysHeightOffsetModifierCtrl: boolean;
  51675. /**
  51676. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51677. */
  51678. keysHeightOffsetModifierShift: boolean;
  51679. /**
  51680. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51681. */
  51682. keysRotationOffsetIncr: number[];
  51683. /**
  51684. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51685. */
  51686. keysRotationOffsetDecr: number[];
  51687. /**
  51688. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51689. */
  51690. keysRotationOffsetModifierAlt: boolean;
  51691. /**
  51692. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51693. */
  51694. keysRotationOffsetModifierCtrl: boolean;
  51695. /**
  51696. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51697. */
  51698. keysRotationOffsetModifierShift: boolean;
  51699. /**
  51700. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51701. */
  51702. keysRadiusIncr: number[];
  51703. /**
  51704. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51705. */
  51706. keysRadiusDecr: number[];
  51707. /**
  51708. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51709. */
  51710. keysRadiusModifierAlt: boolean;
  51711. /**
  51712. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51713. */
  51714. keysRadiusModifierCtrl: boolean;
  51715. /**
  51716. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51717. */
  51718. keysRadiusModifierShift: boolean;
  51719. /**
  51720. * Defines the rate of change of heightOffset.
  51721. */
  51722. heightSensibility: number;
  51723. /**
  51724. * Defines the rate of change of rotationOffset.
  51725. */
  51726. rotationSensibility: number;
  51727. /**
  51728. * Defines the rate of change of radius.
  51729. */
  51730. radiusSensibility: number;
  51731. private _keys;
  51732. private _ctrlPressed;
  51733. private _altPressed;
  51734. private _shiftPressed;
  51735. private _onCanvasBlurObserver;
  51736. private _onKeyboardObserver;
  51737. private _engine;
  51738. private _scene;
  51739. /**
  51740. * Attach the input controls to a specific dom element to get the input from.
  51741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51742. */
  51743. attachControl(noPreventDefault?: boolean): void;
  51744. /**
  51745. * Detach the current controls from the specified dom element.
  51746. */
  51747. detachControl(): void;
  51748. /**
  51749. * Update the current camera state depending on the inputs that have been used this frame.
  51750. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51751. */
  51752. checkInputs(): void;
  51753. /**
  51754. * Gets the class name of the current input.
  51755. * @returns the class name
  51756. */
  51757. getClassName(): string;
  51758. /**
  51759. * Get the friendly name associated with the input class.
  51760. * @returns the input friendly name
  51761. */
  51762. getSimpleName(): string;
  51763. /**
  51764. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51765. * allow modification of the heightOffset value.
  51766. */
  51767. private _modifierHeightOffset;
  51768. /**
  51769. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51770. * allow modification of the rotationOffset value.
  51771. */
  51772. private _modifierRotationOffset;
  51773. /**
  51774. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51775. * allow modification of the radius value.
  51776. */
  51777. private _modifierRadius;
  51778. }
  51779. }
  51780. declare module BABYLON {
  51781. interface FreeCameraInputsManager {
  51782. /**
  51783. * @hidden
  51784. */
  51785. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  51786. /**
  51787. * Add orientation input support to the input manager.
  51788. * @returns the current input manager
  51789. */
  51790. addDeviceOrientation(): FreeCameraInputsManager;
  51791. }
  51792. /**
  51793. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  51794. * Screen rotation is taken into account.
  51795. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51796. */
  51797. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  51798. private _camera;
  51799. private _screenOrientationAngle;
  51800. private _constantTranform;
  51801. private _screenQuaternion;
  51802. private _alpha;
  51803. private _beta;
  51804. private _gamma;
  51805. /**
  51806. * Can be used to detect if a device orientation sensor is available on a device
  51807. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  51808. * @returns a promise that will resolve on orientation change
  51809. */
  51810. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  51811. /**
  51812. * @hidden
  51813. */
  51814. _onDeviceOrientationChangedObservable: Observable<void>;
  51815. /**
  51816. * Instantiates a new input
  51817. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51818. */
  51819. constructor();
  51820. /**
  51821. * Define the camera controlled by the input.
  51822. */
  51823. get camera(): FreeCamera;
  51824. set camera(camera: FreeCamera);
  51825. /**
  51826. * Attach the input controls to a specific dom element to get the input from.
  51827. */
  51828. attachControl(): void;
  51829. private _orientationChanged;
  51830. private _deviceOrientation;
  51831. /**
  51832. * Detach the current controls from the specified dom element.
  51833. */
  51834. detachControl(): void;
  51835. /**
  51836. * Update the current camera state depending on the inputs that have been used this frame.
  51837. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51838. */
  51839. checkInputs(): void;
  51840. /**
  51841. * Gets the class name of the current input.
  51842. * @returns the class name
  51843. */
  51844. getClassName(): string;
  51845. /**
  51846. * Get the friendly name associated with the input class.
  51847. * @returns the input friendly name
  51848. */
  51849. getSimpleName(): string;
  51850. }
  51851. }
  51852. declare module BABYLON {
  51853. /**
  51854. * Manage the gamepad inputs to control a free camera.
  51855. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51856. */
  51857. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  51858. /**
  51859. * Define the camera the input is attached to.
  51860. */
  51861. camera: FreeCamera;
  51862. /**
  51863. * Define the Gamepad controlling the input
  51864. */
  51865. gamepad: Nullable<Gamepad>;
  51866. /**
  51867. * Defines the gamepad rotation sensiblity.
  51868. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51869. */
  51870. gamepadAngularSensibility: number;
  51871. /**
  51872. * Defines the gamepad move sensiblity.
  51873. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51874. */
  51875. gamepadMoveSensibility: number;
  51876. private _yAxisScale;
  51877. /**
  51878. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51879. */
  51880. get invertYAxis(): boolean;
  51881. set invertYAxis(value: boolean);
  51882. private _onGamepadConnectedObserver;
  51883. private _onGamepadDisconnectedObserver;
  51884. private _cameraTransform;
  51885. private _deltaTransform;
  51886. private _vector3;
  51887. private _vector2;
  51888. /**
  51889. * Attach the input controls to a specific dom element to get the input from.
  51890. */
  51891. attachControl(): void;
  51892. /**
  51893. * Detach the current controls from the specified dom element.
  51894. */
  51895. detachControl(): void;
  51896. /**
  51897. * Update the current camera state depending on the inputs that have been used this frame.
  51898. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51899. */
  51900. checkInputs(): void;
  51901. /**
  51902. * Gets the class name of the current input.
  51903. * @returns the class name
  51904. */
  51905. getClassName(): string;
  51906. /**
  51907. * Get the friendly name associated with the input class.
  51908. * @returns the input friendly name
  51909. */
  51910. getSimpleName(): string;
  51911. }
  51912. }
  51913. declare module BABYLON {
  51914. /**
  51915. * Defines the potential axis of a Joystick
  51916. */
  51917. export enum JoystickAxis {
  51918. /** X axis */
  51919. X = 0,
  51920. /** Y axis */
  51921. Y = 1,
  51922. /** Z axis */
  51923. Z = 2
  51924. }
  51925. /**
  51926. * Represents the different customization options available
  51927. * for VirtualJoystick
  51928. */
  51929. interface VirtualJoystickCustomizations {
  51930. /**
  51931. * Size of the joystick's puck
  51932. */
  51933. puckSize: number;
  51934. /**
  51935. * Size of the joystick's container
  51936. */
  51937. containerSize: number;
  51938. /**
  51939. * Color of the joystick && puck
  51940. */
  51941. color: string;
  51942. /**
  51943. * Image URL for the joystick's puck
  51944. */
  51945. puckImage?: string;
  51946. /**
  51947. * Image URL for the joystick's container
  51948. */
  51949. containerImage?: string;
  51950. /**
  51951. * Defines the unmoving position of the joystick container
  51952. */
  51953. position?: {
  51954. x: number;
  51955. y: number;
  51956. };
  51957. /**
  51958. * Defines whether or not the joystick container is always visible
  51959. */
  51960. alwaysVisible: boolean;
  51961. /**
  51962. * Defines whether or not to limit the movement of the puck to the joystick's container
  51963. */
  51964. limitToContainer: boolean;
  51965. }
  51966. /**
  51967. * Class used to define virtual joystick (used in touch mode)
  51968. */
  51969. export class VirtualJoystick {
  51970. /**
  51971. * Gets or sets a boolean indicating that left and right values must be inverted
  51972. */
  51973. reverseLeftRight: boolean;
  51974. /**
  51975. * Gets or sets a boolean indicating that up and down values must be inverted
  51976. */
  51977. reverseUpDown: boolean;
  51978. /**
  51979. * Gets the offset value for the position (ie. the change of the position value)
  51980. */
  51981. deltaPosition: Vector3;
  51982. /**
  51983. * Gets a boolean indicating if the virtual joystick was pressed
  51984. */
  51985. pressed: boolean;
  51986. /**
  51987. * Canvas the virtual joystick will render onto, default z-index of this is 5
  51988. */
  51989. static Canvas: Nullable<HTMLCanvasElement>;
  51990. /**
  51991. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  51992. */
  51993. limitToContainer: boolean;
  51994. private static _globalJoystickIndex;
  51995. private static _alwaysVisibleSticks;
  51996. private static vjCanvasContext;
  51997. private static vjCanvasWidth;
  51998. private static vjCanvasHeight;
  51999. private static halfWidth;
  52000. private static _GetDefaultOptions;
  52001. private _action;
  52002. private _axisTargetedByLeftAndRight;
  52003. private _axisTargetedByUpAndDown;
  52004. private _joystickSensibility;
  52005. private _inversedSensibility;
  52006. private _joystickPointerID;
  52007. private _joystickColor;
  52008. private _joystickPointerPos;
  52009. private _joystickPreviousPointerPos;
  52010. private _joystickPointerStartPos;
  52011. private _deltaJoystickVector;
  52012. private _leftJoystick;
  52013. private _touches;
  52014. private _joystickPosition;
  52015. private _alwaysVisible;
  52016. private _puckImage;
  52017. private _containerImage;
  52018. private _joystickPuckSize;
  52019. private _joystickContainerSize;
  52020. private _clearPuckSize;
  52021. private _clearContainerSize;
  52022. private _clearPuckSizeOffset;
  52023. private _clearContainerSizeOffset;
  52024. private _onPointerDownHandlerRef;
  52025. private _onPointerMoveHandlerRef;
  52026. private _onPointerUpHandlerRef;
  52027. private _onResize;
  52028. /**
  52029. * Creates a new virtual joystick
  52030. * @param leftJoystick defines that the joystick is for left hand (false by default)
  52031. * @param customizations Defines the options we want to customize the VirtualJoystick
  52032. */
  52033. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  52034. /**
  52035. * Defines joystick sensibility (ie. the ratio between a physical move and virtual joystick position change)
  52036. * @param newJoystickSensibility defines the new sensibility
  52037. */
  52038. setJoystickSensibility(newJoystickSensibility: number): void;
  52039. private _onPointerDown;
  52040. private _onPointerMove;
  52041. private _onPointerUp;
  52042. /**
  52043. * Change the color of the virtual joystick
  52044. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  52045. */
  52046. setJoystickColor(newColor: string): void;
  52047. /**
  52048. * Size of the joystick's container
  52049. */
  52050. set containerSize(newSize: number);
  52051. get containerSize(): number;
  52052. /**
  52053. * Size of the joystick's puck
  52054. */
  52055. set puckSize(newSize: number);
  52056. get puckSize(): number;
  52057. /**
  52058. * Clears the set position of the joystick
  52059. */
  52060. clearPosition(): void;
  52061. /**
  52062. * Defines whether or not the joystick container is always visible
  52063. */
  52064. set alwaysVisible(value: boolean);
  52065. get alwaysVisible(): boolean;
  52066. /**
  52067. * Sets the constant position of the Joystick container
  52068. * @param x X axis coordinate
  52069. * @param y Y axis coordinate
  52070. */
  52071. setPosition(x: number, y: number): void;
  52072. /**
  52073. * Defines a callback to call when the joystick is touched
  52074. * @param action defines the callback
  52075. */
  52076. setActionOnTouch(action: () => any): void;
  52077. /**
  52078. * Defines which axis you'd like to control for left & right
  52079. * @param axis defines the axis to use
  52080. */
  52081. setAxisForLeftRight(axis: JoystickAxis): void;
  52082. /**
  52083. * Defines which axis you'd like to control for up & down
  52084. * @param axis defines the axis to use
  52085. */
  52086. setAxisForUpDown(axis: JoystickAxis): void;
  52087. /**
  52088. * Clears the canvas from the previous puck / container draw
  52089. */
  52090. private _clearPreviousDraw;
  52091. /**
  52092. * Loads `urlPath` to be used for the container's image
  52093. * @param urlPath defines the urlPath of an image to use
  52094. */
  52095. setContainerImage(urlPath: string): void;
  52096. /**
  52097. * Loads `urlPath` to be used for the puck's image
  52098. * @param urlPath defines the urlPath of an image to use
  52099. */
  52100. setPuckImage(urlPath: string): void;
  52101. /**
  52102. * Draws the Virtual Joystick's container
  52103. */
  52104. private _drawContainer;
  52105. /**
  52106. * Draws the Virtual Joystick's puck
  52107. */
  52108. private _drawPuck;
  52109. private _drawVirtualJoystick;
  52110. /**
  52111. * Release internal HTML canvas
  52112. */
  52113. releaseCanvas(): void;
  52114. }
  52115. }
  52116. declare module BABYLON {
  52117. interface FreeCameraInputsManager {
  52118. /**
  52119. * Add virtual joystick input support to the input manager.
  52120. * @returns the current input manager
  52121. */
  52122. addVirtualJoystick(): FreeCameraInputsManager;
  52123. }
  52124. /**
  52125. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  52126. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52127. */
  52128. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  52129. /**
  52130. * Defines the camera the input is attached to.
  52131. */
  52132. camera: FreeCamera;
  52133. private _leftjoystick;
  52134. private _rightjoystick;
  52135. /**
  52136. * Gets the left stick of the virtual joystick.
  52137. * @returns The virtual Joystick
  52138. */
  52139. getLeftJoystick(): VirtualJoystick;
  52140. /**
  52141. * Gets the right stick of the virtual joystick.
  52142. * @returns The virtual Joystick
  52143. */
  52144. getRightJoystick(): VirtualJoystick;
  52145. /**
  52146. * Update the current camera state depending on the inputs that have been used this frame.
  52147. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52148. */
  52149. checkInputs(): void;
  52150. /**
  52151. * Attach the input controls to a specific dom element to get the input from.
  52152. */
  52153. attachControl(): void;
  52154. /**
  52155. * Detach the current controls from the specified dom element.
  52156. */
  52157. detachControl(): void;
  52158. /**
  52159. * Gets the class name of the current input.
  52160. * @returns the class name
  52161. */
  52162. getClassName(): string;
  52163. /**
  52164. * Get the friendly name associated with the input class.
  52165. * @returns the input friendly name
  52166. */
  52167. getSimpleName(): string;
  52168. }
  52169. }
  52170. declare module BABYLON {
  52171. /**
  52172. * This represents a FPS type of camera controlled by touch.
  52173. * This is like a universal camera minus the Gamepad controls.
  52174. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52175. */
  52176. export class TouchCamera extends FreeCamera {
  52177. /**
  52178. * Defines the touch sensibility for rotation.
  52179. * The higher the faster.
  52180. */
  52181. get touchAngularSensibility(): number;
  52182. set touchAngularSensibility(value: number);
  52183. /**
  52184. * Defines the touch sensibility for move.
  52185. * The higher the faster.
  52186. */
  52187. get touchMoveSensibility(): number;
  52188. set touchMoveSensibility(value: number);
  52189. /**
  52190. * Instantiates a new touch camera.
  52191. * This represents a FPS type of camera controlled by touch.
  52192. * This is like a universal camera minus the Gamepad controls.
  52193. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52194. * @param name Define the name of the camera in the scene
  52195. * @param position Define the start position of the camera in the scene
  52196. * @param scene Define the scene the camera belongs to
  52197. */
  52198. constructor(name: string, position: Vector3, scene: Scene);
  52199. /**
  52200. * Gets the current object class name.
  52201. * @return the class name
  52202. */
  52203. getClassName(): string;
  52204. /** @hidden */
  52205. _setupInputs(): void;
  52206. }
  52207. }
  52208. declare module BABYLON {
  52209. /**
  52210. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  52211. * being tilted forward or back and left or right.
  52212. */
  52213. export class DeviceOrientationCamera extends FreeCamera {
  52214. private _initialQuaternion;
  52215. private _quaternionCache;
  52216. private _tmpDragQuaternion;
  52217. private _disablePointerInputWhenUsingDeviceOrientation;
  52218. /**
  52219. * Creates a new device orientation camera
  52220. * @param name The name of the camera
  52221. * @param position The start position camera
  52222. * @param scene The scene the camera belongs to
  52223. */
  52224. constructor(name: string, position: Vector3, scene: Scene);
  52225. /**
  52226. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  52227. */
  52228. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  52229. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  52230. private _dragFactor;
  52231. /**
  52232. * Enabled turning on the y axis when the orientation sensor is active
  52233. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  52234. */
  52235. enableHorizontalDragging(dragFactor?: number): void;
  52236. /**
  52237. * Gets the current instance class name ("DeviceOrientationCamera").
  52238. * This helps avoiding instanceof at run time.
  52239. * @returns the class name
  52240. */
  52241. getClassName(): string;
  52242. /**
  52243. * @hidden
  52244. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  52245. */
  52246. _checkInputs(): void;
  52247. /**
  52248. * Reset the camera to its default orientation on the specified axis only.
  52249. * @param axis The axis to reset
  52250. */
  52251. resetToCurrentRotation(axis?: Axis): void;
  52252. }
  52253. }
  52254. declare module BABYLON {
  52255. /**
  52256. * Defines supported buttons for XBox360 compatible gamepads
  52257. */
  52258. export enum Xbox360Button {
  52259. /** A */
  52260. A = 0,
  52261. /** B */
  52262. B = 1,
  52263. /** X */
  52264. X = 2,
  52265. /** Y */
  52266. Y = 3,
  52267. /** Left button */
  52268. LB = 4,
  52269. /** Right button */
  52270. RB = 5,
  52271. /** Back */
  52272. Back = 8,
  52273. /** Start */
  52274. Start = 9,
  52275. /** Left stick */
  52276. LeftStick = 10,
  52277. /** Right stick */
  52278. RightStick = 11
  52279. }
  52280. /** Defines values for XBox360 DPad */
  52281. export enum Xbox360Dpad {
  52282. /** Up */
  52283. Up = 12,
  52284. /** Down */
  52285. Down = 13,
  52286. /** Left */
  52287. Left = 14,
  52288. /** Right */
  52289. Right = 15
  52290. }
  52291. /**
  52292. * Defines a XBox360 gamepad
  52293. */
  52294. export class Xbox360Pad extends Gamepad {
  52295. private _leftTrigger;
  52296. private _rightTrigger;
  52297. private _onlefttriggerchanged;
  52298. private _onrighttriggerchanged;
  52299. private _onbuttondown;
  52300. private _onbuttonup;
  52301. private _ondpaddown;
  52302. private _ondpadup;
  52303. /** Observable raised when a button is pressed */
  52304. onButtonDownObservable: Observable<Xbox360Button>;
  52305. /** Observable raised when a button is released */
  52306. onButtonUpObservable: Observable<Xbox360Button>;
  52307. /** Observable raised when a pad is pressed */
  52308. onPadDownObservable: Observable<Xbox360Dpad>;
  52309. /** Observable raised when a pad is released */
  52310. onPadUpObservable: Observable<Xbox360Dpad>;
  52311. private _buttonA;
  52312. private _buttonB;
  52313. private _buttonX;
  52314. private _buttonY;
  52315. private _buttonBack;
  52316. private _buttonStart;
  52317. private _buttonLB;
  52318. private _buttonRB;
  52319. private _buttonLeftStick;
  52320. private _buttonRightStick;
  52321. private _dPadUp;
  52322. private _dPadDown;
  52323. private _dPadLeft;
  52324. private _dPadRight;
  52325. private _isXboxOnePad;
  52326. /**
  52327. * Creates a new XBox360 gamepad object
  52328. * @param id defines the id of this gamepad
  52329. * @param index defines its index
  52330. * @param gamepad defines the internal HTML gamepad object
  52331. * @param xboxOne defines if it is a XBox One gamepad
  52332. */
  52333. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  52334. /**
  52335. * Defines the callback to call when left trigger is pressed
  52336. * @param callback defines the callback to use
  52337. */
  52338. onlefttriggerchanged(callback: (value: number) => void): void;
  52339. /**
  52340. * Defines the callback to call when right trigger is pressed
  52341. * @param callback defines the callback to use
  52342. */
  52343. onrighttriggerchanged(callback: (value: number) => void): void;
  52344. /**
  52345. * Gets the left trigger value
  52346. */
  52347. get leftTrigger(): number;
  52348. /**
  52349. * Sets the left trigger value
  52350. */
  52351. set leftTrigger(newValue: number);
  52352. /**
  52353. * Gets the right trigger value
  52354. */
  52355. get rightTrigger(): number;
  52356. /**
  52357. * Sets the right trigger value
  52358. */
  52359. set rightTrigger(newValue: number);
  52360. /**
  52361. * Defines the callback to call when a button is pressed
  52362. * @param callback defines the callback to use
  52363. */
  52364. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  52365. /**
  52366. * Defines the callback to call when a button is released
  52367. * @param callback defines the callback to use
  52368. */
  52369. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  52370. /**
  52371. * Defines the callback to call when a pad is pressed
  52372. * @param callback defines the callback to use
  52373. */
  52374. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  52375. /**
  52376. * Defines the callback to call when a pad is released
  52377. * @param callback defines the callback to use
  52378. */
  52379. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  52380. private _setButtonValue;
  52381. private _setDPadValue;
  52382. /**
  52383. * Gets the value of the `A` button
  52384. */
  52385. get buttonA(): number;
  52386. /**
  52387. * Sets the value of the `A` button
  52388. */
  52389. set buttonA(value: number);
  52390. /**
  52391. * Gets the value of the `B` button
  52392. */
  52393. get buttonB(): number;
  52394. /**
  52395. * Sets the value of the `B` button
  52396. */
  52397. set buttonB(value: number);
  52398. /**
  52399. * Gets the value of the `X` button
  52400. */
  52401. get buttonX(): number;
  52402. /**
  52403. * Sets the value of the `X` button
  52404. */
  52405. set buttonX(value: number);
  52406. /**
  52407. * Gets the value of the `Y` button
  52408. */
  52409. get buttonY(): number;
  52410. /**
  52411. * Sets the value of the `Y` button
  52412. */
  52413. set buttonY(value: number);
  52414. /**
  52415. * Gets the value of the `Start` button
  52416. */
  52417. get buttonStart(): number;
  52418. /**
  52419. * Sets the value of the `Start` button
  52420. */
  52421. set buttonStart(value: number);
  52422. /**
  52423. * Gets the value of the `Back` button
  52424. */
  52425. get buttonBack(): number;
  52426. /**
  52427. * Sets the value of the `Back` button
  52428. */
  52429. set buttonBack(value: number);
  52430. /**
  52431. * Gets the value of the `Left` button
  52432. */
  52433. get buttonLB(): number;
  52434. /**
  52435. * Sets the value of the `Left` button
  52436. */
  52437. set buttonLB(value: number);
  52438. /**
  52439. * Gets the value of the `Right` button
  52440. */
  52441. get buttonRB(): number;
  52442. /**
  52443. * Sets the value of the `Right` button
  52444. */
  52445. set buttonRB(value: number);
  52446. /**
  52447. * Gets the value of the Left joystick
  52448. */
  52449. get buttonLeftStick(): number;
  52450. /**
  52451. * Sets the value of the Left joystick
  52452. */
  52453. set buttonLeftStick(value: number);
  52454. /**
  52455. * Gets the value of the Right joystick
  52456. */
  52457. get buttonRightStick(): number;
  52458. /**
  52459. * Sets the value of the Right joystick
  52460. */
  52461. set buttonRightStick(value: number);
  52462. /**
  52463. * Gets the value of D-pad up
  52464. */
  52465. get dPadUp(): number;
  52466. /**
  52467. * Sets the value of D-pad up
  52468. */
  52469. set dPadUp(value: number);
  52470. /**
  52471. * Gets the value of D-pad down
  52472. */
  52473. get dPadDown(): number;
  52474. /**
  52475. * Sets the value of D-pad down
  52476. */
  52477. set dPadDown(value: number);
  52478. /**
  52479. * Gets the value of D-pad left
  52480. */
  52481. get dPadLeft(): number;
  52482. /**
  52483. * Sets the value of D-pad left
  52484. */
  52485. set dPadLeft(value: number);
  52486. /**
  52487. * Gets the value of D-pad right
  52488. */
  52489. get dPadRight(): number;
  52490. /**
  52491. * Sets the value of D-pad right
  52492. */
  52493. set dPadRight(value: number);
  52494. /**
  52495. * Force the gamepad to synchronize with device values
  52496. */
  52497. update(): void;
  52498. /**
  52499. * Disposes the gamepad
  52500. */
  52501. dispose(): void;
  52502. }
  52503. }
  52504. declare module BABYLON {
  52505. /**
  52506. * Defines supported buttons for DualShock compatible gamepads
  52507. */
  52508. export enum DualShockButton {
  52509. /** Cross */
  52510. Cross = 0,
  52511. /** Circle */
  52512. Circle = 1,
  52513. /** Square */
  52514. Square = 2,
  52515. /** Triangle */
  52516. Triangle = 3,
  52517. /** L1 */
  52518. L1 = 4,
  52519. /** R1 */
  52520. R1 = 5,
  52521. /** Share */
  52522. Share = 8,
  52523. /** Options */
  52524. Options = 9,
  52525. /** Left stick */
  52526. LeftStick = 10,
  52527. /** Right stick */
  52528. RightStick = 11
  52529. }
  52530. /** Defines values for DualShock DPad */
  52531. export enum DualShockDpad {
  52532. /** Up */
  52533. Up = 12,
  52534. /** Down */
  52535. Down = 13,
  52536. /** Left */
  52537. Left = 14,
  52538. /** Right */
  52539. Right = 15
  52540. }
  52541. /**
  52542. * Defines a DualShock gamepad
  52543. */
  52544. export class DualShockPad extends Gamepad {
  52545. private _leftTrigger;
  52546. private _rightTrigger;
  52547. private _onlefttriggerchanged;
  52548. private _onrighttriggerchanged;
  52549. private _onbuttondown;
  52550. private _onbuttonup;
  52551. private _ondpaddown;
  52552. private _ondpadup;
  52553. /** Observable raised when a button is pressed */
  52554. onButtonDownObservable: Observable<DualShockButton>;
  52555. /** Observable raised when a button is released */
  52556. onButtonUpObservable: Observable<DualShockButton>;
  52557. /** Observable raised when a pad is pressed */
  52558. onPadDownObservable: Observable<DualShockDpad>;
  52559. /** Observable raised when a pad is released */
  52560. onPadUpObservable: Observable<DualShockDpad>;
  52561. private _buttonCross;
  52562. private _buttonCircle;
  52563. private _buttonSquare;
  52564. private _buttonTriangle;
  52565. private _buttonShare;
  52566. private _buttonOptions;
  52567. private _buttonL1;
  52568. private _buttonR1;
  52569. private _buttonLeftStick;
  52570. private _buttonRightStick;
  52571. private _dPadUp;
  52572. private _dPadDown;
  52573. private _dPadLeft;
  52574. private _dPadRight;
  52575. /**
  52576. * Creates a new DualShock gamepad object
  52577. * @param id defines the id of this gamepad
  52578. * @param index defines its index
  52579. * @param gamepad defines the internal HTML gamepad object
  52580. */
  52581. constructor(id: string, index: number, gamepad: any);
  52582. /**
  52583. * Defines the callback to call when left trigger is pressed
  52584. * @param callback defines the callback to use
  52585. */
  52586. onlefttriggerchanged(callback: (value: number) => void): void;
  52587. /**
  52588. * Defines the callback to call when right trigger is pressed
  52589. * @param callback defines the callback to use
  52590. */
  52591. onrighttriggerchanged(callback: (value: number) => void): void;
  52592. /**
  52593. * Gets the left trigger value
  52594. */
  52595. get leftTrigger(): number;
  52596. /**
  52597. * Sets the left trigger value
  52598. */
  52599. set leftTrigger(newValue: number);
  52600. /**
  52601. * Gets the right trigger value
  52602. */
  52603. get rightTrigger(): number;
  52604. /**
  52605. * Sets the right trigger value
  52606. */
  52607. set rightTrigger(newValue: number);
  52608. /**
  52609. * Defines the callback to call when a button is pressed
  52610. * @param callback defines the callback to use
  52611. */
  52612. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52613. /**
  52614. * Defines the callback to call when a button is released
  52615. * @param callback defines the callback to use
  52616. */
  52617. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52618. /**
  52619. * Defines the callback to call when a pad is pressed
  52620. * @param callback defines the callback to use
  52621. */
  52622. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52623. /**
  52624. * Defines the callback to call when a pad is released
  52625. * @param callback defines the callback to use
  52626. */
  52627. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52628. private _setButtonValue;
  52629. private _setDPadValue;
  52630. /**
  52631. * Gets the value of the `Cross` button
  52632. */
  52633. get buttonCross(): number;
  52634. /**
  52635. * Sets the value of the `Cross` button
  52636. */
  52637. set buttonCross(value: number);
  52638. /**
  52639. * Gets the value of the `Circle` button
  52640. */
  52641. get buttonCircle(): number;
  52642. /**
  52643. * Sets the value of the `Circle` button
  52644. */
  52645. set buttonCircle(value: number);
  52646. /**
  52647. * Gets the value of the `Square` button
  52648. */
  52649. get buttonSquare(): number;
  52650. /**
  52651. * Sets the value of the `Square` button
  52652. */
  52653. set buttonSquare(value: number);
  52654. /**
  52655. * Gets the value of the `Triangle` button
  52656. */
  52657. get buttonTriangle(): number;
  52658. /**
  52659. * Sets the value of the `Triangle` button
  52660. */
  52661. set buttonTriangle(value: number);
  52662. /**
  52663. * Gets the value of the `Options` button
  52664. */
  52665. get buttonOptions(): number;
  52666. /**
  52667. * Sets the value of the `Options` button
  52668. */
  52669. set buttonOptions(value: number);
  52670. /**
  52671. * Gets the value of the `Share` button
  52672. */
  52673. get buttonShare(): number;
  52674. /**
  52675. * Sets the value of the `Share` button
  52676. */
  52677. set buttonShare(value: number);
  52678. /**
  52679. * Gets the value of the `L1` button
  52680. */
  52681. get buttonL1(): number;
  52682. /**
  52683. * Sets the value of the `L1` button
  52684. */
  52685. set buttonL1(value: number);
  52686. /**
  52687. * Gets the value of the `R1` button
  52688. */
  52689. get buttonR1(): number;
  52690. /**
  52691. * Sets the value of the `R1` button
  52692. */
  52693. set buttonR1(value: number);
  52694. /**
  52695. * Gets the value of the Left joystick
  52696. */
  52697. get buttonLeftStick(): number;
  52698. /**
  52699. * Sets the value of the Left joystick
  52700. */
  52701. set buttonLeftStick(value: number);
  52702. /**
  52703. * Gets the value of the Right joystick
  52704. */
  52705. get buttonRightStick(): number;
  52706. /**
  52707. * Sets the value of the Right joystick
  52708. */
  52709. set buttonRightStick(value: number);
  52710. /**
  52711. * Gets the value of D-pad up
  52712. */
  52713. get dPadUp(): number;
  52714. /**
  52715. * Sets the value of D-pad up
  52716. */
  52717. set dPadUp(value: number);
  52718. /**
  52719. * Gets the value of D-pad down
  52720. */
  52721. get dPadDown(): number;
  52722. /**
  52723. * Sets the value of D-pad down
  52724. */
  52725. set dPadDown(value: number);
  52726. /**
  52727. * Gets the value of D-pad left
  52728. */
  52729. get dPadLeft(): number;
  52730. /**
  52731. * Sets the value of D-pad left
  52732. */
  52733. set dPadLeft(value: number);
  52734. /**
  52735. * Gets the value of D-pad right
  52736. */
  52737. get dPadRight(): number;
  52738. /**
  52739. * Sets the value of D-pad right
  52740. */
  52741. set dPadRight(value: number);
  52742. /**
  52743. * Force the gamepad to synchronize with device values
  52744. */
  52745. update(): void;
  52746. /**
  52747. * Disposes the gamepad
  52748. */
  52749. dispose(): void;
  52750. }
  52751. }
  52752. declare module BABYLON {
  52753. /**
  52754. * Manager for handling gamepads
  52755. */
  52756. export class GamepadManager {
  52757. private _scene?;
  52758. private _babylonGamepads;
  52759. private _oneGamepadConnected;
  52760. /** @hidden */
  52761. _isMonitoring: boolean;
  52762. private _gamepadEventSupported;
  52763. private _gamepadSupport?;
  52764. /**
  52765. * observable to be triggered when the gamepad controller has been connected
  52766. */
  52767. onGamepadConnectedObservable: Observable<Gamepad>;
  52768. /**
  52769. * observable to be triggered when the gamepad controller has been disconnected
  52770. */
  52771. onGamepadDisconnectedObservable: Observable<Gamepad>;
  52772. private _onGamepadConnectedEvent;
  52773. private _onGamepadDisconnectedEvent;
  52774. /**
  52775. * Initializes the gamepad manager
  52776. * @param _scene BabylonJS scene
  52777. */
  52778. constructor(_scene?: Scene | undefined);
  52779. /**
  52780. * The gamepads in the game pad manager
  52781. */
  52782. get gamepads(): Gamepad[];
  52783. /**
  52784. * Get the gamepad controllers based on type
  52785. * @param type The type of gamepad controller
  52786. * @returns Nullable gamepad
  52787. */
  52788. getGamepadByType(type?: number): Nullable<Gamepad>;
  52789. /**
  52790. * Disposes the gamepad manager
  52791. */
  52792. dispose(): void;
  52793. private _addNewGamepad;
  52794. private _startMonitoringGamepads;
  52795. private _stopMonitoringGamepads;
  52796. /** @hidden */
  52797. _checkGamepadsStatus(): void;
  52798. private _updateGamepadObjects;
  52799. }
  52800. }
  52801. declare module BABYLON {
  52802. interface Scene {
  52803. /** @hidden */
  52804. _gamepadManager: Nullable<GamepadManager>;
  52805. /**
  52806. * Gets the gamepad manager associated with the scene
  52807. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  52808. */
  52809. gamepadManager: GamepadManager;
  52810. }
  52811. /**
  52812. * Interface representing a free camera inputs manager
  52813. */
  52814. interface FreeCameraInputsManager {
  52815. /**
  52816. * Adds gamepad input support to the FreeCameraInputsManager.
  52817. * @returns the FreeCameraInputsManager
  52818. */
  52819. addGamepad(): FreeCameraInputsManager;
  52820. }
  52821. /**
  52822. * Interface representing an arc rotate camera inputs manager
  52823. */
  52824. interface ArcRotateCameraInputsManager {
  52825. /**
  52826. * Adds gamepad input support to the ArcRotateCamera InputManager.
  52827. * @returns the camera inputs manager
  52828. */
  52829. addGamepad(): ArcRotateCameraInputsManager;
  52830. }
  52831. /**
  52832. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  52833. */
  52834. export class GamepadSystemSceneComponent implements ISceneComponent {
  52835. /**
  52836. * The component name helpfull to identify the component in the list of scene components.
  52837. */
  52838. readonly name: string;
  52839. /**
  52840. * The scene the component belongs to.
  52841. */
  52842. scene: Scene;
  52843. /**
  52844. * Creates a new instance of the component for the given scene
  52845. * @param scene Defines the scene to register the component in
  52846. */
  52847. constructor(scene: Scene);
  52848. /**
  52849. * Registers the component in a given scene
  52850. */
  52851. register(): void;
  52852. /**
  52853. * Rebuilds the elements related to this component in case of
  52854. * context lost for instance.
  52855. */
  52856. rebuild(): void;
  52857. /**
  52858. * Disposes the component and the associated ressources
  52859. */
  52860. dispose(): void;
  52861. private _beforeCameraUpdate;
  52862. }
  52863. }
  52864. declare module BABYLON {
  52865. /**
  52866. * 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,
  52867. * which still works and will still be found in many Playgrounds.
  52868. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52869. */
  52870. export class UniversalCamera extends TouchCamera {
  52871. /**
  52872. * Defines the gamepad rotation sensiblity.
  52873. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52874. */
  52875. get gamepadAngularSensibility(): number;
  52876. set gamepadAngularSensibility(value: number);
  52877. /**
  52878. * Defines the gamepad move sensiblity.
  52879. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52880. */
  52881. get gamepadMoveSensibility(): number;
  52882. set gamepadMoveSensibility(value: number);
  52883. /**
  52884. * 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,
  52885. * which still works and will still be found in many Playgrounds.
  52886. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52887. * @param name Define the name of the camera in the scene
  52888. * @param position Define the start position of the camera in the scene
  52889. * @param scene Define the scene the camera belongs to
  52890. */
  52891. constructor(name: string, position: Vector3, scene: Scene);
  52892. /**
  52893. * Gets the current object class name.
  52894. * @return the class name
  52895. */
  52896. getClassName(): string;
  52897. }
  52898. }
  52899. declare module BABYLON {
  52900. /**
  52901. * This represents a FPS type of camera. This is only here for back compat purpose.
  52902. * Please use the UniversalCamera instead as both are identical.
  52903. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52904. */
  52905. export class GamepadCamera extends UniversalCamera {
  52906. /**
  52907. * Instantiates a new Gamepad Camera
  52908. * This represents a FPS type of camera. This is only here for back compat purpose.
  52909. * Please use the UniversalCamera instead as both are identical.
  52910. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52911. * @param name Define the name of the camera in the scene
  52912. * @param position Define the start position of the camera in the scene
  52913. * @param scene Define the scene the camera belongs to
  52914. */
  52915. constructor(name: string, position: Vector3, scene: Scene);
  52916. /**
  52917. * Gets the current object class name.
  52918. * @return the class name
  52919. */
  52920. getClassName(): string;
  52921. }
  52922. }
  52923. declare module BABYLON {
  52924. /** @hidden */
  52925. export var anaglyphPixelShader: {
  52926. name: string;
  52927. shader: string;
  52928. };
  52929. }
  52930. declare module BABYLON {
  52931. /**
  52932. * Postprocess used to generate anaglyphic rendering
  52933. */
  52934. export class AnaglyphPostProcess extends PostProcess {
  52935. private _passedProcess;
  52936. /**
  52937. * Gets a string identifying the name of the class
  52938. * @returns "AnaglyphPostProcess" string
  52939. */
  52940. getClassName(): string;
  52941. /**
  52942. * Creates a new AnaglyphPostProcess
  52943. * @param name defines postprocess name
  52944. * @param options defines creation options or target ratio scale
  52945. * @param rigCameras defines cameras using this postprocess
  52946. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  52947. * @param engine defines hosting engine
  52948. * @param reusable defines if the postprocess will be reused multiple times per frame
  52949. */
  52950. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  52951. }
  52952. }
  52953. declare module BABYLON {
  52954. /**
  52955. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  52956. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52957. */
  52958. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  52959. /**
  52960. * Creates a new AnaglyphArcRotateCamera
  52961. * @param name defines camera name
  52962. * @param alpha defines alpha angle (in radians)
  52963. * @param beta defines beta angle (in radians)
  52964. * @param radius defines radius
  52965. * @param target defines camera target
  52966. * @param interaxialDistance defines distance between each color axis
  52967. * @param scene defines the hosting scene
  52968. */
  52969. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  52970. /**
  52971. * Gets camera class name
  52972. * @returns AnaglyphArcRotateCamera
  52973. */
  52974. getClassName(): string;
  52975. }
  52976. }
  52977. declare module BABYLON {
  52978. /**
  52979. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  52980. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52981. */
  52982. export class AnaglyphFreeCamera extends FreeCamera {
  52983. /**
  52984. * Creates a new AnaglyphFreeCamera
  52985. * @param name defines camera name
  52986. * @param position defines initial position
  52987. * @param interaxialDistance defines distance between each color axis
  52988. * @param scene defines the hosting scene
  52989. */
  52990. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52991. /**
  52992. * Gets camera class name
  52993. * @returns AnaglyphFreeCamera
  52994. */
  52995. getClassName(): string;
  52996. }
  52997. }
  52998. declare module BABYLON {
  52999. /**
  53000. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  53001. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53002. */
  53003. export class AnaglyphGamepadCamera extends GamepadCamera {
  53004. /**
  53005. * Creates a new AnaglyphGamepadCamera
  53006. * @param name defines camera name
  53007. * @param position defines initial position
  53008. * @param interaxialDistance defines distance between each color axis
  53009. * @param scene defines the hosting scene
  53010. */
  53011. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53012. /**
  53013. * Gets camera class name
  53014. * @returns AnaglyphGamepadCamera
  53015. */
  53016. getClassName(): string;
  53017. }
  53018. }
  53019. declare module BABYLON {
  53020. /**
  53021. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  53022. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53023. */
  53024. export class AnaglyphUniversalCamera extends UniversalCamera {
  53025. /**
  53026. * Creates a new AnaglyphUniversalCamera
  53027. * @param name defines camera name
  53028. * @param position defines initial position
  53029. * @param interaxialDistance defines distance between each color axis
  53030. * @param scene defines the hosting scene
  53031. */
  53032. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53033. /**
  53034. * Gets camera class name
  53035. * @returns AnaglyphUniversalCamera
  53036. */
  53037. getClassName(): string;
  53038. }
  53039. }
  53040. declare module BABYLON {
  53041. /** @hidden */
  53042. export var stereoscopicInterlacePixelShader: {
  53043. name: string;
  53044. shader: string;
  53045. };
  53046. }
  53047. declare module BABYLON {
  53048. /**
  53049. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  53050. */
  53051. export class StereoscopicInterlacePostProcessI extends PostProcess {
  53052. private _stepSize;
  53053. private _passedProcess;
  53054. /**
  53055. * Gets a string identifying the name of the class
  53056. * @returns "StereoscopicInterlacePostProcessI" string
  53057. */
  53058. getClassName(): string;
  53059. /**
  53060. * Initializes a StereoscopicInterlacePostProcessI
  53061. * @param name The name of the effect.
  53062. * @param rigCameras The rig cameras to be applied to the post process
  53063. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53064. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  53065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53066. * @param engine The engine which the post process will be applied. (default: current engine)
  53067. * @param reusable If the post process can be reused on the same frame. (default: false)
  53068. */
  53069. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53070. }
  53071. /**
  53072. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  53073. */
  53074. export class StereoscopicInterlacePostProcess extends PostProcess {
  53075. private _stepSize;
  53076. private _passedProcess;
  53077. /**
  53078. * Gets a string identifying the name of the class
  53079. * @returns "StereoscopicInterlacePostProcess" string
  53080. */
  53081. getClassName(): string;
  53082. /**
  53083. * Initializes a StereoscopicInterlacePostProcess
  53084. * @param name The name of the effect.
  53085. * @param rigCameras The rig cameras to be applied to the post process
  53086. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53088. * @param engine The engine which the post process will be applied. (default: current engine)
  53089. * @param reusable If the post process can be reused on the same frame. (default: false)
  53090. */
  53091. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53092. }
  53093. }
  53094. declare module BABYLON {
  53095. /**
  53096. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  53097. * @see https://doc.babylonjs.com/features/cameras
  53098. */
  53099. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  53100. /**
  53101. * Creates a new StereoscopicArcRotateCamera
  53102. * @param name defines camera name
  53103. * @param alpha defines alpha angle (in radians)
  53104. * @param beta defines beta angle (in radians)
  53105. * @param radius defines radius
  53106. * @param target defines camera target
  53107. * @param interaxialDistance defines distance between each color axis
  53108. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53109. * @param scene defines the hosting scene
  53110. */
  53111. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53112. /**
  53113. * Gets camera class name
  53114. * @returns StereoscopicArcRotateCamera
  53115. */
  53116. getClassName(): string;
  53117. }
  53118. }
  53119. declare module BABYLON {
  53120. /**
  53121. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  53122. * @see https://doc.babylonjs.com/features/cameras
  53123. */
  53124. export class StereoscopicFreeCamera extends FreeCamera {
  53125. /**
  53126. * Creates a new StereoscopicFreeCamera
  53127. * @param name defines camera name
  53128. * @param position defines initial position
  53129. * @param interaxialDistance defines distance between each color axis
  53130. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53131. * @param scene defines the hosting scene
  53132. */
  53133. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53134. /**
  53135. * Gets camera class name
  53136. * @returns StereoscopicFreeCamera
  53137. */
  53138. getClassName(): string;
  53139. }
  53140. }
  53141. declare module BABYLON {
  53142. /**
  53143. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  53144. * @see https://doc.babylonjs.com/features/cameras
  53145. */
  53146. export class StereoscopicGamepadCamera extends GamepadCamera {
  53147. /**
  53148. * Creates a new StereoscopicGamepadCamera
  53149. * @param name defines camera name
  53150. * @param position defines initial position
  53151. * @param interaxialDistance defines distance between each color axis
  53152. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53153. * @param scene defines the hosting scene
  53154. */
  53155. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53156. /**
  53157. * Gets camera class name
  53158. * @returns StereoscopicGamepadCamera
  53159. */
  53160. getClassName(): string;
  53161. }
  53162. }
  53163. declare module BABYLON {
  53164. /**
  53165. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  53166. * @see https://doc.babylonjs.com/features/cameras
  53167. */
  53168. export class StereoscopicUniversalCamera extends UniversalCamera {
  53169. /**
  53170. * Creates a new StereoscopicUniversalCamera
  53171. * @param name defines camera name
  53172. * @param position defines initial position
  53173. * @param interaxialDistance defines distance between each color axis
  53174. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53175. * @param scene defines the hosting scene
  53176. */
  53177. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53178. /**
  53179. * Gets camera class name
  53180. * @returns StereoscopicUniversalCamera
  53181. */
  53182. getClassName(): string;
  53183. }
  53184. }
  53185. declare module BABYLON {
  53186. /**
  53187. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  53188. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  53189. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  53190. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  53191. */
  53192. export class VirtualJoysticksCamera extends FreeCamera {
  53193. /**
  53194. * Instantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  53195. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  53196. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  53197. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  53198. * @param name Define the name of the camera in the scene
  53199. * @param position Define the start position of the camera in the scene
  53200. * @param scene Define the scene the camera belongs to
  53201. */
  53202. constructor(name: string, position: Vector3, scene: Scene);
  53203. /**
  53204. * Gets the current object class name.
  53205. * @return the class name
  53206. */
  53207. getClassName(): string;
  53208. }
  53209. }
  53210. declare module BABYLON {
  53211. /**
  53212. * This represents all the required metrics to create a VR camera.
  53213. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  53214. */
  53215. export class VRCameraMetrics {
  53216. /**
  53217. * Define the horizontal resolution off the screen.
  53218. */
  53219. hResolution: number;
  53220. /**
  53221. * Define the vertical resolution off the screen.
  53222. */
  53223. vResolution: number;
  53224. /**
  53225. * Define the horizontal screen size.
  53226. */
  53227. hScreenSize: number;
  53228. /**
  53229. * Define the vertical screen size.
  53230. */
  53231. vScreenSize: number;
  53232. /**
  53233. * Define the vertical screen center position.
  53234. */
  53235. vScreenCenter: number;
  53236. /**
  53237. * Define the distance of the eyes to the screen.
  53238. */
  53239. eyeToScreenDistance: number;
  53240. /**
  53241. * Define the distance between both lenses
  53242. */
  53243. lensSeparationDistance: number;
  53244. /**
  53245. * Define the distance between both viewer's eyes.
  53246. */
  53247. interpupillaryDistance: number;
  53248. /**
  53249. * Define the distortion factor of the VR postprocess.
  53250. * Please, touch with care.
  53251. */
  53252. distortionK: number[];
  53253. /**
  53254. * Define the chromatic aberration correction factors for the VR post process.
  53255. */
  53256. chromaAbCorrection: number[];
  53257. /**
  53258. * Define the scale factor of the post process.
  53259. * The smaller the better but the slower.
  53260. */
  53261. postProcessScaleFactor: number;
  53262. /**
  53263. * Define an offset for the lens center.
  53264. */
  53265. lensCenterOffset: number;
  53266. /**
  53267. * Define if the current vr camera should compensate the distortion of the lens or not.
  53268. */
  53269. compensateDistortion: boolean;
  53270. /**
  53271. * Defines if multiview should be enabled when rendering (Default: false)
  53272. */
  53273. multiviewEnabled: boolean;
  53274. /**
  53275. * Gets the rendering aspect ratio based on the provided resolutions.
  53276. */
  53277. get aspectRatio(): number;
  53278. /**
  53279. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  53280. */
  53281. get aspectRatioFov(): number;
  53282. /**
  53283. * @hidden
  53284. */
  53285. get leftHMatrix(): Matrix;
  53286. /**
  53287. * @hidden
  53288. */
  53289. get rightHMatrix(): Matrix;
  53290. /**
  53291. * @hidden
  53292. */
  53293. get leftPreViewMatrix(): Matrix;
  53294. /**
  53295. * @hidden
  53296. */
  53297. get rightPreViewMatrix(): Matrix;
  53298. /**
  53299. * Get the default VRMetrics based on the most generic setup.
  53300. * @returns the default vr metrics
  53301. */
  53302. static GetDefault(): VRCameraMetrics;
  53303. }
  53304. }
  53305. declare module BABYLON {
  53306. /** @hidden */
  53307. export var vrDistortionCorrectionPixelShader: {
  53308. name: string;
  53309. shader: string;
  53310. };
  53311. }
  53312. declare module BABYLON {
  53313. /**
  53314. * VRDistortionCorrectionPostProcess used for mobile VR
  53315. */
  53316. export class VRDistortionCorrectionPostProcess extends PostProcess {
  53317. private _isRightEye;
  53318. private _distortionFactors;
  53319. private _postProcessScaleFactor;
  53320. private _lensCenterOffset;
  53321. private _scaleIn;
  53322. private _scaleFactor;
  53323. private _lensCenter;
  53324. /**
  53325. * Gets a string identifying the name of the class
  53326. * @returns "VRDistortionCorrectionPostProcess" string
  53327. */
  53328. getClassName(): string;
  53329. /**
  53330. * Initializes the VRDistortionCorrectionPostProcess
  53331. * @param name The name of the effect.
  53332. * @param camera The camera to apply the render pass to.
  53333. * @param isRightEye If this is for the right eye distortion
  53334. * @param vrMetrics All the required metrics for the VR camera
  53335. */
  53336. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  53337. }
  53338. }
  53339. declare module BABYLON {
  53340. /**
  53341. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  53342. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53343. */
  53344. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  53345. /**
  53346. * Creates a new VRDeviceOrientationArcRotateCamera
  53347. * @param name defines camera name
  53348. * @param alpha defines the camera rotation along the longitudinal axis
  53349. * @param beta defines the camera rotation along the latitudinal axis
  53350. * @param radius defines the camera distance from its target
  53351. * @param target defines the camera target
  53352. * @param scene defines the scene the camera belongs to
  53353. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53354. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53355. */
  53356. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53357. /**
  53358. * Gets camera class name
  53359. * @returns VRDeviceOrientationArcRotateCamera
  53360. */
  53361. getClassName(): string;
  53362. }
  53363. }
  53364. declare module BABYLON {
  53365. /**
  53366. * Camera used to simulate VR rendering (based on FreeCamera)
  53367. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53368. */
  53369. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  53370. /**
  53371. * Creates a new VRDeviceOrientationFreeCamera
  53372. * @param name defines camera name
  53373. * @param position defines the start position of the camera
  53374. * @param scene defines the scene the camera belongs to
  53375. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53376. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53377. */
  53378. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53379. /**
  53380. * Gets camera class name
  53381. * @returns VRDeviceOrientationFreeCamera
  53382. */
  53383. getClassName(): string;
  53384. }
  53385. }
  53386. declare module BABYLON {
  53387. /**
  53388. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  53389. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53390. */
  53391. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  53392. /**
  53393. * Creates a new VRDeviceOrientationGamepadCamera
  53394. * @param name defines camera name
  53395. * @param position defines the start position of the camera
  53396. * @param scene defines the scene the camera belongs to
  53397. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53398. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53399. */
  53400. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53401. /**
  53402. * Gets camera class name
  53403. * @returns VRDeviceOrientationGamepadCamera
  53404. */
  53405. getClassName(): string;
  53406. }
  53407. }
  53408. declare module BABYLON {
  53409. /**
  53410. * A class extending Texture allowing drawing on a texture
  53411. * @see https://doc.babylonjs.com/how_to/dynamictexture
  53412. */
  53413. export class DynamicTexture extends Texture {
  53414. private _generateMipMaps;
  53415. private _canvas;
  53416. private _context;
  53417. /**
  53418. * Creates a DynamicTexture
  53419. * @param name defines the name of the texture
  53420. * @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
  53421. * @param scene defines the scene where you want the texture
  53422. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  53423. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53424. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  53425. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  53426. */
  53427. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  53428. /**
  53429. * Get the current class name of the texture useful for serialization or dynamic coding.
  53430. * @returns "DynamicTexture"
  53431. */
  53432. getClassName(): string;
  53433. /**
  53434. * Gets the current state of canRescale
  53435. */
  53436. get canRescale(): boolean;
  53437. private _recreate;
  53438. /**
  53439. * Scales the texture
  53440. * @param ratio the scale factor to apply to both width and height
  53441. */
  53442. scale(ratio: number): void;
  53443. /**
  53444. * Resizes the texture
  53445. * @param width the new width
  53446. * @param height the new height
  53447. */
  53448. scaleTo(width: number, height: number): void;
  53449. /**
  53450. * Gets the context of the canvas used by the texture
  53451. * @returns the canvas context of the dynamic texture
  53452. */
  53453. getContext(): CanvasRenderingContext2D;
  53454. /**
  53455. * Clears the texture
  53456. */
  53457. clear(): void;
  53458. /**
  53459. * Updates the texture
  53460. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53461. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  53462. */
  53463. update(invertY?: boolean, premulAlpha?: boolean): void;
  53464. /**
  53465. * Draws text onto the texture
  53466. * @param text defines the text to be drawn
  53467. * @param x defines the placement of the text from the left
  53468. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  53469. * @param font defines the font to be used with font-style, font-size, font-name
  53470. * @param color defines the color used for the text
  53471. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  53472. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53473. * @param update defines whether texture is immediately update (default is true)
  53474. */
  53475. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  53476. /**
  53477. * Clones the texture
  53478. * @returns the clone of the texture.
  53479. */
  53480. clone(): DynamicTexture;
  53481. /**
  53482. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  53483. * @returns a serialized dynamic texture object
  53484. */
  53485. serialize(): any;
  53486. private _IsCanvasElement;
  53487. /** @hidden */
  53488. _rebuild(): void;
  53489. }
  53490. }
  53491. declare module BABYLON {
  53492. /**
  53493. * Class containing static functions to help procedurally build meshes
  53494. */
  53495. export class GroundBuilder {
  53496. /**
  53497. * Creates a ground mesh
  53498. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53499. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53501. * @param name defines the name of the mesh
  53502. * @param options defines the options used to create the mesh
  53503. * @param scene defines the hosting scene
  53504. * @returns the ground mesh
  53505. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53506. */
  53507. static CreateGround(name: string, options: {
  53508. width?: number;
  53509. height?: number;
  53510. subdivisions?: number;
  53511. subdivisionsX?: number;
  53512. subdivisionsY?: number;
  53513. updatable?: boolean;
  53514. }, scene: any): Mesh;
  53515. /**
  53516. * Creates a tiled ground mesh
  53517. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53518. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53519. * * 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
  53520. * * 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
  53521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53522. * @param name defines the name of the mesh
  53523. * @param options defines the options used to create the mesh
  53524. * @param scene defines the hosting scene
  53525. * @returns the tiled ground mesh
  53526. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53527. */
  53528. static CreateTiledGround(name: string, options: {
  53529. xmin: number;
  53530. zmin: number;
  53531. xmax: number;
  53532. zmax: number;
  53533. subdivisions?: {
  53534. w: number;
  53535. h: number;
  53536. };
  53537. precision?: {
  53538. w: number;
  53539. h: number;
  53540. };
  53541. updatable?: boolean;
  53542. }, scene?: Nullable<Scene>): Mesh;
  53543. /**
  53544. * Creates a ground mesh from a height map
  53545. * * The parameter `url` sets the URL of the height map image resource.
  53546. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53547. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53548. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53549. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53550. * * 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.
  53551. * * 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).
  53552. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53554. * @param name defines the name of the mesh
  53555. * @param url defines the url to the height map
  53556. * @param options defines the options used to create the mesh
  53557. * @param scene defines the hosting scene
  53558. * @returns the ground mesh
  53559. * @see https://doc.babylonjs.com/babylon101/height_map
  53560. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53561. */
  53562. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53563. width?: number;
  53564. height?: number;
  53565. subdivisions?: number;
  53566. minHeight?: number;
  53567. maxHeight?: number;
  53568. colorFilter?: Color3;
  53569. alphaFilter?: number;
  53570. updatable?: boolean;
  53571. onReady?: (mesh: GroundMesh) => void;
  53572. }, scene?: Nullable<Scene>): GroundMesh;
  53573. }
  53574. }
  53575. declare module BABYLON {
  53576. /**
  53577. * Class containing static functions to help procedurally build meshes
  53578. */
  53579. export class TorusBuilder {
  53580. /**
  53581. * Creates a torus mesh
  53582. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53583. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53584. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  53585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53586. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53588. * @param name defines the name of the mesh
  53589. * @param options defines the options used to create the mesh
  53590. * @param scene defines the hosting scene
  53591. * @returns the torus mesh
  53592. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53593. */
  53594. static CreateTorus(name: string, options: {
  53595. diameter?: number;
  53596. thickness?: number;
  53597. tessellation?: number;
  53598. updatable?: boolean;
  53599. sideOrientation?: number;
  53600. frontUVs?: Vector4;
  53601. backUVs?: Vector4;
  53602. }, scene: any): Mesh;
  53603. }
  53604. }
  53605. declare module BABYLON {
  53606. /**
  53607. * Class containing static functions to help procedurally build meshes
  53608. */
  53609. export class CylinderBuilder {
  53610. /**
  53611. * Creates a cylinder or a cone mesh
  53612. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53613. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53614. * * 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.
  53615. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53616. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53617. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53618. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53619. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  53620. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53621. * * 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).
  53622. * * 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
  53623. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53624. * * 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
  53625. * * 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.
  53626. * * If `enclose` is false, a ring surface is one element.
  53627. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53628. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  53629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53630. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53632. * @param name defines the name of the mesh
  53633. * @param options defines the options used to create the mesh
  53634. * @param scene defines the hosting scene
  53635. * @returns the cylinder mesh
  53636. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53637. */
  53638. static CreateCylinder(name: string, options: {
  53639. height?: number;
  53640. diameterTop?: number;
  53641. diameterBottom?: number;
  53642. diameter?: number;
  53643. tessellation?: number;
  53644. subdivisions?: number;
  53645. arc?: number;
  53646. faceColors?: Color4[];
  53647. faceUV?: Vector4[];
  53648. updatable?: boolean;
  53649. hasRings?: boolean;
  53650. enclose?: boolean;
  53651. cap?: number;
  53652. sideOrientation?: number;
  53653. frontUVs?: Vector4;
  53654. backUVs?: Vector4;
  53655. }, scene: any): Mesh;
  53656. }
  53657. }
  53658. declare module BABYLON {
  53659. /**
  53660. * States of the webXR experience
  53661. */
  53662. export enum WebXRState {
  53663. /**
  53664. * Transitioning to being in XR mode
  53665. */
  53666. ENTERING_XR = 0,
  53667. /**
  53668. * Transitioning to non XR mode
  53669. */
  53670. EXITING_XR = 1,
  53671. /**
  53672. * In XR mode and presenting
  53673. */
  53674. IN_XR = 2,
  53675. /**
  53676. * Not entered XR mode
  53677. */
  53678. NOT_IN_XR = 3
  53679. }
  53680. /**
  53681. * The state of the XR camera's tracking
  53682. */
  53683. export enum WebXRTrackingState {
  53684. /**
  53685. * No transformation received, device is not being tracked
  53686. */
  53687. NOT_TRACKING = 0,
  53688. /**
  53689. * Tracking lost - using emulated position
  53690. */
  53691. TRACKING_LOST = 1,
  53692. /**
  53693. * Transformation tracking works normally
  53694. */
  53695. TRACKING = 2
  53696. }
  53697. /**
  53698. * Abstraction of the XR render target
  53699. */
  53700. export interface WebXRRenderTarget extends IDisposable {
  53701. /**
  53702. * xrpresent context of the canvas which can be used to display/mirror xr content
  53703. */
  53704. canvasContext: WebGLRenderingContext;
  53705. /**
  53706. * xr layer for the canvas
  53707. */
  53708. xrLayer: Nullable<XRWebGLLayer>;
  53709. /**
  53710. * Initializes the xr layer for the session
  53711. * @param xrSession xr session
  53712. * @returns a promise that will resolve once the XR Layer has been created
  53713. */
  53714. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53715. }
  53716. }
  53717. declare module BABYLON {
  53718. /**
  53719. * Configuration object for WebXR output canvas
  53720. */
  53721. export class WebXRManagedOutputCanvasOptions {
  53722. /**
  53723. * An optional canvas in case you wish to create it yourself and provide it here.
  53724. * If not provided, a new canvas will be created
  53725. */
  53726. canvasElement?: HTMLCanvasElement;
  53727. /**
  53728. * Options for this XR Layer output
  53729. */
  53730. canvasOptions?: XRWebGLLayerInit;
  53731. /**
  53732. * CSS styling for a newly created canvas (if not provided)
  53733. */
  53734. newCanvasCssStyle?: string;
  53735. /**
  53736. * Get the default values of the configuration object
  53737. * @param engine defines the engine to use (can be null)
  53738. * @returns default values of this configuration object
  53739. */
  53740. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53741. }
  53742. /**
  53743. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53744. */
  53745. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53746. private _options;
  53747. private _canvas;
  53748. private _engine;
  53749. private _originalCanvasSize;
  53750. /**
  53751. * Rendering context of the canvas which can be used to display/mirror xr content
  53752. */
  53753. canvasContext: WebGLRenderingContext;
  53754. /**
  53755. * xr layer for the canvas
  53756. */
  53757. xrLayer: Nullable<XRWebGLLayer>;
  53758. /**
  53759. * Observers registered here will be triggered when the xr layer was initialized
  53760. */
  53761. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  53762. /**
  53763. * Initializes the canvas to be added/removed upon entering/exiting xr
  53764. * @param _xrSessionManager The XR Session manager
  53765. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  53766. */
  53767. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  53768. /**
  53769. * Disposes of the object
  53770. */
  53771. dispose(): void;
  53772. /**
  53773. * Initializes the xr layer for the session
  53774. * @param xrSession xr session
  53775. * @returns a promise that will resolve once the XR Layer has been created
  53776. */
  53777. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53778. private _addCanvas;
  53779. private _removeCanvas;
  53780. private _setCanvasSize;
  53781. private _setManagedOutputCanvas;
  53782. }
  53783. }
  53784. declare module BABYLON {
  53785. /**
  53786. * Manages an XRSession to work with Babylon's engine
  53787. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  53788. */
  53789. export class WebXRSessionManager implements IDisposable {
  53790. /** The scene which the session should be created for */
  53791. scene: Scene;
  53792. private _referenceSpace;
  53793. private _rttProvider;
  53794. private _sessionEnded;
  53795. private _xrNavigator;
  53796. private baseLayer;
  53797. /**
  53798. * The base reference space from which the session started. good if you want to reset your
  53799. * reference space
  53800. */
  53801. baseReferenceSpace: XRReferenceSpace;
  53802. /**
  53803. * Current XR frame
  53804. */
  53805. currentFrame: Nullable<XRFrame>;
  53806. /** WebXR timestamp updated every frame */
  53807. currentTimestamp: number;
  53808. /**
  53809. * Used just in case of a failure to initialize an immersive session.
  53810. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  53811. */
  53812. defaultHeightCompensation: number;
  53813. /**
  53814. * Fires every time a new xrFrame arrives which can be used to update the camera
  53815. */
  53816. onXRFrameObservable: Observable<XRFrame>;
  53817. /**
  53818. * Fires when the reference space changed
  53819. */
  53820. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  53821. /**
  53822. * Fires when the xr session is ended either by the device or manually done
  53823. */
  53824. onXRSessionEnded: Observable<any>;
  53825. /**
  53826. * Fires when the xr session is ended either by the device or manually done
  53827. */
  53828. onXRSessionInit: Observable<XRSession>;
  53829. /**
  53830. * Underlying xr session
  53831. */
  53832. session: XRSession;
  53833. /**
  53834. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  53835. * or get the offset the player is currently at.
  53836. */
  53837. viewerReferenceSpace: XRReferenceSpace;
  53838. /**
  53839. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  53840. * @param scene The scene which the session should be created for
  53841. */
  53842. constructor(
  53843. /** The scene which the session should be created for */
  53844. scene: Scene);
  53845. /**
  53846. * The current reference space used in this session. This reference space can constantly change!
  53847. * It is mainly used to offset the camera's position.
  53848. */
  53849. get referenceSpace(): XRReferenceSpace;
  53850. /**
  53851. * Set a new reference space and triggers the observable
  53852. */
  53853. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  53854. /**
  53855. * Disposes of the session manager
  53856. */
  53857. dispose(): void;
  53858. /**
  53859. * Stops the xrSession and restores the render loop
  53860. * @returns Promise which resolves after it exits XR
  53861. */
  53862. exitXRAsync(): Promise<void>;
  53863. /**
  53864. * Gets the correct render target texture to be rendered this frame for this eye
  53865. * @param eye the eye for which to get the render target
  53866. * @returns the render target for the specified eye
  53867. */
  53868. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  53869. /**
  53870. * Creates a WebXRRenderTarget object for the XR session
  53871. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  53872. * @param options optional options to provide when creating a new render target
  53873. * @returns a WebXR render target to which the session can render
  53874. */
  53875. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  53876. /**
  53877. * Initializes the manager
  53878. * After initialization enterXR can be called to start an XR session
  53879. * @returns Promise which resolves after it is initialized
  53880. */
  53881. initializeAsync(): Promise<void>;
  53882. /**
  53883. * Initializes an xr session
  53884. * @param xrSessionMode mode to initialize
  53885. * @param xrSessionInit defines optional and required values to pass to the session builder
  53886. * @returns a promise which will resolve once the session has been initialized
  53887. */
  53888. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  53889. /**
  53890. * Checks if a session would be supported for the creation options specified
  53891. * @param sessionMode session mode to check if supported eg. immersive-vr
  53892. * @returns A Promise that resolves to true if supported and false if not
  53893. */
  53894. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53895. /**
  53896. * Resets the reference space to the one started the session
  53897. */
  53898. resetReferenceSpace(): void;
  53899. /**
  53900. * Starts rendering to the xr layer
  53901. */
  53902. runXRRenderLoop(): void;
  53903. /**
  53904. * Sets the reference space on the xr session
  53905. * @param referenceSpaceType space to set
  53906. * @returns a promise that will resolve once the reference space has been set
  53907. */
  53908. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  53909. /**
  53910. * Updates the render state of the session
  53911. * @param state state to set
  53912. * @returns a promise that resolves once the render state has been updated
  53913. */
  53914. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  53915. /**
  53916. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  53917. * @param sessionMode defines the session to test
  53918. * @returns a promise with boolean as final value
  53919. */
  53920. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53921. /**
  53922. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  53923. */
  53924. get isNative(): boolean;
  53925. private _createRenderTargetTexture;
  53926. }
  53927. }
  53928. declare module BABYLON {
  53929. /**
  53930. * WebXR Camera which holds the views for the xrSession
  53931. * @see https://doc.babylonjs.com/how_to/webxr_camera
  53932. */
  53933. export class WebXRCamera extends FreeCamera {
  53934. private _xrSessionManager;
  53935. private _firstFrame;
  53936. private _referenceQuaternion;
  53937. private _referencedPosition;
  53938. private _xrInvPositionCache;
  53939. private _xrInvQuaternionCache;
  53940. private _trackingState;
  53941. /**
  53942. * Observable raised before camera teleportation
  53943. */
  53944. onBeforeCameraTeleport: Observable<Vector3>;
  53945. /**
  53946. * Observable raised after camera teleportation
  53947. */
  53948. onAfterCameraTeleport: Observable<Vector3>;
  53949. /**
  53950. * Notifies when the camera's tracking state has changed.
  53951. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  53952. */
  53953. onTrackingStateChanged: Observable<WebXRTrackingState>;
  53954. /**
  53955. * Should position compensation execute on first frame.
  53956. * This is used when copying the position from a native (non XR) camera
  53957. */
  53958. compensateOnFirstFrame: boolean;
  53959. /**
  53960. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  53961. * @param name the name of the camera
  53962. * @param scene the scene to add the camera to
  53963. * @param _xrSessionManager a constructed xr session manager
  53964. */
  53965. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  53966. /**
  53967. * Get the current XR tracking state of the camera
  53968. */
  53969. get trackingState(): WebXRTrackingState;
  53970. private _setTrackingState;
  53971. /**
  53972. * Return the user's height, unrelated to the current ground.
  53973. * This will be the y position of this camera, when ground level is 0.
  53974. */
  53975. get realWorldHeight(): number;
  53976. /** @hidden */
  53977. _updateForDualEyeDebugging(): void;
  53978. /**
  53979. * Sets this camera's transformation based on a non-vr camera
  53980. * @param otherCamera the non-vr camera to copy the transformation from
  53981. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  53982. */
  53983. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  53984. /**
  53985. * Gets the current instance class name ("WebXRCamera").
  53986. * @returns the class name
  53987. */
  53988. getClassName(): string;
  53989. private _rotate180;
  53990. private _updateFromXRSession;
  53991. private _updateNumberOfRigCameras;
  53992. private _updateReferenceSpace;
  53993. private _updateReferenceSpaceOffset;
  53994. }
  53995. }
  53996. declare module BABYLON {
  53997. /**
  53998. * Defining the interface required for a (webxr) feature
  53999. */
  54000. export interface IWebXRFeature extends IDisposable {
  54001. /**
  54002. * Is this feature attached
  54003. */
  54004. attached: boolean;
  54005. /**
  54006. * Should auto-attach be disabled?
  54007. */
  54008. disableAutoAttach: boolean;
  54009. /**
  54010. * Attach the feature to the session
  54011. * Will usually be called by the features manager
  54012. *
  54013. * @param force should attachment be forced (even when already attached)
  54014. * @returns true if successful.
  54015. */
  54016. attach(force?: boolean): boolean;
  54017. /**
  54018. * Detach the feature from the session
  54019. * Will usually be called by the features manager
  54020. *
  54021. * @returns true if successful.
  54022. */
  54023. detach(): boolean;
  54024. /**
  54025. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54026. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54027. *
  54028. * @returns whether or not the feature is compatible in this environment
  54029. */
  54030. isCompatible(): boolean;
  54031. /**
  54032. * Was this feature disposed;
  54033. */
  54034. isDisposed: boolean;
  54035. /**
  54036. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  54037. */
  54038. xrNativeFeatureName?: string;
  54039. /**
  54040. * A list of (Babylon WebXR) features this feature depends on
  54041. */
  54042. dependsOn?: string[];
  54043. /**
  54044. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  54045. */
  54046. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  54047. }
  54048. /**
  54049. * A list of the currently available features without referencing them
  54050. */
  54051. export class WebXRFeatureName {
  54052. /**
  54053. * The name of the anchor system feature
  54054. */
  54055. static readonly ANCHOR_SYSTEM: string;
  54056. /**
  54057. * The name of the background remover feature
  54058. */
  54059. static readonly BACKGROUND_REMOVER: string;
  54060. /**
  54061. * The name of the hit test feature
  54062. */
  54063. static readonly HIT_TEST: string;
  54064. /**
  54065. * The name of the mesh detection feature
  54066. */
  54067. static readonly MESH_DETECTION: string;
  54068. /**
  54069. * physics impostors for xr controllers feature
  54070. */
  54071. static readonly PHYSICS_CONTROLLERS: string;
  54072. /**
  54073. * The name of the plane detection feature
  54074. */
  54075. static readonly PLANE_DETECTION: string;
  54076. /**
  54077. * The name of the pointer selection feature
  54078. */
  54079. static readonly POINTER_SELECTION: string;
  54080. /**
  54081. * The name of the teleportation feature
  54082. */
  54083. static readonly TELEPORTATION: string;
  54084. /**
  54085. * The name of the feature points feature.
  54086. */
  54087. static readonly FEATURE_POINTS: string;
  54088. /**
  54089. * The name of the hand tracking feature.
  54090. */
  54091. static readonly HAND_TRACKING: string;
  54092. /**
  54093. * The name of the image tracking feature
  54094. */
  54095. static readonly IMAGE_TRACKING: string;
  54096. }
  54097. /**
  54098. * Defining the constructor of a feature. Used to register the modules.
  54099. */
  54100. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  54101. /**
  54102. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  54103. * It is mainly used in AR sessions.
  54104. *
  54105. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  54106. */
  54107. export class WebXRFeaturesManager implements IDisposable {
  54108. private _xrSessionManager;
  54109. private static readonly _AvailableFeatures;
  54110. private _features;
  54111. /**
  54112. * constructs a new features manages.
  54113. *
  54114. * @param _xrSessionManager an instance of WebXRSessionManager
  54115. */
  54116. constructor(_xrSessionManager: WebXRSessionManager);
  54117. /**
  54118. * Used to register a module. After calling this function a developer can use this feature in the scene.
  54119. * Mainly used internally.
  54120. *
  54121. * @param featureName the name of the feature to register
  54122. * @param constructorFunction the function used to construct the module
  54123. * @param version the (babylon) version of the module
  54124. * @param stable is that a stable version of this module
  54125. */
  54126. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  54127. /**
  54128. * Returns a constructor of a specific feature.
  54129. *
  54130. * @param featureName the name of the feature to construct
  54131. * @param version the version of the feature to load
  54132. * @param xrSessionManager the xrSessionManager. Used to construct the module
  54133. * @param options optional options provided to the module.
  54134. * @returns a function that, when called, will return a new instance of this feature
  54135. */
  54136. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  54137. /**
  54138. * Can be used to return the list of features currently registered
  54139. *
  54140. * @returns an Array of available features
  54141. */
  54142. static GetAvailableFeatures(): string[];
  54143. /**
  54144. * Gets the versions available for a specific feature
  54145. * @param featureName the name of the feature
  54146. * @returns an array with the available versions
  54147. */
  54148. static GetAvailableVersions(featureName: string): string[];
  54149. /**
  54150. * Return the latest unstable version of this feature
  54151. * @param featureName the name of the feature to search
  54152. * @returns the version number. if not found will return -1
  54153. */
  54154. static GetLatestVersionOfFeature(featureName: string): number;
  54155. /**
  54156. * Return the latest stable version of this feature
  54157. * @param featureName the name of the feature to search
  54158. * @returns the version number. if not found will return -1
  54159. */
  54160. static GetStableVersionOfFeature(featureName: string): number;
  54161. /**
  54162. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  54163. * Can be used during a session to start a feature
  54164. * @param featureName the name of feature to attach
  54165. */
  54166. attachFeature(featureName: string): void;
  54167. /**
  54168. * Can be used inside a session or when the session ends to detach a specific feature
  54169. * @param featureName the name of the feature to detach
  54170. */
  54171. detachFeature(featureName: string): void;
  54172. /**
  54173. * Used to disable an already-enabled feature
  54174. * The feature will be disposed and will be recreated once enabled.
  54175. * @param featureName the feature to disable
  54176. * @returns true if disable was successful
  54177. */
  54178. disableFeature(featureName: string | {
  54179. Name: string;
  54180. }): boolean;
  54181. /**
  54182. * dispose this features manager
  54183. */
  54184. dispose(): void;
  54185. /**
  54186. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  54187. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  54188. *
  54189. * @param featureName the name of the feature to load or the class of the feature
  54190. * @param version optional version to load. if not provided the latest version will be enabled
  54191. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  54192. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  54193. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  54194. * @returns a new constructed feature or throws an error if feature not found.
  54195. */
  54196. enableFeature(featureName: string | {
  54197. Name: string;
  54198. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  54199. /**
  54200. * get the implementation of an enabled feature.
  54201. * @param featureName the name of the feature to load
  54202. * @returns the feature class, if found
  54203. */
  54204. getEnabledFeature(featureName: string): IWebXRFeature;
  54205. /**
  54206. * Get the list of enabled features
  54207. * @returns an array of enabled features
  54208. */
  54209. getEnabledFeatures(): string[];
  54210. /**
  54211. * This function will extend the session creation configuration object with enabled features.
  54212. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  54213. * according to the defined "required" variable, provided during enableFeature call
  54214. * @param xrSessionInit the xr Session init object to extend
  54215. *
  54216. * @returns an extended XRSessionInit object
  54217. */
  54218. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  54219. }
  54220. }
  54221. declare module BABYLON {
  54222. /**
  54223. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  54224. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  54225. */
  54226. export class WebXRExperienceHelper implements IDisposable {
  54227. private scene;
  54228. private _nonVRCamera;
  54229. private _originalSceneAutoClear;
  54230. private _supported;
  54231. /**
  54232. * Camera used to render xr content
  54233. */
  54234. camera: WebXRCamera;
  54235. /** A features manager for this xr session */
  54236. featuresManager: WebXRFeaturesManager;
  54237. /**
  54238. * Observers registered here will be triggered after the camera's initial transformation is set
  54239. * This can be used to set a different ground level or an extra rotation.
  54240. *
  54241. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  54242. * to the position set after this observable is done executing.
  54243. */
  54244. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  54245. /**
  54246. * Fires when the state of the experience helper has changed
  54247. */
  54248. onStateChangedObservable: Observable<WebXRState>;
  54249. /** Session manager used to keep track of xr session */
  54250. sessionManager: WebXRSessionManager;
  54251. /**
  54252. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  54253. */
  54254. state: WebXRState;
  54255. /**
  54256. * Creates a WebXRExperienceHelper
  54257. * @param scene The scene the helper should be created in
  54258. */
  54259. private constructor();
  54260. /**
  54261. * Creates the experience helper
  54262. * @param scene the scene to attach the experience helper to
  54263. * @returns a promise for the experience helper
  54264. */
  54265. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  54266. /**
  54267. * Disposes of the experience helper
  54268. */
  54269. dispose(): void;
  54270. /**
  54271. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  54272. * @param sessionMode options for the XR session
  54273. * @param referenceSpaceType frame of reference of the XR session
  54274. * @param renderTarget the output canvas that will be used to enter XR mode
  54275. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  54276. * @returns promise that resolves after xr mode has entered
  54277. */
  54278. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  54279. /**
  54280. * Exits XR mode and returns the scene to its original state
  54281. * @returns promise that resolves after xr mode has exited
  54282. */
  54283. exitXRAsync(): Promise<void>;
  54284. private _nonXRToXRCamera;
  54285. private _setState;
  54286. }
  54287. }
  54288. declare module BABYLON {
  54289. /**
  54290. * X-Y values for axes in WebXR
  54291. */
  54292. export interface IWebXRMotionControllerAxesValue {
  54293. /**
  54294. * The value of the x axis
  54295. */
  54296. x: number;
  54297. /**
  54298. * The value of the y-axis
  54299. */
  54300. y: number;
  54301. }
  54302. /**
  54303. * changed / previous values for the values of this component
  54304. */
  54305. export interface IWebXRMotionControllerComponentChangesValues<T> {
  54306. /**
  54307. * current (this frame) value
  54308. */
  54309. current: T;
  54310. /**
  54311. * previous (last change) value
  54312. */
  54313. previous: T;
  54314. }
  54315. /**
  54316. * Represents changes in the component between current frame and last values recorded
  54317. */
  54318. export interface IWebXRMotionControllerComponentChanges {
  54319. /**
  54320. * will be populated with previous and current values if axes changed
  54321. */
  54322. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  54323. /**
  54324. * will be populated with previous and current values if pressed changed
  54325. */
  54326. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54327. /**
  54328. * will be populated with previous and current values if touched changed
  54329. */
  54330. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54331. /**
  54332. * will be populated with previous and current values if value changed
  54333. */
  54334. value?: IWebXRMotionControllerComponentChangesValues<number>;
  54335. }
  54336. /**
  54337. * This class represents a single component (for example button or thumbstick) of a motion controller
  54338. */
  54339. export class WebXRControllerComponent implements IDisposable {
  54340. /**
  54341. * the id of this component
  54342. */
  54343. id: string;
  54344. /**
  54345. * the type of the component
  54346. */
  54347. type: MotionControllerComponentType;
  54348. private _buttonIndex;
  54349. private _axesIndices;
  54350. private _axes;
  54351. private _changes;
  54352. private _currentValue;
  54353. private _hasChanges;
  54354. private _pressed;
  54355. private _touched;
  54356. /**
  54357. * button component type
  54358. */
  54359. static BUTTON_TYPE: MotionControllerComponentType;
  54360. /**
  54361. * squeeze component type
  54362. */
  54363. static SQUEEZE_TYPE: MotionControllerComponentType;
  54364. /**
  54365. * Thumbstick component type
  54366. */
  54367. static THUMBSTICK_TYPE: MotionControllerComponentType;
  54368. /**
  54369. * Touchpad component type
  54370. */
  54371. static TOUCHPAD_TYPE: MotionControllerComponentType;
  54372. /**
  54373. * trigger component type
  54374. */
  54375. static TRIGGER_TYPE: MotionControllerComponentType;
  54376. /**
  54377. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  54378. * the axes data changes
  54379. */
  54380. onAxisValueChangedObservable: Observable<{
  54381. x: number;
  54382. y: number;
  54383. }>;
  54384. /**
  54385. * Observers registered here will be triggered when the state of a button changes
  54386. * State change is either pressed / touched / value
  54387. */
  54388. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  54389. /**
  54390. * Creates a new component for a motion controller.
  54391. * It is created by the motion controller itself
  54392. *
  54393. * @param id the id of this component
  54394. * @param type the type of the component
  54395. * @param _buttonIndex index in the buttons array of the gamepad
  54396. * @param _axesIndices indices of the values in the axes array of the gamepad
  54397. */
  54398. constructor(
  54399. /**
  54400. * the id of this component
  54401. */
  54402. id: string,
  54403. /**
  54404. * the type of the component
  54405. */
  54406. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  54407. /**
  54408. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  54409. */
  54410. get axes(): IWebXRMotionControllerAxesValue;
  54411. /**
  54412. * Get the changes. Elements will be populated only if they changed with their previous and current value
  54413. */
  54414. get changes(): IWebXRMotionControllerComponentChanges;
  54415. /**
  54416. * Return whether or not the component changed the last frame
  54417. */
  54418. get hasChanges(): boolean;
  54419. /**
  54420. * is the button currently pressed
  54421. */
  54422. get pressed(): boolean;
  54423. /**
  54424. * is the button currently touched
  54425. */
  54426. get touched(): boolean;
  54427. /**
  54428. * Get the current value of this component
  54429. */
  54430. get value(): number;
  54431. /**
  54432. * Dispose this component
  54433. */
  54434. dispose(): void;
  54435. /**
  54436. * Are there axes correlating to this component
  54437. * @return true is axes data is available
  54438. */
  54439. isAxes(): boolean;
  54440. /**
  54441. * Is this component a button (hence - pressable)
  54442. * @returns true if can be pressed
  54443. */
  54444. isButton(): boolean;
  54445. /**
  54446. * update this component using the gamepad object it is in. Called on every frame
  54447. * @param nativeController the native gamepad controller object
  54448. */
  54449. update(nativeController: IMinimalMotionControllerObject): void;
  54450. }
  54451. }
  54452. declare module BABYLON {
  54453. /**
  54454. * Type used for the success callback of ImportMesh
  54455. */
  54456. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  54457. /**
  54458. * Interface used for the result of ImportMeshAsync
  54459. */
  54460. export interface ISceneLoaderAsyncResult {
  54461. /**
  54462. * The array of loaded meshes
  54463. */
  54464. readonly meshes: AbstractMesh[];
  54465. /**
  54466. * The array of loaded particle systems
  54467. */
  54468. readonly particleSystems: IParticleSystem[];
  54469. /**
  54470. * The array of loaded skeletons
  54471. */
  54472. readonly skeletons: Skeleton[];
  54473. /**
  54474. * The array of loaded animation groups
  54475. */
  54476. readonly animationGroups: AnimationGroup[];
  54477. /**
  54478. * The array of loaded transform nodes
  54479. */
  54480. readonly transformNodes: TransformNode[];
  54481. /**
  54482. * The array of loaded geometries
  54483. */
  54484. readonly geometries: Geometry[];
  54485. /**
  54486. * The array of loaded lights
  54487. */
  54488. readonly lights: Light[];
  54489. }
  54490. /**
  54491. * Interface used to represent data loading progression
  54492. */
  54493. export interface ISceneLoaderProgressEvent {
  54494. /**
  54495. * Defines if data length to load can be evaluated
  54496. */
  54497. readonly lengthComputable: boolean;
  54498. /**
  54499. * Defines the loaded data length
  54500. */
  54501. readonly loaded: number;
  54502. /**
  54503. * Defines the data length to load
  54504. */
  54505. readonly total: number;
  54506. }
  54507. /**
  54508. * Interface used by SceneLoader plugins to define supported file extensions
  54509. */
  54510. export interface ISceneLoaderPluginExtensions {
  54511. /**
  54512. * Defines the list of supported extensions
  54513. */
  54514. [extension: string]: {
  54515. isBinary: boolean;
  54516. };
  54517. }
  54518. /**
  54519. * Interface used by SceneLoader plugin factory
  54520. */
  54521. export interface ISceneLoaderPluginFactory {
  54522. /**
  54523. * Defines the name of the factory
  54524. */
  54525. name: string;
  54526. /**
  54527. * Function called to create a new plugin
  54528. * @return the new plugin
  54529. */
  54530. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54531. /**
  54532. * The callback that returns true if the data can be directly loaded.
  54533. * @param data string containing the file data
  54534. * @returns if the data can be loaded directly
  54535. */
  54536. canDirectLoad?(data: string): boolean;
  54537. }
  54538. /**
  54539. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54540. */
  54541. export interface ISceneLoaderPluginBase {
  54542. /**
  54543. * The friendly name of this plugin.
  54544. */
  54545. name: string;
  54546. /**
  54547. * The file extensions supported by this plugin.
  54548. */
  54549. extensions: string | ISceneLoaderPluginExtensions;
  54550. /**
  54551. * The callback called when loading from a url.
  54552. * @param scene scene loading this url
  54553. * @param url url to load
  54554. * @param onSuccess callback called when the file successfully loads
  54555. * @param onProgress callback called while file is loading (if the server supports this mode)
  54556. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54557. * @param onError callback called when the file fails to load
  54558. * @returns a file request object
  54559. */
  54560. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54561. /**
  54562. * The callback called when loading from a file object.
  54563. * @param scene scene loading this file
  54564. * @param file defines the file to load
  54565. * @param onSuccess defines the callback to call when data is loaded
  54566. * @param onProgress defines the callback to call during loading process
  54567. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54568. * @param onError defines the callback to call when an error occurs
  54569. * @returns a file request object
  54570. */
  54571. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54572. /**
  54573. * The callback that returns true if the data can be directly loaded.
  54574. * @param data string containing the file data
  54575. * @returns if the data can be loaded directly
  54576. */
  54577. canDirectLoad?(data: string): boolean;
  54578. /**
  54579. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54580. * @param scene scene loading this data
  54581. * @param data string containing the data
  54582. * @returns data to pass to the plugin
  54583. */
  54584. directLoad?(scene: Scene, data: string): any;
  54585. /**
  54586. * The callback that allows custom handling of the root url based on the response url.
  54587. * @param rootUrl the original root url
  54588. * @param responseURL the response url if available
  54589. * @returns the new root url
  54590. */
  54591. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54592. }
  54593. /**
  54594. * Interface used to define a SceneLoader plugin
  54595. */
  54596. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54597. /**
  54598. * Import meshes into a scene.
  54599. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54600. * @param scene The scene to import into
  54601. * @param data The data to import
  54602. * @param rootUrl The root url for scene and resources
  54603. * @param meshes The meshes array to import into
  54604. * @param particleSystems The particle systems array to import into
  54605. * @param skeletons The skeletons array to import into
  54606. * @param onError The callback when import fails
  54607. * @returns True if successful or false otherwise
  54608. */
  54609. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54610. /**
  54611. * Load into a scene.
  54612. * @param scene The scene to load into
  54613. * @param data The data to import
  54614. * @param rootUrl The root url for scene and resources
  54615. * @param onError The callback when import fails
  54616. * @returns True if successful or false otherwise
  54617. */
  54618. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54619. /**
  54620. * Load into an asset container.
  54621. * @param scene The scene to load into
  54622. * @param data The data to import
  54623. * @param rootUrl The root url for scene and resources
  54624. * @param onError The callback when import fails
  54625. * @returns The loaded asset container
  54626. */
  54627. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54628. }
  54629. /**
  54630. * Interface used to define an async SceneLoader plugin
  54631. */
  54632. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54633. /**
  54634. * Import meshes into a scene.
  54635. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54636. * @param scene The scene to import into
  54637. * @param data The data to import
  54638. * @param rootUrl The root url for scene and resources
  54639. * @param onProgress The callback when the load progresses
  54640. * @param fileName Defines the name of the file to load
  54641. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54642. */
  54643. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54644. /**
  54645. * Load into a scene.
  54646. * @param scene The scene to load into
  54647. * @param data The data to import
  54648. * @param rootUrl The root url for scene and resources
  54649. * @param onProgress The callback when the load progresses
  54650. * @param fileName Defines the name of the file to load
  54651. * @returns Nothing
  54652. */
  54653. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54654. /**
  54655. * Load into an asset container.
  54656. * @param scene The scene to load into
  54657. * @param data The data to import
  54658. * @param rootUrl The root url for scene and resources
  54659. * @param onProgress The callback when the load progresses
  54660. * @param fileName Defines the name of the file to load
  54661. * @returns The loaded asset container
  54662. */
  54663. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54664. }
  54665. /**
  54666. * Mode that determines how to handle old animation groups before loading new ones.
  54667. */
  54668. export enum SceneLoaderAnimationGroupLoadingMode {
  54669. /**
  54670. * Reset all old animations to initial state then dispose them.
  54671. */
  54672. Clean = 0,
  54673. /**
  54674. * Stop all old animations.
  54675. */
  54676. Stop = 1,
  54677. /**
  54678. * Restart old animations from first frame.
  54679. */
  54680. Sync = 2,
  54681. /**
  54682. * Old animations remains untouched.
  54683. */
  54684. NoSync = 3
  54685. }
  54686. /**
  54687. * Defines a plugin registered by the SceneLoader
  54688. */
  54689. interface IRegisteredPlugin {
  54690. /**
  54691. * Defines the plugin to use
  54692. */
  54693. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54694. /**
  54695. * Defines if the plugin supports binary data
  54696. */
  54697. isBinary: boolean;
  54698. }
  54699. /**
  54700. * Class used to load scene from various file formats using registered plugins
  54701. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54702. */
  54703. export class SceneLoader {
  54704. /**
  54705. * No logging while loading
  54706. */
  54707. static readonly NO_LOGGING: number;
  54708. /**
  54709. * Minimal logging while loading
  54710. */
  54711. static readonly MINIMAL_LOGGING: number;
  54712. /**
  54713. * Summary logging while loading
  54714. */
  54715. static readonly SUMMARY_LOGGING: number;
  54716. /**
  54717. * Detailed logging while loading
  54718. */
  54719. static readonly DETAILED_LOGGING: number;
  54720. /**
  54721. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54722. */
  54723. static get ForceFullSceneLoadingForIncremental(): boolean;
  54724. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54725. /**
  54726. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54727. */
  54728. static get ShowLoadingScreen(): boolean;
  54729. static set ShowLoadingScreen(value: boolean);
  54730. /**
  54731. * Defines the current logging level (while loading the scene)
  54732. * @ignorenaming
  54733. */
  54734. static get loggingLevel(): number;
  54735. static set loggingLevel(value: number);
  54736. /**
  54737. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54738. */
  54739. static get CleanBoneMatrixWeights(): boolean;
  54740. static set CleanBoneMatrixWeights(value: boolean);
  54741. /**
  54742. * Event raised when a plugin is used to load a scene
  54743. */
  54744. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54745. private static _registeredPlugins;
  54746. private static _showingLoadingScreen;
  54747. /**
  54748. * Gets the default plugin (used to load Babylon files)
  54749. * @returns the .babylon plugin
  54750. */
  54751. static GetDefaultPlugin(): IRegisteredPlugin;
  54752. private static _GetPluginForExtension;
  54753. private static _GetPluginForDirectLoad;
  54754. private static _GetPluginForFilename;
  54755. private static _GetDirectLoad;
  54756. private static _LoadData;
  54757. private static _GetFileInfo;
  54758. /**
  54759. * Gets a plugin that can load the given extension
  54760. * @param extension defines the extension to load
  54761. * @returns a plugin or null if none works
  54762. */
  54763. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54764. /**
  54765. * Gets a boolean indicating that the given extension can be loaded
  54766. * @param extension defines the extension to load
  54767. * @returns true if the extension is supported
  54768. */
  54769. static IsPluginForExtensionAvailable(extension: string): boolean;
  54770. /**
  54771. * Adds a new plugin to the list of registered plugins
  54772. * @param plugin defines the plugin to add
  54773. */
  54774. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  54775. /**
  54776. * Import meshes into a scene
  54777. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54778. * @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)
  54779. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  54780. * @param scene the instance of BABYLON.Scene to append to
  54781. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  54782. * @param onProgress a callback with a progress event for each file being loaded
  54783. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54784. * @param pluginExtension the extension used to determine the plugin
  54785. * @returns The loaded plugin
  54786. */
  54787. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54788. /**
  54789. * Import meshes into a scene
  54790. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54791. * @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)
  54792. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  54793. * @param scene the instance of BABYLON.Scene to append to
  54794. * @param onProgress a callback with a progress event for each file being loaded
  54795. * @param pluginExtension the extension used to determine the plugin
  54796. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  54797. */
  54798. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  54799. /**
  54800. * Load a scene
  54801. * @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)
  54802. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  54803. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54804. * @param onSuccess a callback with the scene when import succeeds
  54805. * @param onProgress a callback with a progress event for each file being loaded
  54806. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54807. * @param pluginExtension the extension used to determine the plugin
  54808. * @returns The loaded plugin
  54809. */
  54810. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54811. /**
  54812. * Load a scene
  54813. * @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)
  54814. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  54815. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54816. * @param onProgress a callback with a progress event for each file being loaded
  54817. * @param pluginExtension the extension used to determine the plugin
  54818. * @returns The loaded scene
  54819. */
  54820. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54821. /**
  54822. * Append a scene
  54823. * @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)
  54824. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  54825. * @param scene is the instance of BABYLON.Scene to append to
  54826. * @param onSuccess a callback with the scene when import succeeds
  54827. * @param onProgress a callback with a progress event for each file being loaded
  54828. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54829. * @param pluginExtension the extension used to determine the plugin
  54830. * @returns The loaded plugin
  54831. */
  54832. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54833. /**
  54834. * Append a scene
  54835. * @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)
  54836. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  54837. * @param scene is the instance of BABYLON.Scene to append to
  54838. * @param onProgress a callback with a progress event for each file being loaded
  54839. * @param pluginExtension the extension used to determine the plugin
  54840. * @returns The given scene
  54841. */
  54842. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54843. /**
  54844. * Load a scene into an asset container
  54845. * @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)
  54846. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  54847. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54848. * @param onSuccess a callback with the scene when import succeeds
  54849. * @param onProgress a callback with a progress event for each file being loaded
  54850. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54851. * @param pluginExtension the extension used to determine the plugin
  54852. * @returns The loaded plugin
  54853. */
  54854. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54855. /**
  54856. * Load a scene into an asset container
  54857. * @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)
  54858. * @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)
  54859. * @param scene is the instance of Scene to append to
  54860. * @param onProgress a callback with a progress event for each file being loaded
  54861. * @param pluginExtension the extension used to determine the plugin
  54862. * @returns The loaded asset container
  54863. */
  54864. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  54865. /**
  54866. * Import animations from a file into a scene
  54867. * @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)
  54868. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  54869. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54870. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54871. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54872. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54873. * @param onSuccess a callback with the scene when import succeeds
  54874. * @param onProgress a callback with a progress event for each file being loaded
  54875. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54876. * @param pluginExtension the extension used to determine the plugin
  54877. */
  54878. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): void;
  54879. /**
  54880. * Import animations from a file into a scene
  54881. * @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)
  54882. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  54883. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54884. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54885. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54886. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54887. * @param onSuccess a callback with the scene when import succeeds
  54888. * @param onProgress a callback with a progress event for each file being loaded
  54889. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54890. * @param pluginExtension the extension used to determine the plugin
  54891. * @returns the updated scene with imported animations
  54892. */
  54893. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54894. }
  54895. }
  54896. declare module BABYLON {
  54897. /**
  54898. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  54899. */
  54900. export type MotionControllerHandedness = "none" | "left" | "right";
  54901. /**
  54902. * The type of components available in motion controllers.
  54903. * This is not the name of the component.
  54904. */
  54905. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  54906. /**
  54907. * The state of a controller component
  54908. */
  54909. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  54910. /**
  54911. * The schema of motion controller layout.
  54912. * No object will be initialized using this interface
  54913. * This is used just to define the profile.
  54914. */
  54915. export interface IMotionControllerLayout {
  54916. /**
  54917. * Path to load the assets. Usually relative to the base path
  54918. */
  54919. assetPath: string;
  54920. /**
  54921. * Available components (unsorted)
  54922. */
  54923. components: {
  54924. /**
  54925. * A map of component Ids
  54926. */
  54927. [componentId: string]: {
  54928. /**
  54929. * The type of input the component outputs
  54930. */
  54931. type: MotionControllerComponentType;
  54932. /**
  54933. * The indices of this component in the gamepad object
  54934. */
  54935. gamepadIndices: {
  54936. /**
  54937. * Index of button
  54938. */
  54939. button?: number;
  54940. /**
  54941. * If available, index of x-axis
  54942. */
  54943. xAxis?: number;
  54944. /**
  54945. * If available, index of y-axis
  54946. */
  54947. yAxis?: number;
  54948. };
  54949. /**
  54950. * The mesh's root node name
  54951. */
  54952. rootNodeName: string;
  54953. /**
  54954. * Animation definitions for this model
  54955. */
  54956. visualResponses: {
  54957. [stateKey: string]: {
  54958. /**
  54959. * What property will be animated
  54960. */
  54961. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  54962. /**
  54963. * What states influence this visual response
  54964. */
  54965. states: MotionControllerComponentStateType[];
  54966. /**
  54967. * Type of animation - movement or visibility
  54968. */
  54969. valueNodeProperty: "transform" | "visibility";
  54970. /**
  54971. * Base node name to move. Its position will be calculated according to the min and max nodes
  54972. */
  54973. valueNodeName?: string;
  54974. /**
  54975. * Minimum movement node
  54976. */
  54977. minNodeName?: string;
  54978. /**
  54979. * Max movement node
  54980. */
  54981. maxNodeName?: string;
  54982. };
  54983. };
  54984. /**
  54985. * If touch enabled, what is the name of node to display user feedback
  54986. */
  54987. touchPointNodeName?: string;
  54988. };
  54989. };
  54990. /**
  54991. * Is it xr standard mapping or not
  54992. */
  54993. gamepadMapping: "" | "xr-standard";
  54994. /**
  54995. * Base root node of this entire model
  54996. */
  54997. rootNodeName: string;
  54998. /**
  54999. * Defines the main button component id
  55000. */
  55001. selectComponentId: string;
  55002. }
  55003. /**
  55004. * A definition for the layout map in the input profile
  55005. */
  55006. export interface IMotionControllerLayoutMap {
  55007. /**
  55008. * Layouts with handedness type as a key
  55009. */
  55010. [handedness: string]: IMotionControllerLayout;
  55011. }
  55012. /**
  55013. * The XR Input profile schema
  55014. * Profiles can be found here:
  55015. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  55016. */
  55017. export interface IMotionControllerProfile {
  55018. /**
  55019. * fallback profiles for this profileId
  55020. */
  55021. fallbackProfileIds: string[];
  55022. /**
  55023. * The layout map, with handedness as key
  55024. */
  55025. layouts: IMotionControllerLayoutMap;
  55026. /**
  55027. * The id of this profile
  55028. * correlates to the profile(s) in the xrInput.profiles array
  55029. */
  55030. profileId: string;
  55031. }
  55032. /**
  55033. * A helper-interface for the 3 meshes needed for controller button animation
  55034. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  55035. */
  55036. export interface IMotionControllerButtonMeshMap {
  55037. /**
  55038. * the mesh that defines the pressed value mesh position.
  55039. * This is used to find the max-position of this button
  55040. */
  55041. pressedMesh: AbstractMesh;
  55042. /**
  55043. * the mesh that defines the unpressed value mesh position.
  55044. * This is used to find the min (or initial) position of this button
  55045. */
  55046. unpressedMesh: AbstractMesh;
  55047. /**
  55048. * The mesh that will be changed when value changes
  55049. */
  55050. valueMesh: AbstractMesh;
  55051. }
  55052. /**
  55053. * A helper-interface for the 3 meshes needed for controller axis animation.
  55054. * This will be expanded when touchpad animations are fully supported
  55055. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  55056. */
  55057. export interface IMotionControllerMeshMap {
  55058. /**
  55059. * the mesh that defines the maximum value mesh position.
  55060. */
  55061. maxMesh?: AbstractMesh;
  55062. /**
  55063. * the mesh that defines the minimum value mesh position.
  55064. */
  55065. minMesh?: AbstractMesh;
  55066. /**
  55067. * The mesh that will be changed when axis value changes
  55068. */
  55069. valueMesh?: AbstractMesh;
  55070. }
  55071. /**
  55072. * The elements needed for change-detection of the gamepad objects in motion controllers
  55073. */
  55074. export interface IMinimalMotionControllerObject {
  55075. /**
  55076. * Available axes of this controller
  55077. */
  55078. axes: number[];
  55079. /**
  55080. * An array of available buttons
  55081. */
  55082. buttons: Array<{
  55083. /**
  55084. * Value of the button/trigger
  55085. */
  55086. value: number;
  55087. /**
  55088. * If the button/trigger is currently touched
  55089. */
  55090. touched: boolean;
  55091. /**
  55092. * If the button/trigger is currently pressed
  55093. */
  55094. pressed: boolean;
  55095. }>;
  55096. /**
  55097. * EXPERIMENTAL haptic support.
  55098. */
  55099. hapticActuators?: Array<{
  55100. pulse: (value: number, duration: number) => Promise<boolean>;
  55101. }>;
  55102. }
  55103. /**
  55104. * An Abstract Motion controller
  55105. * This class receives an xrInput and a profile layout and uses those to initialize the components
  55106. * Each component has an observable to check for changes in value and state
  55107. */
  55108. export abstract class WebXRAbstractMotionController implements IDisposable {
  55109. protected scene: Scene;
  55110. protected layout: IMotionControllerLayout;
  55111. /**
  55112. * The gamepad object correlating to this controller
  55113. */
  55114. gamepadObject: IMinimalMotionControllerObject;
  55115. /**
  55116. * handedness (left/right/none) of this controller
  55117. */
  55118. handedness: MotionControllerHandedness;
  55119. private _initComponent;
  55120. private _modelReady;
  55121. /**
  55122. * A map of components (WebXRControllerComponent) in this motion controller
  55123. * Components have a ComponentType and can also have both button and axis definitions
  55124. */
  55125. readonly components: {
  55126. [id: string]: WebXRControllerComponent;
  55127. };
  55128. /**
  55129. * Disable the model's animation. Can be set at any time.
  55130. */
  55131. disableAnimation: boolean;
  55132. /**
  55133. * Observers registered here will be triggered when the model of this controller is done loading
  55134. */
  55135. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  55136. /**
  55137. * The profile id of this motion controller
  55138. */
  55139. abstract profileId: string;
  55140. /**
  55141. * The root mesh of the model. It is null if the model was not yet initialized
  55142. */
  55143. rootMesh: Nullable<AbstractMesh>;
  55144. /**
  55145. * constructs a new abstract motion controller
  55146. * @param scene the scene to which the model of the controller will be added
  55147. * @param layout The profile layout to load
  55148. * @param gamepadObject The gamepad object correlating to this controller
  55149. * @param handedness handedness (left/right/none) of this controller
  55150. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  55151. */
  55152. constructor(scene: Scene, layout: IMotionControllerLayout,
  55153. /**
  55154. * The gamepad object correlating to this controller
  55155. */
  55156. gamepadObject: IMinimalMotionControllerObject,
  55157. /**
  55158. * handedness (left/right/none) of this controller
  55159. */
  55160. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  55161. /**
  55162. * Dispose this controller, the model mesh and all its components
  55163. */
  55164. dispose(): void;
  55165. /**
  55166. * Returns all components of specific type
  55167. * @param type the type to search for
  55168. * @return an array of components with this type
  55169. */
  55170. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  55171. /**
  55172. * get a component based an its component id as defined in layout.components
  55173. * @param id the id of the component
  55174. * @returns the component correlates to the id or undefined if not found
  55175. */
  55176. getComponent(id: string): WebXRControllerComponent;
  55177. /**
  55178. * Get the list of components available in this motion controller
  55179. * @returns an array of strings correlating to available components
  55180. */
  55181. getComponentIds(): string[];
  55182. /**
  55183. * Get the first component of specific type
  55184. * @param type type of component to find
  55185. * @return a controller component or null if not found
  55186. */
  55187. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  55188. /**
  55189. * Get the main (Select) component of this controller as defined in the layout
  55190. * @returns the main component of this controller
  55191. */
  55192. getMainComponent(): WebXRControllerComponent;
  55193. /**
  55194. * Loads the model correlating to this controller
  55195. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  55196. * @returns A promise fulfilled with the result of the model loading
  55197. */
  55198. loadModel(): Promise<boolean>;
  55199. /**
  55200. * Update this model using the current XRFrame
  55201. * @param xrFrame the current xr frame to use and update the model
  55202. */
  55203. updateFromXRFrame(xrFrame: XRFrame): void;
  55204. /**
  55205. * Backwards compatibility due to a deeply-integrated typo
  55206. */
  55207. get handness(): XREye;
  55208. /**
  55209. * Pulse (vibrate) this controller
  55210. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  55211. * Consecutive calls to this function will cancel the last pulse call
  55212. *
  55213. * @param value the strength of the pulse in 0.0...1.0 range
  55214. * @param duration Duration of the pulse in milliseconds
  55215. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  55216. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  55217. */
  55218. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  55219. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55220. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55221. /**
  55222. * Moves the axis on the controller mesh based on its current state
  55223. * @param axis the index of the axis
  55224. * @param axisValue the value of the axis which determines the meshes new position
  55225. * @hidden
  55226. */
  55227. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  55228. /**
  55229. * Update the model itself with the current frame data
  55230. * @param xrFrame the frame to use for updating the model mesh
  55231. */
  55232. protected updateModel(xrFrame: XRFrame): void;
  55233. /**
  55234. * Get the filename and path for this controller's model
  55235. * @returns a map of filename and path
  55236. */
  55237. protected abstract _getFilenameAndPath(): {
  55238. filename: string;
  55239. path: string;
  55240. };
  55241. /**
  55242. * This function is called before the mesh is loaded. It checks for loading constraints.
  55243. * For example, this function can check if the GLB loader is available
  55244. * If this function returns false, the generic controller will be loaded instead
  55245. * @returns Is the client ready to load the mesh
  55246. */
  55247. protected abstract _getModelLoadingConstraints(): boolean;
  55248. /**
  55249. * This function will be called after the model was successfully loaded and can be used
  55250. * for mesh transformations before it is available for the user
  55251. * @param meshes the loaded meshes
  55252. */
  55253. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  55254. /**
  55255. * Set the root mesh for this controller. Important for the WebXR controller class
  55256. * @param meshes the loaded meshes
  55257. */
  55258. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  55259. /**
  55260. * A function executed each frame that updates the mesh (if needed)
  55261. * @param xrFrame the current xrFrame
  55262. */
  55263. protected abstract _updateModel(xrFrame: XRFrame): void;
  55264. private _getGenericFilenameAndPath;
  55265. private _getGenericParentMesh;
  55266. }
  55267. }
  55268. declare module BABYLON {
  55269. /**
  55270. * A generic trigger-only motion controller for WebXR
  55271. */
  55272. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  55273. /**
  55274. * Static version of the profile id of this controller
  55275. */
  55276. static ProfileId: string;
  55277. profileId: string;
  55278. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  55279. protected _getFilenameAndPath(): {
  55280. filename: string;
  55281. path: string;
  55282. };
  55283. protected _getModelLoadingConstraints(): boolean;
  55284. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  55285. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55286. protected _updateModel(): void;
  55287. }
  55288. }
  55289. declare module BABYLON {
  55290. /**
  55291. * Class containing static functions to help procedurally build meshes
  55292. */
  55293. export class SphereBuilder {
  55294. /**
  55295. * Creates a sphere mesh
  55296. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55297. * * 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`)
  55298. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55299. * * 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
  55300. * * 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)
  55301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55302. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55304. * @param name defines the name of the mesh
  55305. * @param options defines the options used to create the mesh
  55306. * @param scene defines the hosting scene
  55307. * @returns the sphere mesh
  55308. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55309. */
  55310. static CreateSphere(name: string, options: {
  55311. segments?: number;
  55312. diameter?: number;
  55313. diameterX?: number;
  55314. diameterY?: number;
  55315. diameterZ?: number;
  55316. arc?: number;
  55317. slice?: number;
  55318. sideOrientation?: number;
  55319. frontUVs?: Vector4;
  55320. backUVs?: Vector4;
  55321. updatable?: boolean;
  55322. }, scene?: Nullable<Scene>): Mesh;
  55323. }
  55324. }
  55325. declare module BABYLON {
  55326. /**
  55327. * A profiled motion controller has its profile loaded from an online repository.
  55328. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  55329. */
  55330. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  55331. private _repositoryUrl;
  55332. private _buttonMeshMapping;
  55333. private _touchDots;
  55334. /**
  55335. * The profile ID of this controller. Will be populated when the controller initializes.
  55336. */
  55337. profileId: string;
  55338. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  55339. dispose(): void;
  55340. protected _getFilenameAndPath(): {
  55341. filename: string;
  55342. path: string;
  55343. };
  55344. protected _getModelLoadingConstraints(): boolean;
  55345. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  55346. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55347. protected _updateModel(_xrFrame: XRFrame): void;
  55348. }
  55349. }
  55350. declare module BABYLON {
  55351. /**
  55352. * A construction function type to create a new controller based on an xrInput object
  55353. */
  55354. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  55355. /**
  55356. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  55357. *
  55358. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  55359. * it should be replaced with auto-loaded controllers.
  55360. *
  55361. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  55362. */
  55363. export class WebXRMotionControllerManager {
  55364. private static _AvailableControllers;
  55365. private static _Fallbacks;
  55366. private static _ProfileLoadingPromises;
  55367. private static _ProfilesList;
  55368. /**
  55369. * The base URL of the online controller repository. Can be changed at any time.
  55370. */
  55371. static BaseRepositoryUrl: string;
  55372. /**
  55373. * Which repository gets priority - local or online
  55374. */
  55375. static PrioritizeOnlineRepository: boolean;
  55376. /**
  55377. * Use the online repository, or use only locally-defined controllers
  55378. */
  55379. static UseOnlineRepository: boolean;
  55380. /**
  55381. * Clear the cache used for profile loading and reload when requested again
  55382. */
  55383. static ClearProfilesCache(): void;
  55384. /**
  55385. * Register the default fallbacks.
  55386. * This function is called automatically when this file is imported.
  55387. */
  55388. static DefaultFallbacks(): void;
  55389. /**
  55390. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  55391. * @param profileId the profile to which a fallback needs to be found
  55392. * @return an array with corresponding fallback profiles
  55393. */
  55394. static FindFallbackWithProfileId(profileId: string): string[];
  55395. /**
  55396. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  55397. * The order of search:
  55398. *
  55399. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  55400. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  55401. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  55402. * 4) return the generic trigger controller if none were found
  55403. *
  55404. * @param xrInput the xrInput to which a new controller is initialized
  55405. * @param scene the scene to which the model will be added
  55406. * @param forceProfile force a certain profile for this controller
  55407. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  55408. */
  55409. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  55410. /**
  55411. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  55412. *
  55413. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  55414. *
  55415. * @param type the profile type to register
  55416. * @param constructFunction the function to be called when loading this profile
  55417. */
  55418. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  55419. /**
  55420. * Register a fallback to a specific profile.
  55421. * @param profileId the profileId that will receive the fallbacks
  55422. * @param fallbacks A list of fallback profiles
  55423. */
  55424. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  55425. /**
  55426. * Will update the list of profiles available in the repository
  55427. * @return a promise that resolves to a map of profiles available online
  55428. */
  55429. static UpdateProfilesList(): Promise<{
  55430. [profile: string]: string;
  55431. }>;
  55432. private static _LoadProfileFromRepository;
  55433. private static _LoadProfilesFromAvailableControllers;
  55434. }
  55435. }
  55436. declare module BABYLON {
  55437. /**
  55438. * Configuration options for the WebXR controller creation
  55439. */
  55440. export interface IWebXRControllerOptions {
  55441. /**
  55442. * Should the controller mesh be animated when a user interacts with it
  55443. * The pressed buttons / thumbstick and touchpad animations will be disabled
  55444. */
  55445. disableMotionControllerAnimation?: boolean;
  55446. /**
  55447. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  55448. */
  55449. doNotLoadControllerMesh?: boolean;
  55450. /**
  55451. * Force a specific controller type for this controller.
  55452. * This can be used when creating your own profile or when testing different controllers
  55453. */
  55454. forceControllerProfile?: string;
  55455. /**
  55456. * Defines a rendering group ID for meshes that will be loaded.
  55457. * This is for the default controllers only.
  55458. */
  55459. renderingGroupId?: number;
  55460. }
  55461. /**
  55462. * Represents an XR controller
  55463. */
  55464. export class WebXRInputSource {
  55465. private _scene;
  55466. /** The underlying input source for the controller */
  55467. inputSource: XRInputSource;
  55468. private _options;
  55469. private _tmpVector;
  55470. private _uniqueId;
  55471. private _disposed;
  55472. /**
  55473. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if that's the case only the pointer from the head will be available
  55474. */
  55475. grip?: AbstractMesh;
  55476. /**
  55477. * If available, this is the gamepad object related to this controller.
  55478. * Using this object it is possible to get click events and trackpad changes of the
  55479. * webxr controller that is currently being used.
  55480. */
  55481. motionController?: WebXRAbstractMotionController;
  55482. /**
  55483. * Event that fires when the controller is removed/disposed.
  55484. * The object provided as event data is this controller, after associated assets were disposed.
  55485. * uniqueId is still available.
  55486. */
  55487. onDisposeObservable: Observable<WebXRInputSource>;
  55488. /**
  55489. * Will be triggered when the mesh associated with the motion controller is done loading.
  55490. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  55491. * A shortened version of controller -> motion controller -> on mesh loaded.
  55492. */
  55493. onMeshLoadedObservable: Observable<AbstractMesh>;
  55494. /**
  55495. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  55496. */
  55497. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  55498. /**
  55499. * Pointer which can be used to select objects or attach a visible laser to
  55500. */
  55501. pointer: AbstractMesh;
  55502. /**
  55503. * Creates the input source object
  55504. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  55505. * @param _scene the scene which the controller should be associated to
  55506. * @param inputSource the underlying input source for the controller
  55507. * @param _options options for this controller creation
  55508. */
  55509. constructor(_scene: Scene,
  55510. /** The underlying input source for the controller */
  55511. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  55512. /**
  55513. * Get this controllers unique id
  55514. */
  55515. get uniqueId(): string;
  55516. /**
  55517. * Disposes of the object
  55518. */
  55519. dispose(): void;
  55520. /**
  55521. * Gets a world space ray coming from the pointer or grip
  55522. * @param result the resulting ray
  55523. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  55524. */
  55525. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  55526. /**
  55527. * Updates the controller pose based on the given XRFrame
  55528. * @param xrFrame xr frame to update the pose with
  55529. * @param referenceSpace reference space to use
  55530. */
  55531. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55532. }
  55533. }
  55534. declare module BABYLON {
  55535. /**
  55536. * The schema for initialization options of the XR Input class
  55537. */
  55538. export interface IWebXRInputOptions {
  55539. /**
  55540. * If set to true no model will be automatically loaded
  55541. */
  55542. doNotLoadControllerMeshes?: boolean;
  55543. /**
  55544. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55545. * If not found, the xr input profile data will be used.
  55546. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55547. */
  55548. forceInputProfile?: string;
  55549. /**
  55550. * Do not send a request to the controller repository to load the profile.
  55551. *
  55552. * Instead, use the controllers available in babylon itself.
  55553. */
  55554. disableOnlineControllerRepository?: boolean;
  55555. /**
  55556. * A custom URL for the controllers repository
  55557. */
  55558. customControllersRepositoryURL?: string;
  55559. /**
  55560. * Should the controller model's components not move according to the user input
  55561. */
  55562. disableControllerAnimation?: boolean;
  55563. /**
  55564. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55565. */
  55566. controllerOptions?: IWebXRControllerOptions;
  55567. }
  55568. /**
  55569. * XR input used to track XR inputs such as controllers/rays
  55570. */
  55571. export class WebXRInput implements IDisposable {
  55572. /**
  55573. * the xr session manager for this session
  55574. */
  55575. xrSessionManager: WebXRSessionManager;
  55576. /**
  55577. * the WebXR camera for this session. Mainly used for teleportation
  55578. */
  55579. xrCamera: WebXRCamera;
  55580. private readonly options;
  55581. /**
  55582. * XR controllers being tracked
  55583. */
  55584. controllers: Array<WebXRInputSource>;
  55585. private _frameObserver;
  55586. private _sessionEndedObserver;
  55587. private _sessionInitObserver;
  55588. /**
  55589. * Event when a controller has been connected/added
  55590. */
  55591. onControllerAddedObservable: Observable<WebXRInputSource>;
  55592. /**
  55593. * Event when a controller has been removed/disconnected
  55594. */
  55595. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55596. /**
  55597. * Initializes the WebXRInput
  55598. * @param xrSessionManager the xr session manager for this session
  55599. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55600. * @param options = initialization options for this xr input
  55601. */
  55602. constructor(
  55603. /**
  55604. * the xr session manager for this session
  55605. */
  55606. xrSessionManager: WebXRSessionManager,
  55607. /**
  55608. * the WebXR camera for this session. Mainly used for teleportation
  55609. */
  55610. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55611. private _onInputSourcesChange;
  55612. private _addAndRemoveControllers;
  55613. /**
  55614. * Disposes of the object
  55615. */
  55616. dispose(): void;
  55617. }
  55618. }
  55619. declare module BABYLON {
  55620. /**
  55621. * This is the base class for all WebXR features.
  55622. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55623. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55624. */
  55625. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55626. protected _xrSessionManager: WebXRSessionManager;
  55627. private _attached;
  55628. private _removeOnDetach;
  55629. /**
  55630. * Is this feature disposed?
  55631. */
  55632. isDisposed: boolean;
  55633. /**
  55634. * Should auto-attach be disabled?
  55635. */
  55636. disableAutoAttach: boolean;
  55637. /**
  55638. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55639. */
  55640. xrNativeFeatureName: string;
  55641. /**
  55642. * Construct a new (abstract) WebXR feature
  55643. * @param _xrSessionManager the xr session manager for this feature
  55644. */
  55645. constructor(_xrSessionManager: WebXRSessionManager);
  55646. /**
  55647. * Is this feature attached
  55648. */
  55649. get attached(): boolean;
  55650. /**
  55651. * attach this feature
  55652. *
  55653. * @param force should attachment be forced (even when already attached)
  55654. * @returns true if successful, false is failed or already attached
  55655. */
  55656. attach(force?: boolean): boolean;
  55657. /**
  55658. * detach this feature.
  55659. *
  55660. * @returns true if successful, false if failed or already detached
  55661. */
  55662. detach(): boolean;
  55663. /**
  55664. * Dispose this feature and all of the resources attached
  55665. */
  55666. dispose(): void;
  55667. /**
  55668. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55669. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55670. *
  55671. * @returns whether or not the feature is compatible in this environment
  55672. */
  55673. isCompatible(): boolean;
  55674. /**
  55675. * This is used to register callbacks that will automatically be removed when detach is called.
  55676. * @param observable the observable to which the observer will be attached
  55677. * @param callback the callback to register
  55678. */
  55679. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55680. /**
  55681. * Code in this function will be executed on each xrFrame received from the browser.
  55682. * This function will not execute after the feature is detached.
  55683. * @param _xrFrame the current frame
  55684. */
  55685. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55686. }
  55687. }
  55688. declare module BABYLON {
  55689. /**
  55690. * Renders a layer on top of an existing scene
  55691. */
  55692. export class UtilityLayerRenderer implements IDisposable {
  55693. /** the original scene that will be rendered on top of */
  55694. originalScene: Scene;
  55695. private _pointerCaptures;
  55696. private _lastPointerEvents;
  55697. private static _DefaultUtilityLayer;
  55698. private static _DefaultKeepDepthUtilityLayer;
  55699. private _sharedGizmoLight;
  55700. private _renderCamera;
  55701. /**
  55702. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55703. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55704. * @returns the camera that is used when rendering the utility layer
  55705. */
  55706. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55707. /**
  55708. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55709. * @param cam the camera that should be used when rendering the utility layer
  55710. */
  55711. setRenderCamera(cam: Nullable<Camera>): void;
  55712. /**
  55713. * @hidden
  55714. * Light which used by gizmos to get light shading
  55715. */
  55716. _getSharedGizmoLight(): HemisphericLight;
  55717. /**
  55718. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55719. */
  55720. pickUtilitySceneFirst: boolean;
  55721. /**
  55722. * 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)
  55723. */
  55724. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55725. /**
  55726. * 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)
  55727. */
  55728. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55729. /**
  55730. * The scene that is rendered on top of the original scene
  55731. */
  55732. utilityLayerScene: Scene;
  55733. /**
  55734. * If the utility layer should automatically be rendered on top of existing scene
  55735. */
  55736. shouldRender: boolean;
  55737. /**
  55738. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55739. */
  55740. onlyCheckPointerDownEvents: boolean;
  55741. /**
  55742. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55743. */
  55744. processAllEvents: boolean;
  55745. /**
  55746. * Observable raised when the pointer move from the utility layer scene to the main scene
  55747. */
  55748. onPointerOutObservable: Observable<number>;
  55749. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55750. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55751. private _afterRenderObserver;
  55752. private _sceneDisposeObserver;
  55753. private _originalPointerObserver;
  55754. /**
  55755. * Instantiates a UtilityLayerRenderer
  55756. * @param originalScene the original scene that will be rendered on top of
  55757. * @param handleEvents boolean indicating if the utility layer should handle events
  55758. */
  55759. constructor(
  55760. /** the original scene that will be rendered on top of */
  55761. originalScene: Scene, handleEvents?: boolean);
  55762. private _notifyObservers;
  55763. /**
  55764. * Renders the utility layers scene on top of the original scene
  55765. */
  55766. render(): void;
  55767. /**
  55768. * Disposes of the renderer
  55769. */
  55770. dispose(): void;
  55771. private _updateCamera;
  55772. }
  55773. }
  55774. declare module BABYLON {
  55775. /**
  55776. * Options interface for the pointer selection module
  55777. */
  55778. export interface IWebXRControllerPointerSelectionOptions {
  55779. /**
  55780. * if provided, this scene will be used to render meshes.
  55781. */
  55782. customUtilityLayerScene?: Scene;
  55783. /**
  55784. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  55785. * If not disabled, the last picked point will be used to execute a pointer up event
  55786. * If disabled, pointer up event will be triggered right after the pointer down event.
  55787. * Used in screen and gaze target ray mode only
  55788. */
  55789. disablePointerUpOnTouchOut: boolean;
  55790. /**
  55791. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  55792. */
  55793. forceGazeMode: boolean;
  55794. /**
  55795. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  55796. * to start a new countdown to the pointer down event.
  55797. * Defaults to 1.
  55798. */
  55799. gazeModePointerMovedFactor?: number;
  55800. /**
  55801. * Different button type to use instead of the main component
  55802. */
  55803. overrideButtonId?: string;
  55804. /**
  55805. * use this rendering group id for the meshes (optional)
  55806. */
  55807. renderingGroupId?: number;
  55808. /**
  55809. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  55810. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  55811. * 3000 means 3 seconds between pointing at something and selecting it
  55812. */
  55813. timeToSelect?: number;
  55814. /**
  55815. * Should meshes created here be added to a utility layer or the main scene
  55816. */
  55817. useUtilityLayer?: boolean;
  55818. /**
  55819. * Optional WebXR camera to be used for gaze selection
  55820. */
  55821. gazeCamera?: WebXRCamera;
  55822. /**
  55823. * the xr input to use with this pointer selection
  55824. */
  55825. xrInput: WebXRInput;
  55826. /**
  55827. * Should the scene pointerX and pointerY update be disabled
  55828. * This is required for fullscreen AR GUI, but might slow down other experiences.
  55829. * Disable in VR, if not needed.
  55830. * The first rig camera (left eye) will be used to calculate the projection
  55831. */
  55832. disableScenePointerVectorUpdate: boolean;
  55833. /**
  55834. * Enable pointer selection on all controllers instead of switching between them
  55835. */
  55836. enablePointerSelectionOnAllControllers?: boolean;
  55837. /**
  55838. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  55839. * If switch is enabled, it will still allow the user to switch between the different controllers
  55840. */
  55841. preferredHandedness?: XRHandedness;
  55842. /**
  55843. * Disable switching the pointer selection from one controller to the other.
  55844. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  55845. */
  55846. disableSwitchOnClick?: boolean;
  55847. /**
  55848. * The maximum distance of the pointer selection feature. Defaults to 100.
  55849. */
  55850. maxPointerDistance?: number;
  55851. }
  55852. /**
  55853. * A module that will enable pointer selection for motion controllers of XR Input Sources
  55854. */
  55855. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  55856. private readonly _options;
  55857. private static _idCounter;
  55858. private _attachController;
  55859. private _controllers;
  55860. private _scene;
  55861. private _tmpVectorForPickCompare;
  55862. private _attachedController;
  55863. /**
  55864. * The module's name
  55865. */
  55866. static readonly Name: string;
  55867. /**
  55868. * The (Babylon) version of this module.
  55869. * This is an integer representing the implementation version.
  55870. * This number does not correspond to the WebXR specs version
  55871. */
  55872. static readonly Version: number;
  55873. /**
  55874. * Disable lighting on the laser pointer (so it will always be visible)
  55875. */
  55876. disablePointerLighting: boolean;
  55877. /**
  55878. * Disable lighting on the selection mesh (so it will always be visible)
  55879. */
  55880. disableSelectionMeshLighting: boolean;
  55881. /**
  55882. * Should the laser pointer be displayed
  55883. */
  55884. displayLaserPointer: boolean;
  55885. /**
  55886. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  55887. */
  55888. displaySelectionMesh: boolean;
  55889. /**
  55890. * This color will be set to the laser pointer when selection is triggered
  55891. */
  55892. laserPointerPickedColor: Color3;
  55893. /**
  55894. * Default color of the laser pointer
  55895. */
  55896. laserPointerDefaultColor: Color3;
  55897. /**
  55898. * default color of the selection ring
  55899. */
  55900. selectionMeshDefaultColor: Color3;
  55901. /**
  55902. * This color will be applied to the selection ring when selection is triggered
  55903. */
  55904. selectionMeshPickedColor: Color3;
  55905. /**
  55906. * Optional filter to be used for ray selection. This predicate shares behavior with
  55907. * scene.pointerMovePredicate which takes priority if it is also assigned.
  55908. */
  55909. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55910. /**
  55911. * constructs a new background remover module
  55912. * @param _xrSessionManager the session manager for this module
  55913. * @param _options read-only options to be used in this module
  55914. */
  55915. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  55916. /**
  55917. * attach this feature
  55918. * Will usually be called by the features manager
  55919. *
  55920. * @returns true if successful.
  55921. */
  55922. attach(): boolean;
  55923. /**
  55924. * detach this feature.
  55925. * Will usually be called by the features manager
  55926. *
  55927. * @returns true if successful.
  55928. */
  55929. detach(): boolean;
  55930. /**
  55931. * Will get the mesh under a specific pointer.
  55932. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  55933. * @param controllerId the controllerId to check
  55934. * @returns The mesh under pointer or null if no mesh is under the pointer
  55935. */
  55936. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  55937. /**
  55938. * Get the xr controller that correlates to the pointer id in the pointer event
  55939. *
  55940. * @param id the pointer id to search for
  55941. * @returns the controller that correlates to this id or null if not found
  55942. */
  55943. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  55944. private _identityMatrix;
  55945. private _screenCoordinatesRef;
  55946. private _viewportRef;
  55947. protected _onXRFrame(_xrFrame: XRFrame): void;
  55948. private _attachGazeMode;
  55949. private _attachScreenRayMode;
  55950. private _attachTrackedPointerRayMode;
  55951. private _convertNormalToDirectionOfRay;
  55952. private _detachController;
  55953. private _generateNewMeshPair;
  55954. private _pickingMoved;
  55955. private _updatePointerDistance;
  55956. /** @hidden */
  55957. get lasterPointerDefaultColor(): Color3;
  55958. }
  55959. }
  55960. declare module BABYLON {
  55961. /**
  55962. * Button which can be used to enter a different mode of XR
  55963. */
  55964. export class WebXREnterExitUIButton {
  55965. /** button element */
  55966. element: HTMLElement;
  55967. /** XR initialization options for the button */
  55968. sessionMode: XRSessionMode;
  55969. /** Reference space type */
  55970. referenceSpaceType: XRReferenceSpaceType;
  55971. /**
  55972. * Creates a WebXREnterExitUIButton
  55973. * @param element button element
  55974. * @param sessionMode XR initialization session mode
  55975. * @param referenceSpaceType the type of reference space to be used
  55976. */
  55977. constructor(
  55978. /** button element */
  55979. element: HTMLElement,
  55980. /** XR initialization options for the button */
  55981. sessionMode: XRSessionMode,
  55982. /** Reference space type */
  55983. referenceSpaceType: XRReferenceSpaceType);
  55984. /**
  55985. * Extendable function which can be used to update the button's visuals when the state changes
  55986. * @param activeButton the current active button in the UI
  55987. */
  55988. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  55989. }
  55990. /**
  55991. * Options to create the webXR UI
  55992. */
  55993. export class WebXREnterExitUIOptions {
  55994. /**
  55995. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  55996. */
  55997. customButtons?: Array<WebXREnterExitUIButton>;
  55998. /**
  55999. * A reference space type to use when creating the default button.
  56000. * Default is local-floor
  56001. */
  56002. referenceSpaceType?: XRReferenceSpaceType;
  56003. /**
  56004. * Context to enter xr with
  56005. */
  56006. renderTarget?: Nullable<WebXRRenderTarget>;
  56007. /**
  56008. * A session mode to use when creating the default button.
  56009. * Default is immersive-vr
  56010. */
  56011. sessionMode?: XRSessionMode;
  56012. /**
  56013. * A list of optional features to init the session with
  56014. */
  56015. optionalFeatures?: string[];
  56016. /**
  56017. * A list of optional features to init the session with
  56018. */
  56019. requiredFeatures?: string[];
  56020. /**
  56021. * If defined, this function will be executed if the UI encounters an error when entering XR
  56022. */
  56023. onError?: (error: any) => void;
  56024. }
  56025. /**
  56026. * UI to allow the user to enter/exit XR mode
  56027. */
  56028. export class WebXREnterExitUI implements IDisposable {
  56029. private scene;
  56030. /** version of the options passed to this UI */
  56031. options: WebXREnterExitUIOptions;
  56032. private _activeButton;
  56033. private _buttons;
  56034. /**
  56035. * The HTML Div Element to which buttons are added.
  56036. */
  56037. readonly overlay: HTMLDivElement;
  56038. /**
  56039. * Fired every time the active button is changed.
  56040. *
  56041. * When xr is entered via a button that launches xr that button will be the callback parameter
  56042. *
  56043. * When exiting xr the callback parameter will be null)
  56044. */
  56045. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  56046. /**
  56047. *
  56048. * @param scene babylon scene object to use
  56049. * @param options (read-only) version of the options passed to this UI
  56050. */
  56051. private constructor();
  56052. /**
  56053. * Creates UI to allow the user to enter/exit XR mode
  56054. * @param scene the scene to add the ui to
  56055. * @param helper the xr experience helper to enter/exit xr with
  56056. * @param options options to configure the UI
  56057. * @returns the created ui
  56058. */
  56059. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  56060. /**
  56061. * Disposes of the XR UI component
  56062. */
  56063. dispose(): void;
  56064. private _updateButtons;
  56065. }
  56066. }
  56067. declare module BABYLON {
  56068. /**
  56069. * Class containing static functions to help procedurally build meshes
  56070. */
  56071. export class LinesBuilder {
  56072. /**
  56073. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56074. * * 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
  56075. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56076. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56077. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56078. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56079. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56080. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  56081. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56084. * @param name defines the name of the new line system
  56085. * @param options defines the options used to create the line system
  56086. * @param scene defines the hosting scene
  56087. * @returns a new line system mesh
  56088. */
  56089. static CreateLineSystem(name: string, options: {
  56090. lines: Vector3[][];
  56091. updatable?: boolean;
  56092. instance?: Nullable<LinesMesh>;
  56093. colors?: Nullable<Color4[][]>;
  56094. useVertexAlpha?: boolean;
  56095. }, scene: Nullable<Scene>): LinesMesh;
  56096. /**
  56097. * Creates a line mesh
  56098. * 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
  56099. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56100. * * The parameter `points` is an array successive Vector3
  56101. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  56102. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56103. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56104. * * When updating an instance, remember that only point positions can change, not the number of points
  56105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56107. * @param name defines the name of the new line system
  56108. * @param options defines the options used to create the line system
  56109. * @param scene defines the hosting scene
  56110. * @returns a new line mesh
  56111. */
  56112. static CreateLines(name: string, options: {
  56113. points: Vector3[];
  56114. updatable?: boolean;
  56115. instance?: Nullable<LinesMesh>;
  56116. colors?: Color4[];
  56117. useVertexAlpha?: boolean;
  56118. }, scene?: Nullable<Scene>): LinesMesh;
  56119. /**
  56120. * Creates a dashed line mesh
  56121. * * 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
  56122. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56123. * * The parameter `points` is an array successive Vector3
  56124. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56125. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56126. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56127. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  56128. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56129. * * When updating an instance, remember that only point positions can change, not the number of points
  56130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56131. * @param name defines the name of the mesh
  56132. * @param options defines the options used to create the mesh
  56133. * @param scene defines the hosting scene
  56134. * @returns the dashed line mesh
  56135. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56136. */
  56137. static CreateDashedLines(name: string, options: {
  56138. points: Vector3[];
  56139. dashSize?: number;
  56140. gapSize?: number;
  56141. dashNb?: number;
  56142. updatable?: boolean;
  56143. instance?: LinesMesh;
  56144. useVertexAlpha?: boolean;
  56145. }, scene?: Nullable<Scene>): LinesMesh;
  56146. }
  56147. }
  56148. declare module BABYLON {
  56149. /**
  56150. * Construction options for a timer
  56151. */
  56152. export interface ITimerOptions<T> {
  56153. /**
  56154. * Time-to-end
  56155. */
  56156. timeout: number;
  56157. /**
  56158. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  56159. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  56160. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  56161. */
  56162. contextObservable: Observable<T>;
  56163. /**
  56164. * Optional parameters when adding an observer to the observable
  56165. */
  56166. observableParameters?: {
  56167. mask?: number;
  56168. insertFirst?: boolean;
  56169. scope?: any;
  56170. };
  56171. /**
  56172. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  56173. */
  56174. breakCondition?: (data?: ITimerData<T>) => boolean;
  56175. /**
  56176. * Will be triggered when the time condition has met
  56177. */
  56178. onEnded?: (data: ITimerData<any>) => void;
  56179. /**
  56180. * Will be triggered when the break condition has met (prematurely ended)
  56181. */
  56182. onAborted?: (data: ITimerData<any>) => void;
  56183. /**
  56184. * Optional function to execute on each tick (or count)
  56185. */
  56186. onTick?: (data: ITimerData<any>) => void;
  56187. }
  56188. /**
  56189. * An interface defining the data sent by the timer
  56190. */
  56191. export interface ITimerData<T> {
  56192. /**
  56193. * When did it start
  56194. */
  56195. startTime: number;
  56196. /**
  56197. * Time now
  56198. */
  56199. currentTime: number;
  56200. /**
  56201. * Time passed since started
  56202. */
  56203. deltaTime: number;
  56204. /**
  56205. * How much is completed, in [0.0...1.0].
  56206. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  56207. */
  56208. completeRate: number;
  56209. /**
  56210. * What the registered observable sent in the last count
  56211. */
  56212. payload: T;
  56213. }
  56214. /**
  56215. * The current state of the timer
  56216. */
  56217. export enum TimerState {
  56218. /**
  56219. * Timer initialized, not yet started
  56220. */
  56221. INIT = 0,
  56222. /**
  56223. * Timer started and counting
  56224. */
  56225. STARTED = 1,
  56226. /**
  56227. * Timer ended (whether aborted or time reached)
  56228. */
  56229. ENDED = 2
  56230. }
  56231. /**
  56232. * A simple version of the timer. Will take options and start the timer immediately after calling it
  56233. *
  56234. * @param options options with which to initialize this timer
  56235. */
  56236. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  56237. /**
  56238. * An advanced implementation of a timer class
  56239. */
  56240. export class AdvancedTimer<T = any> implements IDisposable {
  56241. /**
  56242. * Will notify each time the timer calculates the remaining time
  56243. */
  56244. onEachCountObservable: Observable<ITimerData<T>>;
  56245. /**
  56246. * Will trigger when the timer was aborted due to the break condition
  56247. */
  56248. onTimerAbortedObservable: Observable<ITimerData<T>>;
  56249. /**
  56250. * Will trigger when the timer ended successfully
  56251. */
  56252. onTimerEndedObservable: Observable<ITimerData<T>>;
  56253. /**
  56254. * Will trigger when the timer state has changed
  56255. */
  56256. onStateChangedObservable: Observable<TimerState>;
  56257. private _observer;
  56258. private _contextObservable;
  56259. private _observableParameters;
  56260. private _startTime;
  56261. private _timer;
  56262. private _state;
  56263. private _breakCondition;
  56264. private _timeToEnd;
  56265. private _breakOnNextTick;
  56266. /**
  56267. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  56268. * @param options construction options for this advanced timer
  56269. */
  56270. constructor(options: ITimerOptions<T>);
  56271. /**
  56272. * set a breaking condition for this timer. Default is to never break during count
  56273. * @param predicate the new break condition. Returns true to break, false otherwise
  56274. */
  56275. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  56276. /**
  56277. * Reset ALL associated observables in this advanced timer
  56278. */
  56279. clearObservables(): void;
  56280. /**
  56281. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  56282. *
  56283. * @param timeToEnd how much time to measure until timer ended
  56284. */
  56285. start(timeToEnd?: number): void;
  56286. /**
  56287. * Will force a stop on the next tick.
  56288. */
  56289. stop(): void;
  56290. /**
  56291. * Dispose this timer, clearing all resources
  56292. */
  56293. dispose(): void;
  56294. private _setState;
  56295. private _tick;
  56296. private _stop;
  56297. }
  56298. }
  56299. declare module BABYLON {
  56300. /**
  56301. * The options container for the teleportation module
  56302. */
  56303. export interface IWebXRTeleportationOptions {
  56304. /**
  56305. * if provided, this scene will be used to render meshes.
  56306. */
  56307. customUtilityLayerScene?: Scene;
  56308. /**
  56309. * Values to configure the default target mesh
  56310. */
  56311. defaultTargetMeshOptions?: {
  56312. /**
  56313. * Fill color of the teleportation area
  56314. */
  56315. teleportationFillColor?: string;
  56316. /**
  56317. * Border color for the teleportation area
  56318. */
  56319. teleportationBorderColor?: string;
  56320. /**
  56321. * Disable the mesh's animation sequence
  56322. */
  56323. disableAnimation?: boolean;
  56324. /**
  56325. * Disable lighting on the material or the ring and arrow
  56326. */
  56327. disableLighting?: boolean;
  56328. /**
  56329. * Override the default material of the torus and arrow
  56330. */
  56331. torusArrowMaterial?: Material;
  56332. };
  56333. /**
  56334. * A list of meshes to use as floor meshes.
  56335. * Meshes can be added and removed after initializing the feature using the
  56336. * addFloorMesh and removeFloorMesh functions
  56337. * If empty, rotation will still work
  56338. */
  56339. floorMeshes?: AbstractMesh[];
  56340. /**
  56341. * use this rendering group id for the meshes (optional)
  56342. */
  56343. renderingGroupId?: number;
  56344. /**
  56345. * Should teleportation move only to snap points
  56346. */
  56347. snapPointsOnly?: boolean;
  56348. /**
  56349. * An array of points to which the teleportation will snap to.
  56350. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  56351. */
  56352. snapPositions?: Vector3[];
  56353. /**
  56354. * How close should the teleportation ray be in order to snap to position.
  56355. * Default to 0.8 units (meters)
  56356. */
  56357. snapToPositionRadius?: number;
  56358. /**
  56359. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  56360. * If you want to support rotation, make sure your mesh has a direction indicator.
  56361. *
  56362. * When left untouched, the default mesh will be initialized.
  56363. */
  56364. teleportationTargetMesh?: AbstractMesh;
  56365. /**
  56366. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  56367. */
  56368. timeToTeleport?: number;
  56369. /**
  56370. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  56371. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  56372. */
  56373. useMainComponentOnly?: boolean;
  56374. /**
  56375. * Should meshes created here be added to a utility layer or the main scene
  56376. */
  56377. useUtilityLayer?: boolean;
  56378. /**
  56379. * Babylon XR Input class for controller
  56380. */
  56381. xrInput: WebXRInput;
  56382. /**
  56383. * Meshes that the teleportation ray cannot go through
  56384. */
  56385. pickBlockerMeshes?: AbstractMesh[];
  56386. /**
  56387. * Should teleport work only on a specific hand?
  56388. */
  56389. forceHandedness?: XRHandedness;
  56390. /**
  56391. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  56392. */
  56393. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  56394. }
  56395. /**
  56396. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  56397. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  56398. * the input of the attached controllers.
  56399. */
  56400. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  56401. private _options;
  56402. private _controllers;
  56403. private _currentTeleportationControllerId;
  56404. private _floorMeshes;
  56405. private _quadraticBezierCurve;
  56406. private _selectionFeature;
  56407. private _snapToPositions;
  56408. private _snappedToPoint;
  56409. private _teleportationRingMaterial?;
  56410. private _tmpRay;
  56411. private _tmpVector;
  56412. private _tmpQuaternion;
  56413. /**
  56414. * The module's name
  56415. */
  56416. static readonly Name: string;
  56417. /**
  56418. * The (Babylon) version of this module.
  56419. * This is an integer representing the implementation version.
  56420. * This number does not correspond to the webxr specs version
  56421. */
  56422. static readonly Version: number;
  56423. /**
  56424. * Is movement backwards enabled
  56425. */
  56426. backwardsMovementEnabled: boolean;
  56427. /**
  56428. * Distance to travel when moving backwards
  56429. */
  56430. backwardsTeleportationDistance: number;
  56431. /**
  56432. * The distance from the user to the inspection point in the direction of the controller
  56433. * A higher number will allow the user to move further
  56434. * defaults to 5 (meters, in xr units)
  56435. */
  56436. parabolicCheckRadius: number;
  56437. /**
  56438. * Should the module support parabolic ray on top of direct ray
  56439. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  56440. * Very helpful when moving between floors / different heights
  56441. */
  56442. parabolicRayEnabled: boolean;
  56443. /**
  56444. * The second type of ray - straight line.
  56445. * Should it be enabled or should the parabolic line be the only one.
  56446. */
  56447. straightRayEnabled: boolean;
  56448. /**
  56449. * How much rotation should be applied when rotating right and left
  56450. */
  56451. rotationAngle: number;
  56452. private _rotationEnabled;
  56453. /**
  56454. * Is rotation enabled when moving forward?
  56455. * Disabling this feature will prevent the user from deciding the direction when teleporting
  56456. */
  56457. get rotationEnabled(): boolean;
  56458. /**
  56459. * Sets whether rotation is enabled or not
  56460. * @param enabled is rotation enabled when teleportation is shown
  56461. */
  56462. set rotationEnabled(enabled: boolean);
  56463. /**
  56464. * Exposes the currently set teleportation target mesh.
  56465. */
  56466. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  56467. /**
  56468. * constructs a new anchor system
  56469. * @param _xrSessionManager an instance of WebXRSessionManager
  56470. * @param _options configuration object for this feature
  56471. */
  56472. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  56473. /**
  56474. * Get the snapPointsOnly flag
  56475. */
  56476. get snapPointsOnly(): boolean;
  56477. /**
  56478. * Sets the snapPointsOnly flag
  56479. * @param snapToPoints should teleportation be exclusively to snap points
  56480. */
  56481. set snapPointsOnly(snapToPoints: boolean);
  56482. /**
  56483. * Add a new mesh to the floor meshes array
  56484. * @param mesh the mesh to use as floor mesh
  56485. */
  56486. addFloorMesh(mesh: AbstractMesh): void;
  56487. /**
  56488. * Add a new snap-to point to fix teleportation to this position
  56489. * @param newSnapPoint The new Snap-To point
  56490. */
  56491. addSnapPoint(newSnapPoint: Vector3): void;
  56492. attach(): boolean;
  56493. detach(): boolean;
  56494. dispose(): void;
  56495. /**
  56496. * Remove a mesh from the floor meshes array
  56497. * @param mesh the mesh to remove
  56498. */
  56499. removeFloorMesh(mesh: AbstractMesh): void;
  56500. /**
  56501. * Remove a mesh from the floor meshes array using its name
  56502. * @param name the mesh name to remove
  56503. */
  56504. removeFloorMeshByName(name: string): void;
  56505. /**
  56506. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  56507. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  56508. * @returns was the point found and removed or not
  56509. */
  56510. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  56511. /**
  56512. * This function sets a selection feature that will be disabled when
  56513. * the forward ray is shown and will be reattached when hidden.
  56514. * This is used to remove the selection rays when moving.
  56515. * @param selectionFeature the feature to disable when forward movement is enabled
  56516. */
  56517. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  56518. protected _onXRFrame(_xrFrame: XRFrame): void;
  56519. private _attachController;
  56520. private _createDefaultTargetMesh;
  56521. private _detachController;
  56522. private _findClosestSnapPointWithRadius;
  56523. private _setTargetMeshPosition;
  56524. private _setTargetMeshVisibility;
  56525. private _showParabolicPath;
  56526. private _teleportForward;
  56527. }
  56528. }
  56529. declare module BABYLON {
  56530. /**
  56531. * Options for the default xr helper
  56532. */
  56533. export class WebXRDefaultExperienceOptions {
  56534. /**
  56535. * Enable or disable default UI to enter XR
  56536. */
  56537. disableDefaultUI?: boolean;
  56538. /**
  56539. * Should teleportation not initialize. defaults to false.
  56540. */
  56541. disableTeleportation?: boolean;
  56542. /**
  56543. * Floor meshes that will be used for teleport
  56544. */
  56545. floorMeshes?: Array<AbstractMesh>;
  56546. /**
  56547. * If set to true, the first frame will not be used to reset position
  56548. * The first frame is mainly used when copying transformation from the old camera
  56549. * Mainly used in AR
  56550. */
  56551. ignoreNativeCameraTransformation?: boolean;
  56552. /**
  56553. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56554. */
  56555. inputOptions?: IWebXRInputOptions;
  56556. /**
  56557. * optional configuration for the output canvas
  56558. */
  56559. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56560. /**
  56561. * optional UI options. This can be used among other to change session mode and reference space type
  56562. */
  56563. uiOptions?: WebXREnterExitUIOptions;
  56564. /**
  56565. * When loading teleportation and pointer select, use stable versions instead of latest.
  56566. */
  56567. useStablePlugins?: boolean;
  56568. /**
  56569. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56570. */
  56571. renderingGroupId?: number;
  56572. /**
  56573. * A list of optional features to init the session with
  56574. * If set to true, all features we support will be added
  56575. */
  56576. optionalFeatures?: boolean | string[];
  56577. }
  56578. /**
  56579. * Default experience which provides a similar setup to the previous webVRExperience
  56580. */
  56581. export class WebXRDefaultExperience {
  56582. /**
  56583. * Base experience
  56584. */
  56585. baseExperience: WebXRExperienceHelper;
  56586. /**
  56587. * Enables ui for entering/exiting xr
  56588. */
  56589. enterExitUI: WebXREnterExitUI;
  56590. /**
  56591. * Input experience extension
  56592. */
  56593. input: WebXRInput;
  56594. /**
  56595. * Enables laser pointer and selection
  56596. */
  56597. pointerSelection: WebXRControllerPointerSelection;
  56598. /**
  56599. * Default target xr should render to
  56600. */
  56601. renderTarget: WebXRRenderTarget;
  56602. /**
  56603. * Enables teleportation
  56604. */
  56605. teleportation: WebXRMotionControllerTeleportation;
  56606. private constructor();
  56607. /**
  56608. * Creates the default xr experience
  56609. * @param scene scene
  56610. * @param options options for basic configuration
  56611. * @returns resulting WebXRDefaultExperience
  56612. */
  56613. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56614. /**
  56615. * Disposes of the experience helper
  56616. */
  56617. dispose(): void;
  56618. }
  56619. }
  56620. declare module BABYLON {
  56621. /**
  56622. * Options to modify the vr teleportation behavior.
  56623. */
  56624. export interface VRTeleportationOptions {
  56625. /**
  56626. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56627. */
  56628. floorMeshName?: string;
  56629. /**
  56630. * A list of meshes to be used as the teleportation floor. (default: empty)
  56631. */
  56632. floorMeshes?: Mesh[];
  56633. /**
  56634. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56635. */
  56636. teleportationMode?: number;
  56637. /**
  56638. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56639. */
  56640. teleportationTime?: number;
  56641. /**
  56642. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56643. */
  56644. teleportationSpeed?: number;
  56645. /**
  56646. * The easing function used in the animation or null for Linear. (default CircleEase)
  56647. */
  56648. easingFunction?: EasingFunction;
  56649. }
  56650. /**
  56651. * Options to modify the vr experience helper's behavior.
  56652. */
  56653. export interface VRExperienceHelperOptions extends WebVROptions {
  56654. /**
  56655. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56656. */
  56657. createDeviceOrientationCamera?: boolean;
  56658. /**
  56659. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56660. */
  56661. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56662. /**
  56663. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56664. */
  56665. laserToggle?: boolean;
  56666. /**
  56667. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56668. */
  56669. floorMeshes?: Mesh[];
  56670. /**
  56671. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56672. */
  56673. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56674. /**
  56675. * Defines if WebXR should be used instead of WebVR (if available)
  56676. */
  56677. useXR?: boolean;
  56678. }
  56679. /**
  56680. * Event containing information after VR has been entered
  56681. */
  56682. export class OnAfterEnteringVRObservableEvent {
  56683. /**
  56684. * If entering vr was successful
  56685. */
  56686. success: boolean;
  56687. }
  56688. /**
  56689. * Helps to quickly add VR support to an existing scene.
  56690. * See https://doc.babylonjs.com/how_to/webvr_helper
  56691. */
  56692. export class VRExperienceHelper {
  56693. /** Options to modify the vr experience helper's behavior. */
  56694. webVROptions: VRExperienceHelperOptions;
  56695. private _scene;
  56696. private _position;
  56697. private _btnVR;
  56698. private _btnVRDisplayed;
  56699. private _webVRsupported;
  56700. private _webVRready;
  56701. private _webVRrequesting;
  56702. private _webVRpresenting;
  56703. private _hasEnteredVR;
  56704. private _fullscreenVRpresenting;
  56705. private _inputElement;
  56706. private _webVRCamera;
  56707. private _vrDeviceOrientationCamera;
  56708. private _deviceOrientationCamera;
  56709. private _existingCamera;
  56710. private _onKeyDown;
  56711. private _onVrDisplayPresentChange;
  56712. private _onVRDisplayChanged;
  56713. private _onVRRequestPresentStart;
  56714. private _onVRRequestPresentComplete;
  56715. /**
  56716. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  56717. */
  56718. enableGazeEvenWhenNoPointerLock: boolean;
  56719. /**
  56720. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56721. */
  56722. exitVROnDoubleTap: boolean;
  56723. /**
  56724. * Observable raised right before entering VR.
  56725. */
  56726. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56727. /**
  56728. * Observable raised when entering VR has completed.
  56729. */
  56730. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56731. /**
  56732. * Observable raised when exiting VR.
  56733. */
  56734. onExitingVRObservable: Observable<VRExperienceHelper>;
  56735. /**
  56736. * Observable raised when controller mesh is loaded.
  56737. */
  56738. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56739. /** Return this.onEnteringVRObservable
  56740. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56741. */
  56742. get onEnteringVR(): Observable<VRExperienceHelper>;
  56743. /** Return this.onExitingVRObservable
  56744. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56745. */
  56746. get onExitingVR(): Observable<VRExperienceHelper>;
  56747. /** Return this.onControllerMeshLoadedObservable
  56748. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56749. */
  56750. get onControllerMeshLoaded(): Observable<WebVRController>;
  56751. private _rayLength;
  56752. private _useCustomVRButton;
  56753. private _teleportationRequested;
  56754. private _teleportActive;
  56755. private _floorMeshName;
  56756. private _floorMeshesCollection;
  56757. private _teleportationMode;
  56758. private _teleportationTime;
  56759. private _teleportationSpeed;
  56760. private _teleportationEasing;
  56761. private _rotationAllowed;
  56762. private _teleportBackwardsVector;
  56763. private _teleportationTarget;
  56764. private _isDefaultTeleportationTarget;
  56765. private _postProcessMove;
  56766. private _teleportationFillColor;
  56767. private _teleportationBorderColor;
  56768. private _rotationAngle;
  56769. private _haloCenter;
  56770. private _cameraGazer;
  56771. private _padSensibilityUp;
  56772. private _padSensibilityDown;
  56773. private _leftController;
  56774. private _rightController;
  56775. private _gazeColor;
  56776. private _laserColor;
  56777. private _pickedLaserColor;
  56778. private _pickedGazeColor;
  56779. /**
  56780. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  56781. */
  56782. onNewMeshSelected: Observable<AbstractMesh>;
  56783. /**
  56784. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  56785. * This observable will provide the mesh and the controller used to select the mesh
  56786. */
  56787. onMeshSelectedWithController: Observable<{
  56788. mesh: AbstractMesh;
  56789. controller: WebVRController;
  56790. }>;
  56791. /**
  56792. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  56793. */
  56794. onNewMeshPicked: Observable<PickingInfo>;
  56795. private _circleEase;
  56796. /**
  56797. * Observable raised before camera teleportation
  56798. */
  56799. onBeforeCameraTeleport: Observable<Vector3>;
  56800. /**
  56801. * Observable raised after camera teleportation
  56802. */
  56803. onAfterCameraTeleport: Observable<Vector3>;
  56804. /**
  56805. * Observable raised when current selected mesh gets unselected
  56806. */
  56807. onSelectedMeshUnselected: Observable<AbstractMesh>;
  56808. private _raySelectionPredicate;
  56809. /**
  56810. * To be optionally changed by user to define custom ray selection
  56811. */
  56812. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56813. /**
  56814. * To be optionally changed by user to define custom selection logic (after ray selection)
  56815. */
  56816. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56817. /**
  56818. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  56819. */
  56820. teleportationEnabled: boolean;
  56821. private _defaultHeight;
  56822. private _teleportationInitialized;
  56823. private _interactionsEnabled;
  56824. private _interactionsRequested;
  56825. private _displayGaze;
  56826. private _displayLaserPointer;
  56827. /**
  56828. * The mesh used to display where the user is going to teleport.
  56829. */
  56830. get teleportationTarget(): Mesh;
  56831. /**
  56832. * Sets the mesh to be used to display where the user is going to teleport.
  56833. */
  56834. set teleportationTarget(value: Mesh);
  56835. /**
  56836. * 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
  56837. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  56838. * See https://doc.babylonjs.com/resources/baking_transformations
  56839. */
  56840. get gazeTrackerMesh(): Mesh;
  56841. set gazeTrackerMesh(value: Mesh);
  56842. /**
  56843. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  56844. */
  56845. updateGazeTrackerScale: boolean;
  56846. /**
  56847. * If the gaze trackers color should be updated when selecting meshes
  56848. */
  56849. updateGazeTrackerColor: boolean;
  56850. /**
  56851. * If the controller laser color should be updated when selecting meshes
  56852. */
  56853. updateControllerLaserColor: boolean;
  56854. /**
  56855. * The gaze tracking mesh corresponding to the left controller
  56856. */
  56857. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  56858. /**
  56859. * The gaze tracking mesh corresponding to the right controller
  56860. */
  56861. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  56862. /**
  56863. * If the ray of the gaze should be displayed.
  56864. */
  56865. get displayGaze(): boolean;
  56866. /**
  56867. * Sets if the ray of the gaze should be displayed.
  56868. */
  56869. set displayGaze(value: boolean);
  56870. /**
  56871. * If the ray of the LaserPointer should be displayed.
  56872. */
  56873. get displayLaserPointer(): boolean;
  56874. /**
  56875. * Sets if the ray of the LaserPointer should be displayed.
  56876. */
  56877. set displayLaserPointer(value: boolean);
  56878. /**
  56879. * The deviceOrientationCamera used as the camera when not in VR.
  56880. */
  56881. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  56882. /**
  56883. * Based on the current WebVR support, returns the current VR camera used.
  56884. */
  56885. get currentVRCamera(): Nullable<Camera>;
  56886. /**
  56887. * The webVRCamera which is used when in VR.
  56888. */
  56889. get webVRCamera(): WebVRFreeCamera;
  56890. /**
  56891. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  56892. */
  56893. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  56894. /**
  56895. * The html button that is used to trigger entering into VR.
  56896. */
  56897. get vrButton(): Nullable<HTMLButtonElement>;
  56898. private get _teleportationRequestInitiated();
  56899. /**
  56900. * Defines whether or not Pointer lock should be requested when switching to
  56901. * full screen.
  56902. */
  56903. requestPointerLockOnFullScreen: boolean;
  56904. /**
  56905. * If asking to force XR, this will be populated with the default xr experience
  56906. */
  56907. xr: WebXRDefaultExperience;
  56908. /**
  56909. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  56910. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  56911. */
  56912. xrTestDone: boolean;
  56913. /**
  56914. * Instantiates a VRExperienceHelper.
  56915. * Helps to quickly add VR support to an existing scene.
  56916. * @param scene The scene the VRExperienceHelper belongs to.
  56917. * @param webVROptions Options to modify the vr experience helper's behavior.
  56918. */
  56919. constructor(scene: Scene,
  56920. /** Options to modify the vr experience helper's behavior. */
  56921. webVROptions?: VRExperienceHelperOptions);
  56922. private completeVRInit;
  56923. private _onDefaultMeshLoaded;
  56924. private _onResize;
  56925. private _onFullscreenChange;
  56926. /**
  56927. * Gets a value indicating if we are currently in VR mode.
  56928. */
  56929. get isInVRMode(): boolean;
  56930. private onVrDisplayPresentChange;
  56931. private onVRDisplayChanged;
  56932. private moveButtonToBottomRight;
  56933. private displayVRButton;
  56934. private updateButtonVisibility;
  56935. private _cachedAngularSensibility;
  56936. /**
  56937. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  56938. * Otherwise, will use the fullscreen API.
  56939. */
  56940. enterVR(): void;
  56941. /**
  56942. * Attempt to exit VR, or fullscreen.
  56943. */
  56944. exitVR(): void;
  56945. /**
  56946. * The position of the vr experience helper.
  56947. */
  56948. get position(): Vector3;
  56949. /**
  56950. * Sets the position of the vr experience helper.
  56951. */
  56952. set position(value: Vector3);
  56953. /**
  56954. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  56955. */
  56956. enableInteractions(): void;
  56957. private get _noControllerIsActive();
  56958. private beforeRender;
  56959. private _isTeleportationFloor;
  56960. /**
  56961. * Adds a floor mesh to be used for teleportation.
  56962. * @param floorMesh the mesh to be used for teleportation.
  56963. */
  56964. addFloorMesh(floorMesh: Mesh): void;
  56965. /**
  56966. * Removes a floor mesh from being used for teleportation.
  56967. * @param floorMesh the mesh to be removed.
  56968. */
  56969. removeFloorMesh(floorMesh: Mesh): void;
  56970. /**
  56971. * Enables interactions and teleportation using the VR controllers and gaze.
  56972. * @param vrTeleportationOptions options to modify teleportation behavior.
  56973. */
  56974. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  56975. private _onNewGamepadConnected;
  56976. private _tryEnableInteractionOnController;
  56977. private _onNewGamepadDisconnected;
  56978. private _enableInteractionOnController;
  56979. private _checkTeleportWithRay;
  56980. private _checkRotate;
  56981. private _checkTeleportBackwards;
  56982. private _enableTeleportationOnController;
  56983. private _createTeleportationCircles;
  56984. private _displayTeleportationTarget;
  56985. private _hideTeleportationTarget;
  56986. private _rotateCamera;
  56987. private _moveTeleportationSelectorTo;
  56988. private _workingVector;
  56989. private _workingQuaternion;
  56990. private _workingMatrix;
  56991. /**
  56992. * Time Constant Teleportation Mode
  56993. */
  56994. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  56995. /**
  56996. * Speed Constant Teleportation Mode
  56997. */
  56998. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  56999. /**
  57000. * Teleports the users feet to the desired location
  57001. * @param location The location where the user's feet should be placed
  57002. */
  57003. teleportCamera(location: Vector3): void;
  57004. private _convertNormalToDirectionOfRay;
  57005. private _castRayAndSelectObject;
  57006. private _notifySelectedMeshUnselected;
  57007. /**
  57008. * Permanently set new colors for the laser pointer
  57009. * @param color the new laser color
  57010. * @param pickedColor the new laser color when picked mesh detected
  57011. */
  57012. setLaserColor(color: Color3, pickedColor?: Color3): void;
  57013. /**
  57014. * Set lighting enabled / disabled on the laser pointer of both controllers
  57015. * @param enabled should the lighting be enabled on the laser pointer
  57016. */
  57017. setLaserLightingState(enabled?: boolean): void;
  57018. /**
  57019. * Permanently set new colors for the gaze pointer
  57020. * @param color the new gaze color
  57021. * @param pickedColor the new gaze color when picked mesh detected
  57022. */
  57023. setGazeColor(color: Color3, pickedColor?: Color3): void;
  57024. /**
  57025. * Sets the color of the laser ray from the vr controllers.
  57026. * @param color new color for the ray.
  57027. */
  57028. changeLaserColor(color: Color3): void;
  57029. /**
  57030. * Sets the color of the ray from the vr headsets gaze.
  57031. * @param color new color for the ray.
  57032. */
  57033. changeGazeColor(color: Color3): void;
  57034. /**
  57035. * Exits VR and disposes of the vr experience helper
  57036. */
  57037. dispose(): void;
  57038. /**
  57039. * Gets the name of the VRExperienceHelper class
  57040. * @returns "VRExperienceHelper"
  57041. */
  57042. getClassName(): string;
  57043. }
  57044. }
  57045. declare module BABYLON {
  57046. /**
  57047. * Contains an array of blocks representing the octree
  57048. */
  57049. export interface IOctreeContainer<T> {
  57050. /**
  57051. * Blocks within the octree
  57052. */
  57053. blocks: Array<OctreeBlock<T>>;
  57054. }
  57055. /**
  57056. * Class used to store a cell in an octree
  57057. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57058. */
  57059. export class OctreeBlock<T> {
  57060. /**
  57061. * Gets the content of the current block
  57062. */
  57063. entries: T[];
  57064. /**
  57065. * Gets the list of block children
  57066. */
  57067. blocks: Array<OctreeBlock<T>>;
  57068. private _depth;
  57069. private _maxDepth;
  57070. private _capacity;
  57071. private _minPoint;
  57072. private _maxPoint;
  57073. private _boundingVectors;
  57074. private _creationFunc;
  57075. /**
  57076. * Creates a new block
  57077. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  57078. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  57079. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57080. * @param depth defines the current depth of this block in the octree
  57081. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  57082. * @param creationFunc defines a callback to call when an element is added to the block
  57083. */
  57084. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  57085. /**
  57086. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57087. */
  57088. get capacity(): number;
  57089. /**
  57090. * Gets the minimum vector (in world space) of the block's bounding box
  57091. */
  57092. get minPoint(): Vector3;
  57093. /**
  57094. * Gets the maximum vector (in world space) of the block's bounding box
  57095. */
  57096. get maxPoint(): Vector3;
  57097. /**
  57098. * Add a new element to this block
  57099. * @param entry defines the element to add
  57100. */
  57101. addEntry(entry: T): void;
  57102. /**
  57103. * Remove an element from this block
  57104. * @param entry defines the element to remove
  57105. */
  57106. removeEntry(entry: T): void;
  57107. /**
  57108. * Add an array of elements to this block
  57109. * @param entries defines the array of elements to add
  57110. */
  57111. addEntries(entries: T[]): void;
  57112. /**
  57113. * Test if the current block intersects the frustum planes and if yes, then add its content to the selection array
  57114. * @param frustumPlanes defines the frustum planes to test
  57115. * @param selection defines the array to store current content if selection is positive
  57116. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57117. */
  57118. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57119. /**
  57120. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  57121. * @param sphereCenter defines the bounding sphere center
  57122. * @param sphereRadius defines the bounding sphere radius
  57123. * @param selection defines the array to store current content if selection is positive
  57124. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57125. */
  57126. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57127. /**
  57128. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  57129. * @param ray defines the ray to test with
  57130. * @param selection defines the array to store current content if selection is positive
  57131. */
  57132. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  57133. /**
  57134. * Subdivide the content into child blocks (this block will then be empty)
  57135. */
  57136. createInnerBlocks(): void;
  57137. /**
  57138. * @hidden
  57139. */
  57140. 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;
  57141. }
  57142. }
  57143. declare module BABYLON {
  57144. /**
  57145. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  57146. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57147. */
  57148. export class Octree<T> {
  57149. /** 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.) */
  57150. maxDepth: number;
  57151. /**
  57152. * Blocks within the octree containing objects
  57153. */
  57154. blocks: Array<OctreeBlock<T>>;
  57155. /**
  57156. * Content stored in the octree
  57157. */
  57158. dynamicContent: T[];
  57159. private _maxBlockCapacity;
  57160. private _selectionContent;
  57161. private _creationFunc;
  57162. /**
  57163. * Creates a octree
  57164. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57165. * @param creationFunc function to be used to instantiate the octree
  57166. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  57167. * @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.)
  57168. */
  57169. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  57170. /** 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.) */
  57171. maxDepth?: number);
  57172. /**
  57173. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  57174. * @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);
  57175. * @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);
  57176. * @param entries meshes to be added to the octree blocks
  57177. */
  57178. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  57179. /**
  57180. * Adds a mesh to the octree
  57181. * @param entry Mesh to add to the octree
  57182. */
  57183. addMesh(entry: T): void;
  57184. /**
  57185. * Remove an element from the octree
  57186. * @param entry defines the element to remove
  57187. */
  57188. removeMesh(entry: T): void;
  57189. /**
  57190. * Selects an array of meshes within the frustum
  57191. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  57192. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  57193. * @returns array of meshes within the frustum
  57194. */
  57195. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  57196. /**
  57197. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  57198. * @param sphereCenter defines the bounding sphere center
  57199. * @param sphereRadius defines the bounding sphere radius
  57200. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57201. * @returns an array of objects that intersect the sphere
  57202. */
  57203. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  57204. /**
  57205. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  57206. * @param ray defines the ray to test with
  57207. * @returns array of intersected objects
  57208. */
  57209. intersectsRay(ray: Ray): SmartArray<T>;
  57210. /**
  57211. * Adds a mesh into the octree block if it intersects the block
  57212. */
  57213. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  57214. /**
  57215. * Adds a submesh into the octree block if it intersects the block
  57216. */
  57217. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  57218. }
  57219. }
  57220. declare module BABYLON {
  57221. interface Scene {
  57222. /**
  57223. * @hidden
  57224. * Backing Filed
  57225. */
  57226. _selectionOctree: Octree<AbstractMesh>;
  57227. /**
  57228. * Gets the octree used to boost mesh selection (picking)
  57229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57230. */
  57231. selectionOctree: Octree<AbstractMesh>;
  57232. /**
  57233. * Creates or updates the octree used to boost selection (picking)
  57234. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57235. * @param maxCapacity defines the maximum capacity per leaf
  57236. * @param maxDepth defines the maximum depth of the octree
  57237. * @returns an octree of AbstractMesh
  57238. */
  57239. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  57240. }
  57241. interface AbstractMesh {
  57242. /**
  57243. * @hidden
  57244. * Backing Field
  57245. */
  57246. _submeshesOctree: Octree<SubMesh>;
  57247. /**
  57248. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  57249. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  57250. * @param maxCapacity defines the maximum size of each block (64 by default)
  57251. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  57252. * @returns the new octree
  57253. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  57254. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57255. */
  57256. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  57257. }
  57258. /**
  57259. * Defines the octree scene component responsible to manage any octrees
  57260. * in a given scene.
  57261. */
  57262. export class OctreeSceneComponent {
  57263. /**
  57264. * The component name help to identify the component in the list of scene components.
  57265. */
  57266. readonly name: string;
  57267. /**
  57268. * The scene the component belongs to.
  57269. */
  57270. scene: Scene;
  57271. /**
  57272. * Indicates if the meshes have been checked to make sure they are isEnabled()
  57273. */
  57274. readonly checksIsEnabled: boolean;
  57275. /**
  57276. * Creates a new instance of the component for the given scene
  57277. * @param scene Defines the scene to register the component in
  57278. */
  57279. constructor(scene: Scene);
  57280. /**
  57281. * Registers the component in a given scene
  57282. */
  57283. register(): void;
  57284. /**
  57285. * Return the list of active meshes
  57286. * @returns the list of active meshes
  57287. */
  57288. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  57289. /**
  57290. * Return the list of active sub meshes
  57291. * @param mesh The mesh to get the candidates sub meshes from
  57292. * @returns the list of active sub meshes
  57293. */
  57294. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  57295. private _tempRay;
  57296. /**
  57297. * Return the list of sub meshes intersecting with a given local ray
  57298. * @param mesh defines the mesh to find the submesh for
  57299. * @param localRay defines the ray in local space
  57300. * @returns the list of intersecting sub meshes
  57301. */
  57302. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  57303. /**
  57304. * Return the list of sub meshes colliding with a collider
  57305. * @param mesh defines the mesh to find the submesh for
  57306. * @param collider defines the collider to evaluate the collision against
  57307. * @returns the list of colliding sub meshes
  57308. */
  57309. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  57310. /**
  57311. * Rebuilds the elements related to this component in case of
  57312. * context lost for instance.
  57313. */
  57314. rebuild(): void;
  57315. /**
  57316. * Disposes the component and the associated resources.
  57317. */
  57318. dispose(): void;
  57319. }
  57320. }
  57321. declare module BABYLON {
  57322. /**
  57323. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  57324. */
  57325. export interface GizmoAxisCache {
  57326. /** Mesh used to render the Gizmo */
  57327. gizmoMeshes: Mesh[];
  57328. /** Mesh used to detect user interaction with Gizmo */
  57329. colliderMeshes: Mesh[];
  57330. /** Material used to indicate color of gizmo mesh */
  57331. material: StandardMaterial;
  57332. /** Material used to indicate hover state of the Gizmo */
  57333. hoverMaterial: StandardMaterial;
  57334. /** Material used to indicate disabled state of the Gizmo */
  57335. disableMaterial: StandardMaterial;
  57336. /** Used to indicate Active state of the Gizmo */
  57337. active: boolean;
  57338. }
  57339. /**
  57340. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  57341. */
  57342. export class Gizmo implements IDisposable {
  57343. /** The utility layer the gizmo will be added to */
  57344. gizmoLayer: UtilityLayerRenderer;
  57345. /**
  57346. * The root mesh of the gizmo
  57347. */
  57348. _rootMesh: Mesh;
  57349. private _attachedMesh;
  57350. private _attachedNode;
  57351. /**
  57352. * Ratio for the scale of the gizmo (Default: 1)
  57353. */
  57354. protected _scaleRatio: number;
  57355. /**
  57356. * boolean updated by pointermove when a gizmo mesh is hovered
  57357. */
  57358. protected _isHovered: boolean;
  57359. /**
  57360. * Ratio for the scale of the gizmo (Default: 1)
  57361. */
  57362. set scaleRatio(value: number);
  57363. get scaleRatio(): number;
  57364. /**
  57365. * True when the mouse pointer is hovered a gizmo mesh
  57366. */
  57367. get isHovered(): boolean;
  57368. /**
  57369. * If a custom mesh has been set (Default: false)
  57370. */
  57371. protected _customMeshSet: boolean;
  57372. /**
  57373. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  57374. * * When set, interactions will be enabled
  57375. */
  57376. get attachedMesh(): Nullable<AbstractMesh>;
  57377. set attachedMesh(value: Nullable<AbstractMesh>);
  57378. /**
  57379. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  57380. * * When set, interactions will be enabled
  57381. */
  57382. get attachedNode(): Nullable<Node>;
  57383. set attachedNode(value: Nullable<Node>);
  57384. /**
  57385. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57386. * @param mesh The mesh to replace the default mesh of the gizmo
  57387. */
  57388. setCustomMesh(mesh: Mesh): void;
  57389. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  57390. /**
  57391. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  57392. */
  57393. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57394. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57395. /**
  57396. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  57397. */
  57398. updateGizmoPositionToMatchAttachedMesh: boolean;
  57399. /**
  57400. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  57401. */
  57402. updateScale: boolean;
  57403. protected _interactionsEnabled: boolean;
  57404. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57405. private _beforeRenderObserver;
  57406. private _tempQuaternion;
  57407. private _tempVector;
  57408. private _tempVector2;
  57409. private _tempMatrix1;
  57410. private _tempMatrix2;
  57411. private _rightHandtoLeftHandMatrix;
  57412. /**
  57413. * Creates a gizmo
  57414. * @param gizmoLayer The utility layer the gizmo will be added to
  57415. */
  57416. constructor(
  57417. /** The utility layer the gizmo will be added to */
  57418. gizmoLayer?: UtilityLayerRenderer);
  57419. /**
  57420. * Updates the gizmo to match the attached mesh's position/rotation
  57421. */
  57422. protected _update(): void;
  57423. /**
  57424. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  57425. * @param value Node, TransformNode or mesh
  57426. */
  57427. protected _matrixChanged(): void;
  57428. /**
  57429. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  57430. * @param gizmoLayer The utility layer the gizmo will be added to
  57431. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57432. * @returns {Observer<PointerInfo>} pointerObserver
  57433. */
  57434. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  57435. /**
  57436. * Disposes of the gizmo
  57437. */
  57438. dispose(): void;
  57439. }
  57440. }
  57441. declare module BABYLON {
  57442. /**
  57443. * Single plane drag gizmo
  57444. */
  57445. export class PlaneDragGizmo extends Gizmo {
  57446. /**
  57447. * Drag behavior responsible for the gizmos dragging interactions
  57448. */
  57449. dragBehavior: PointerDragBehavior;
  57450. private _pointerObserver;
  57451. /**
  57452. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57453. */
  57454. snapDistance: number;
  57455. /**
  57456. * Event that fires each time the gizmo snaps to a new location.
  57457. * * snapDistance is the the change in distance
  57458. */
  57459. onSnapObservable: Observable<{
  57460. snapDistance: number;
  57461. }>;
  57462. private _gizmoMesh;
  57463. private _coloredMaterial;
  57464. private _hoverMaterial;
  57465. private _disableMaterial;
  57466. private _isEnabled;
  57467. private _parent;
  57468. private _dragging;
  57469. /** @hidden */
  57470. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  57471. /**
  57472. * Creates a PlaneDragGizmo
  57473. * @param gizmoLayer The utility layer the gizmo will be added to
  57474. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  57475. * @param color The color of the gizmo
  57476. */
  57477. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  57478. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57479. /**
  57480. * If the gizmo is enabled
  57481. */
  57482. set isEnabled(value: boolean);
  57483. get isEnabled(): boolean;
  57484. /**
  57485. * Disposes of the gizmo
  57486. */
  57487. dispose(): void;
  57488. }
  57489. }
  57490. declare module BABYLON {
  57491. /**
  57492. * Single plane rotation gizmo
  57493. */
  57494. export class PlaneRotationGizmo extends Gizmo {
  57495. /**
  57496. * Drag behavior responsible for the gizmos dragging interactions
  57497. */
  57498. dragBehavior: PointerDragBehavior;
  57499. private _pointerObserver;
  57500. /**
  57501. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57502. */
  57503. snapDistance: number;
  57504. /**
  57505. * Event that fires each time the gizmo snaps to a new location.
  57506. * * snapDistance is the the change in distance
  57507. */
  57508. onSnapObservable: Observable<{
  57509. snapDistance: number;
  57510. }>;
  57511. private _isEnabled;
  57512. private _parent;
  57513. private _coloredMaterial;
  57514. private _hoverMaterial;
  57515. private _disableMaterial;
  57516. private _gizmoMesh;
  57517. private _rotationCircle;
  57518. private _dragging;
  57519. private static _CircleConstants;
  57520. /**
  57521. * Creates a PlaneRotationGizmo
  57522. * @param gizmoLayer The utility layer the gizmo will be added to
  57523. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57524. * @param color The color of the gizmo
  57525. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57526. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57527. * @param thickness display gizmo axis thickness
  57528. */
  57529. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57530. /** Create Geometry for Gizmo */
  57531. private _createGizmoMesh;
  57532. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57533. private setupRotationCircle;
  57534. private updateRotationPath;
  57535. private updateRotationCircle;
  57536. /**
  57537. * If the gizmo is enabled
  57538. */
  57539. set isEnabled(value: boolean);
  57540. get isEnabled(): boolean;
  57541. /**
  57542. * Disposes of the gizmo
  57543. */
  57544. dispose(): void;
  57545. }
  57546. }
  57547. declare module BABYLON {
  57548. /**
  57549. * Gizmo that enables rotating a mesh along 3 axis
  57550. */
  57551. export class RotationGizmo extends Gizmo {
  57552. /**
  57553. * Internal gizmo used for interactions on the x axis
  57554. */
  57555. xGizmo: PlaneRotationGizmo;
  57556. /**
  57557. * Internal gizmo used for interactions on the y axis
  57558. */
  57559. yGizmo: PlaneRotationGizmo;
  57560. /**
  57561. * Internal gizmo used for interactions on the z axis
  57562. */
  57563. zGizmo: PlaneRotationGizmo;
  57564. /** Fires an event when any of it's sub gizmos are dragged */
  57565. onDragStartObservable: Observable<unknown>;
  57566. /** Fires an event when any of it's sub gizmos are released from dragging */
  57567. onDragEndObservable: Observable<unknown>;
  57568. private _meshAttached;
  57569. private _nodeAttached;
  57570. private _observables;
  57571. /** Node Caching for quick lookup */
  57572. private _gizmoAxisCache;
  57573. get attachedMesh(): Nullable<AbstractMesh>;
  57574. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57575. get attachedNode(): Nullable<Node>;
  57576. set attachedNode(node: Nullable<Node>);
  57577. protected _checkBillboardTransform(): void;
  57578. /**
  57579. * True when the mouse pointer is hovering a gizmo mesh
  57580. */
  57581. get isHovered(): boolean;
  57582. /**
  57583. * Creates a RotationGizmo
  57584. * @param gizmoLayer The utility layer the gizmo will be added to
  57585. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57586. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57587. * @param thickness display gizmo axis thickness
  57588. */
  57589. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57590. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57591. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57592. /**
  57593. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57594. */
  57595. set snapDistance(value: number);
  57596. get snapDistance(): number;
  57597. /**
  57598. * Ratio for the scale of the gizmo (Default: 1)
  57599. */
  57600. set scaleRatio(value: number);
  57601. get scaleRatio(): number;
  57602. /**
  57603. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57604. * @param mesh Axis gizmo mesh
  57605. * @param cache Gizmo axis definition used for reactive gizmo UI
  57606. */
  57607. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57608. /**
  57609. * Disposes of the gizmo
  57610. */
  57611. dispose(): void;
  57612. /**
  57613. * CustomMeshes are not supported by this gizmo
  57614. * @param mesh The mesh to replace the default mesh of the gizmo
  57615. */
  57616. setCustomMesh(mesh: Mesh): void;
  57617. }
  57618. }
  57619. declare module BABYLON {
  57620. /**
  57621. * Class containing static functions to help procedurally build meshes
  57622. */
  57623. export class PolyhedronBuilder {
  57624. /**
  57625. * Creates a polyhedron mesh
  57626. * * 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
  57627. * * The parameter `size` (positive float, default 1) sets the polygon size
  57628. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57629. * * 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 overrides the parameter `type`
  57630. * * 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
  57631. * * 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)`)
  57632. * * 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 : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57633. * * 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
  57634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57635. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57637. * @param name defines the name of the mesh
  57638. * @param options defines the options used to create the mesh
  57639. * @param scene defines the hosting scene
  57640. * @returns the polyhedron mesh
  57641. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57642. */
  57643. static CreatePolyhedron(name: string, options: {
  57644. type?: number;
  57645. size?: number;
  57646. sizeX?: number;
  57647. sizeY?: number;
  57648. sizeZ?: number;
  57649. custom?: any;
  57650. faceUV?: Vector4[];
  57651. faceColors?: Color4[];
  57652. flat?: boolean;
  57653. updatable?: boolean;
  57654. sideOrientation?: number;
  57655. frontUVs?: Vector4;
  57656. backUVs?: Vector4;
  57657. }, scene?: Nullable<Scene>): Mesh;
  57658. }
  57659. }
  57660. declare module BABYLON {
  57661. /**
  57662. * Class containing static functions to help procedurally build meshes
  57663. */
  57664. export class BoxBuilder {
  57665. /**
  57666. * Creates a box mesh
  57667. * * The parameter `size` sets the size (float) of each box side (default 1)
  57668. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57669. * * 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)
  57670. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57672. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57674. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57675. * @param name defines the name of the mesh
  57676. * @param options defines the options used to create the mesh
  57677. * @param scene defines the hosting scene
  57678. * @returns the box mesh
  57679. */
  57680. static CreateBox(name: string, options: {
  57681. size?: number;
  57682. width?: number;
  57683. height?: number;
  57684. depth?: number;
  57685. faceUV?: Vector4[];
  57686. faceColors?: Color4[];
  57687. sideOrientation?: number;
  57688. frontUVs?: Vector4;
  57689. backUVs?: Vector4;
  57690. wrap?: boolean;
  57691. topBaseAt?: number;
  57692. bottomBaseAt?: number;
  57693. updatable?: boolean;
  57694. }, scene?: Nullable<Scene>): Mesh;
  57695. }
  57696. }
  57697. declare module BABYLON {
  57698. /**
  57699. * Single axis scale gizmo
  57700. */
  57701. export class AxisScaleGizmo extends Gizmo {
  57702. /**
  57703. * Drag behavior responsible for the gizmos dragging interactions
  57704. */
  57705. dragBehavior: PointerDragBehavior;
  57706. private _pointerObserver;
  57707. /**
  57708. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57709. */
  57710. snapDistance: number;
  57711. /**
  57712. * Event that fires each time the gizmo snaps to a new location.
  57713. * * snapDistance is the the change in distance
  57714. */
  57715. onSnapObservable: Observable<{
  57716. snapDistance: number;
  57717. }>;
  57718. /**
  57719. * If the scaling operation should be done on all axis (default: false)
  57720. */
  57721. uniformScaling: boolean;
  57722. /**
  57723. * Custom sensitivity value for the drag strength
  57724. */
  57725. sensitivity: number;
  57726. private _isEnabled;
  57727. private _parent;
  57728. private _gizmoMesh;
  57729. private _coloredMaterial;
  57730. private _hoverMaterial;
  57731. private _disableMaterial;
  57732. private _dragging;
  57733. private _tmpVector;
  57734. private _tmpMatrix;
  57735. private _tmpMatrix2;
  57736. /**
  57737. * Creates an AxisScaleGizmo
  57738. * @param gizmoLayer The utility layer the gizmo will be added to
  57739. * @param dragAxis The axis which the gizmo will be able to scale on
  57740. * @param color The color of the gizmo
  57741. * @param thickness display gizmo axis thickness
  57742. */
  57743. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57744. /** Create Geometry for Gizmo */
  57745. private _createGizmoMesh;
  57746. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57747. /**
  57748. * If the gizmo is enabled
  57749. */
  57750. set isEnabled(value: boolean);
  57751. get isEnabled(): boolean;
  57752. /**
  57753. * Disposes of the gizmo
  57754. */
  57755. dispose(): void;
  57756. /**
  57757. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57758. * @param mesh The mesh to replace the default mesh of the gizmo
  57759. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57760. */
  57761. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57762. }
  57763. }
  57764. declare module BABYLON {
  57765. /**
  57766. * Gizmo that enables scaling a mesh along 3 axis
  57767. */
  57768. export class ScaleGizmo extends Gizmo {
  57769. /**
  57770. * Internal gizmo used for interactions on the x axis
  57771. */
  57772. xGizmo: AxisScaleGizmo;
  57773. /**
  57774. * Internal gizmo used for interactions on the y axis
  57775. */
  57776. yGizmo: AxisScaleGizmo;
  57777. /**
  57778. * Internal gizmo used for interactions on the z axis
  57779. */
  57780. zGizmo: AxisScaleGizmo;
  57781. /**
  57782. * Internal gizmo used to scale all axis equally
  57783. */
  57784. uniformScaleGizmo: AxisScaleGizmo;
  57785. private _meshAttached;
  57786. private _nodeAttached;
  57787. private _snapDistance;
  57788. private _uniformScalingMesh;
  57789. private _octahedron;
  57790. private _sensitivity;
  57791. private _coloredMaterial;
  57792. private _hoverMaterial;
  57793. private _disableMaterial;
  57794. private _observables;
  57795. /** Node Caching for quick lookup */
  57796. private _gizmoAxisCache;
  57797. /** Fires an event when any of it's sub gizmos are dragged */
  57798. onDragStartObservable: Observable<unknown>;
  57799. /** Fires an event when any of it's sub gizmos are released from dragging */
  57800. onDragEndObservable: Observable<unknown>;
  57801. get attachedMesh(): Nullable<AbstractMesh>;
  57802. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57803. get attachedNode(): Nullable<Node>;
  57804. set attachedNode(node: Nullable<Node>);
  57805. /**
  57806. * True when the mouse pointer is hovering a gizmo mesh
  57807. */
  57808. get isHovered(): boolean;
  57809. /**
  57810. * Creates a ScaleGizmo
  57811. * @param gizmoLayer The utility layer the gizmo will be added to
  57812. * @param thickness display gizmo axis thickness
  57813. */
  57814. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57815. /** Create Geometry for Gizmo */
  57816. private _createUniformScaleMesh;
  57817. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57818. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57819. /**
  57820. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57821. */
  57822. set snapDistance(value: number);
  57823. get snapDistance(): number;
  57824. /**
  57825. * Ratio for the scale of the gizmo (Default: 1)
  57826. */
  57827. set scaleRatio(value: number);
  57828. get scaleRatio(): number;
  57829. /**
  57830. * Sensitivity factor for dragging (Default: 1)
  57831. */
  57832. set sensitivity(value: number);
  57833. get sensitivity(): number;
  57834. /**
  57835. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57836. * @param mesh Axis gizmo mesh
  57837. * @param cache Gizmo axis definition used for reactive gizmo UI
  57838. */
  57839. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57840. /**
  57841. * Disposes of the gizmo
  57842. */
  57843. dispose(): void;
  57844. }
  57845. }
  57846. declare module BABYLON {
  57847. /**
  57848. * Bounding box gizmo
  57849. */
  57850. export class BoundingBoxGizmo extends Gizmo {
  57851. private _lineBoundingBox;
  57852. private _rotateSpheresParent;
  57853. private _scaleBoxesParent;
  57854. private _boundingDimensions;
  57855. private _renderObserver;
  57856. private _pointerObserver;
  57857. private _scaleDragSpeed;
  57858. private _tmpQuaternion;
  57859. private _tmpVector;
  57860. private _tmpRotationMatrix;
  57861. /**
  57862. * If child meshes should be ignored when calculating the bounding box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  57863. */
  57864. ignoreChildren: boolean;
  57865. /**
  57866. * 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)
  57867. */
  57868. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57869. /**
  57870. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57871. */
  57872. rotationSphereSize: number;
  57873. /**
  57874. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57875. */
  57876. scaleBoxSize: number;
  57877. /**
  57878. * 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)
  57879. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57880. */
  57881. fixedDragMeshScreenSize: boolean;
  57882. /**
  57883. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  57884. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57885. */
  57886. fixedDragMeshBoundsSize: boolean;
  57887. /**
  57888. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57889. */
  57890. fixedDragMeshScreenSizeDistanceFactor: number;
  57891. /**
  57892. * Fired when a rotation sphere or scale box is dragged
  57893. */
  57894. onDragStartObservable: Observable<{}>;
  57895. /**
  57896. * Fired when a scale box is dragged
  57897. */
  57898. onScaleBoxDragObservable: Observable<{}>;
  57899. /**
  57900. * Fired when a scale box drag is ended
  57901. */
  57902. onScaleBoxDragEndObservable: Observable<{}>;
  57903. /**
  57904. * Fired when a rotation sphere is dragged
  57905. */
  57906. onRotationSphereDragObservable: Observable<{}>;
  57907. /**
  57908. * Fired when a rotation sphere drag is ended
  57909. */
  57910. onRotationSphereDragEndObservable: Observable<{}>;
  57911. /**
  57912. * Relative bounding box pivot used when scaling the attached node. 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)
  57913. */
  57914. scalePivot: Nullable<Vector3>;
  57915. /**
  57916. * Mesh used as a pivot to rotate the attached node
  57917. */
  57918. private _anchorMesh;
  57919. private _existingMeshScale;
  57920. private _dragMesh;
  57921. private pointerDragBehavior;
  57922. private coloredMaterial;
  57923. private hoverColoredMaterial;
  57924. /**
  57925. * Sets the color of the bounding box gizmo
  57926. * @param color the color to set
  57927. */
  57928. setColor(color: Color3): void;
  57929. /**
  57930. * Creates an BoundingBoxGizmo
  57931. * @param gizmoLayer The utility layer the gizmo will be added to
  57932. * @param color The color of the gizmo
  57933. */
  57934. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57935. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57936. private _selectNode;
  57937. /**
  57938. * Updates the bounding box information for the Gizmo
  57939. */
  57940. updateBoundingBox(): void;
  57941. private _updateRotationSpheres;
  57942. private _updateScaleBoxes;
  57943. /**
  57944. * Enables rotation on the specified axis and disables rotation on the others
  57945. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57946. */
  57947. setEnabledRotationAxis(axis: string): void;
  57948. /**
  57949. * Enables/disables scaling
  57950. * @param enable if scaling should be enabled
  57951. * @param homogeneousScaling defines if scaling should only be homogeneous
  57952. */
  57953. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57954. private _updateDummy;
  57955. /**
  57956. * Enables a pointer drag behavior on the bounding box of the gizmo
  57957. */
  57958. enableDragBehavior(): void;
  57959. /**
  57960. * Disposes of the gizmo
  57961. */
  57962. dispose(): void;
  57963. /**
  57964. * 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)
  57965. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57966. * @returns the bounding box mesh with the passed in mesh as a child
  57967. */
  57968. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57969. /**
  57970. * CustomMeshes are not supported by this gizmo
  57971. * @param mesh The mesh to replace the default mesh of the gizmo
  57972. */
  57973. setCustomMesh(mesh: Mesh): void;
  57974. }
  57975. }
  57976. declare module BABYLON {
  57977. /**
  57978. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57979. */
  57980. export class GizmoManager implements IDisposable {
  57981. private scene;
  57982. /**
  57983. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57984. */
  57985. gizmos: {
  57986. positionGizmo: Nullable<PositionGizmo>;
  57987. rotationGizmo: Nullable<RotationGizmo>;
  57988. scaleGizmo: Nullable<ScaleGizmo>;
  57989. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57990. };
  57991. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57992. clearGizmoOnEmptyPointerEvent: boolean;
  57993. /** Fires an event when the manager is attached to a mesh */
  57994. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57995. /** Fires an event when the manager is attached to a node */
  57996. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57997. private _gizmosEnabled;
  57998. private _pointerObservers;
  57999. private _attachedMesh;
  58000. private _attachedNode;
  58001. private _boundingBoxColor;
  58002. private _defaultUtilityLayer;
  58003. private _defaultKeepDepthUtilityLayer;
  58004. private _thickness;
  58005. /** Node Caching for quick lookup */
  58006. private _gizmoAxisCache;
  58007. /**
  58008. * When bounding box gizmo is enabled, this can be used to track drag/end events
  58009. */
  58010. boundingBoxDragBehavior: SixDofDragBehavior;
  58011. /**
  58012. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  58013. */
  58014. attachableMeshes: Nullable<Array<AbstractMesh>>;
  58015. /**
  58016. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  58017. */
  58018. attachableNodes: Nullable<Array<Node>>;
  58019. /**
  58020. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  58021. */
  58022. usePointerToAttachGizmos: boolean;
  58023. /**
  58024. * Utility layer that the bounding box gizmo belongs to
  58025. */
  58026. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  58027. /**
  58028. * Utility layer that all gizmos besides bounding box belong to
  58029. */
  58030. get utilityLayer(): UtilityLayerRenderer;
  58031. /**
  58032. * True when the mouse pointer is hovering a gizmo mesh
  58033. */
  58034. get isHovered(): boolean;
  58035. /**
  58036. * Instantiates a gizmo manager
  58037. * @param scene the scene to overlay the gizmos on top of
  58038. * @param thickness display gizmo axis thickness
  58039. * @param utilityLayer the layer where gizmos are rendered
  58040. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  58041. */
  58042. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  58043. /**
  58044. * Subscribes to pointer down events, for attaching and detaching mesh
  58045. * @param scene The scene layer the observer will be added to
  58046. */
  58047. private _attachToMeshPointerObserver;
  58048. /**
  58049. * Attaches a set of gizmos to the specified mesh
  58050. * @param mesh The mesh the gizmo's should be attached to
  58051. */
  58052. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58053. /**
  58054. * Attaches a set of gizmos to the specified node
  58055. * @param node The node the gizmo's should be attached to
  58056. */
  58057. attachToNode(node: Nullable<Node>): void;
  58058. /**
  58059. * If the position gizmo is enabled
  58060. */
  58061. set positionGizmoEnabled(value: boolean);
  58062. get positionGizmoEnabled(): boolean;
  58063. /**
  58064. * If the rotation gizmo is enabled
  58065. */
  58066. set rotationGizmoEnabled(value: boolean);
  58067. get rotationGizmoEnabled(): boolean;
  58068. /**
  58069. * If the scale gizmo is enabled
  58070. */
  58071. set scaleGizmoEnabled(value: boolean);
  58072. get scaleGizmoEnabled(): boolean;
  58073. /**
  58074. * If the boundingBox gizmo is enabled
  58075. */
  58076. set boundingBoxGizmoEnabled(value: boolean);
  58077. get boundingBoxGizmoEnabled(): boolean;
  58078. /**
  58079. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58080. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  58081. */
  58082. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  58083. /**
  58084. * Disposes of the gizmo manager
  58085. */
  58086. dispose(): void;
  58087. }
  58088. }
  58089. declare module BABYLON {
  58090. /**
  58091. * Gizmo that enables dragging a mesh along 3 axis
  58092. */
  58093. export class PositionGizmo extends Gizmo {
  58094. /**
  58095. * Internal gizmo used for interactions on the x axis
  58096. */
  58097. xGizmo: AxisDragGizmo;
  58098. /**
  58099. * Internal gizmo used for interactions on the y axis
  58100. */
  58101. yGizmo: AxisDragGizmo;
  58102. /**
  58103. * Internal gizmo used for interactions on the z axis
  58104. */
  58105. zGizmo: AxisDragGizmo;
  58106. /**
  58107. * Internal gizmo used for interactions on the yz plane
  58108. */
  58109. xPlaneGizmo: PlaneDragGizmo;
  58110. /**
  58111. * Internal gizmo used for interactions on the xz plane
  58112. */
  58113. yPlaneGizmo: PlaneDragGizmo;
  58114. /**
  58115. * Internal gizmo used for interactions on the xy plane
  58116. */
  58117. zPlaneGizmo: PlaneDragGizmo;
  58118. /**
  58119. * private variables
  58120. */
  58121. private _meshAttached;
  58122. private _nodeAttached;
  58123. private _snapDistance;
  58124. private _observables;
  58125. /** Node Caching for quick lookup */
  58126. private _gizmoAxisCache;
  58127. /** Fires an event when any of it's sub gizmos are dragged */
  58128. onDragStartObservable: Observable<unknown>;
  58129. /** Fires an event when any of it's sub gizmos are released from dragging */
  58130. onDragEndObservable: Observable<unknown>;
  58131. /**
  58132. * If set to true, planar drag is enabled
  58133. */
  58134. private _planarGizmoEnabled;
  58135. get attachedMesh(): Nullable<AbstractMesh>;
  58136. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58137. get attachedNode(): Nullable<Node>;
  58138. set attachedNode(node: Nullable<Node>);
  58139. /**
  58140. * True when the mouse pointer is hovering a gizmo mesh
  58141. */
  58142. get isHovered(): boolean;
  58143. /**
  58144. * Creates a PositionGizmo
  58145. * @param gizmoLayer The utility layer the gizmo will be added to
  58146. @param thickness display gizmo axis thickness
  58147. */
  58148. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  58149. /**
  58150. * If the planar drag gizmo is enabled
  58151. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  58152. */
  58153. set planarGizmoEnabled(value: boolean);
  58154. get planarGizmoEnabled(): boolean;
  58155. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58156. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58157. /**
  58158. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58159. */
  58160. set snapDistance(value: number);
  58161. get snapDistance(): number;
  58162. /**
  58163. * Ratio for the scale of the gizmo (Default: 1)
  58164. */
  58165. set scaleRatio(value: number);
  58166. get scaleRatio(): number;
  58167. /**
  58168. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58169. * @param mesh Axis gizmo mesh
  58170. * @param cache Gizmo axis definition used for reactive gizmo UI
  58171. */
  58172. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58173. /**
  58174. * Disposes of the gizmo
  58175. */
  58176. dispose(): void;
  58177. /**
  58178. * CustomMeshes are not supported by this gizmo
  58179. * @param mesh The mesh to replace the default mesh of the gizmo
  58180. */
  58181. setCustomMesh(mesh: Mesh): void;
  58182. }
  58183. }
  58184. declare module BABYLON {
  58185. /**
  58186. * Single axis drag gizmo
  58187. */
  58188. export class AxisDragGizmo extends Gizmo {
  58189. /**
  58190. * Drag behavior responsible for the gizmos dragging interactions
  58191. */
  58192. dragBehavior: PointerDragBehavior;
  58193. private _pointerObserver;
  58194. /**
  58195. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58196. */
  58197. snapDistance: number;
  58198. /**
  58199. * Event that fires each time the gizmo snaps to a new location.
  58200. * * snapDistance is the the change in distance
  58201. */
  58202. onSnapObservable: Observable<{
  58203. snapDistance: number;
  58204. }>;
  58205. private _isEnabled;
  58206. private _parent;
  58207. private _gizmoMesh;
  58208. private _coloredMaterial;
  58209. private _hoverMaterial;
  58210. private _disableMaterial;
  58211. private _dragging;
  58212. /** @hidden */
  58213. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  58214. /** @hidden */
  58215. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  58216. /**
  58217. * Creates an AxisDragGizmo
  58218. * @param gizmoLayer The utility layer the gizmo will be added to
  58219. * @param dragAxis The axis which the gizmo will be able to drag on
  58220. * @param color The color of the gizmo
  58221. * @param thickness display gizmo axis thickness
  58222. */
  58223. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  58224. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58225. /**
  58226. * If the gizmo is enabled
  58227. */
  58228. set isEnabled(value: boolean);
  58229. get isEnabled(): boolean;
  58230. /**
  58231. * Disposes of the gizmo
  58232. */
  58233. dispose(): void;
  58234. }
  58235. }
  58236. declare module BABYLON.Debug {
  58237. /**
  58238. * The Axes viewer will show 3 axes in a specific point in space
  58239. */
  58240. export class AxesViewer {
  58241. private _xAxis;
  58242. private _yAxis;
  58243. private _zAxis;
  58244. private _scaleLinesFactor;
  58245. private _instanced;
  58246. /**
  58247. * Gets the hosting scene
  58248. */
  58249. scene: Nullable<Scene>;
  58250. /**
  58251. * Gets or sets a number used to scale line length
  58252. */
  58253. scaleLines: number;
  58254. /** Gets the node hierarchy used to render x-axis */
  58255. get xAxis(): TransformNode;
  58256. /** Gets the node hierarchy used to render y-axis */
  58257. get yAxis(): TransformNode;
  58258. /** Gets the node hierarchy used to render z-axis */
  58259. get zAxis(): TransformNode;
  58260. /**
  58261. * Creates a new AxesViewer
  58262. * @param scene defines the hosting scene
  58263. * @param scaleLines defines a number used to scale line length (1 by default)
  58264. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  58265. * @param xAxis defines the node hierarchy used to render the x-axis
  58266. * @param yAxis defines the node hierarchy used to render the y-axis
  58267. * @param zAxis defines the node hierarchy used to render the z-axis
  58268. */
  58269. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  58270. /**
  58271. * Force the viewer to update
  58272. * @param position defines the position of the viewer
  58273. * @param xaxis defines the x axis of the viewer
  58274. * @param yaxis defines the y axis of the viewer
  58275. * @param zaxis defines the z axis of the viewer
  58276. */
  58277. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  58278. /**
  58279. * Creates an instance of this axes viewer.
  58280. * @returns a new axes viewer with instanced meshes
  58281. */
  58282. createInstance(): AxesViewer;
  58283. /** Releases resources */
  58284. dispose(): void;
  58285. private static _SetRenderingGroupId;
  58286. }
  58287. }
  58288. declare module BABYLON.Debug {
  58289. /**
  58290. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  58291. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  58292. */
  58293. export class BoneAxesViewer extends AxesViewer {
  58294. /**
  58295. * Gets or sets the target mesh where to display the axes viewer
  58296. */
  58297. mesh: Nullable<Mesh>;
  58298. /**
  58299. * Gets or sets the target bone where to display the axes viewer
  58300. */
  58301. bone: Nullable<Bone>;
  58302. /** Gets current position */
  58303. pos: Vector3;
  58304. /** Gets direction of X axis */
  58305. xaxis: Vector3;
  58306. /** Gets direction of Y axis */
  58307. yaxis: Vector3;
  58308. /** Gets direction of Z axis */
  58309. zaxis: Vector3;
  58310. /**
  58311. * Creates a new BoneAxesViewer
  58312. * @param scene defines the hosting scene
  58313. * @param bone defines the target bone
  58314. * @param mesh defines the target mesh
  58315. * @param scaleLines defines a scaling factor for line length (1 by default)
  58316. */
  58317. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  58318. /**
  58319. * Force the viewer to update
  58320. */
  58321. update(): void;
  58322. /** Releases resources */
  58323. dispose(): void;
  58324. }
  58325. }
  58326. declare module BABYLON {
  58327. /**
  58328. * Interface used to define scene explorer extensibility option
  58329. */
  58330. export interface IExplorerExtensibilityOption {
  58331. /**
  58332. * Define the option label
  58333. */
  58334. label: string;
  58335. /**
  58336. * Defines the action to execute on click
  58337. */
  58338. action: (entity: any) => void;
  58339. }
  58340. /**
  58341. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  58342. */
  58343. export interface IExplorerExtensibilityGroup {
  58344. /**
  58345. * Defines a predicate to test if a given type mut be extended
  58346. */
  58347. predicate: (entity: any) => boolean;
  58348. /**
  58349. * Gets the list of options added to a type
  58350. */
  58351. entries: IExplorerExtensibilityOption[];
  58352. }
  58353. /**
  58354. * Interface used to define the options to use to create the Inspector
  58355. */
  58356. export interface IInspectorOptions {
  58357. /**
  58358. * Display in overlay mode (default: false)
  58359. */
  58360. overlay?: boolean;
  58361. /**
  58362. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  58363. */
  58364. globalRoot?: HTMLElement;
  58365. /**
  58366. * Display the Scene explorer
  58367. */
  58368. showExplorer?: boolean;
  58369. /**
  58370. * Display the property inspector
  58371. */
  58372. showInspector?: boolean;
  58373. /**
  58374. * Display in embed mode (both panes on the right)
  58375. */
  58376. embedMode?: boolean;
  58377. /**
  58378. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  58379. */
  58380. handleResize?: boolean;
  58381. /**
  58382. * Allow the panes to popup (default: true)
  58383. */
  58384. enablePopup?: boolean;
  58385. /**
  58386. * Allow the panes to be closed by users (default: true)
  58387. */
  58388. enableClose?: boolean;
  58389. /**
  58390. * Optional list of extensibility entries
  58391. */
  58392. explorerExtensibility?: IExplorerExtensibilityGroup[];
  58393. /**
  58394. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  58395. */
  58396. inspectorURL?: string;
  58397. /**
  58398. * Optional initial tab (default to DebugLayerTab.Properties)
  58399. */
  58400. initialTab?: DebugLayerTab;
  58401. }
  58402. interface Scene {
  58403. /**
  58404. * @hidden
  58405. * Backing field
  58406. */
  58407. _debugLayer: DebugLayer;
  58408. /**
  58409. * Gets the debug layer (aka Inspector) associated with the scene
  58410. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58411. */
  58412. debugLayer: DebugLayer;
  58413. }
  58414. /**
  58415. * Enum of inspector action tab
  58416. */
  58417. export enum DebugLayerTab {
  58418. /**
  58419. * Properties tag (default)
  58420. */
  58421. Properties = 0,
  58422. /**
  58423. * Debug tab
  58424. */
  58425. Debug = 1,
  58426. /**
  58427. * Statistics tab
  58428. */
  58429. Statistics = 2,
  58430. /**
  58431. * Tools tab
  58432. */
  58433. Tools = 3,
  58434. /**
  58435. * Settings tab
  58436. */
  58437. Settings = 4
  58438. }
  58439. /**
  58440. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58441. * what is happening in your scene
  58442. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58443. */
  58444. export class DebugLayer {
  58445. /**
  58446. * Define the url to get the inspector script from.
  58447. * By default it uses the babylonjs CDN.
  58448. * @ignoreNaming
  58449. */
  58450. static InspectorURL: string;
  58451. private _scene;
  58452. private BJSINSPECTOR;
  58453. private _onPropertyChangedObservable?;
  58454. /**
  58455. * Observable triggered when a property is changed through the inspector.
  58456. */
  58457. get onPropertyChangedObservable(): any;
  58458. /**
  58459. * Instantiates a new debug layer.
  58460. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58461. * what is happening in your scene
  58462. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58463. * @param scene Defines the scene to inspect
  58464. */
  58465. constructor(scene: Scene);
  58466. /** Creates the inspector window. */
  58467. private _createInspector;
  58468. /**
  58469. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  58470. * @param entity defines the entity to select
  58471. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  58472. */
  58473. select(entity: any, lineContainerTitles?: string | string[]): void;
  58474. /** Get the inspector from bundle or global */
  58475. private _getGlobalInspector;
  58476. /**
  58477. * Get if the inspector is visible or not.
  58478. * @returns true if visible otherwise, false
  58479. */
  58480. isVisible(): boolean;
  58481. /**
  58482. * Hide the inspector and close its window.
  58483. */
  58484. hide(): void;
  58485. /**
  58486. * Update the scene in the inspector
  58487. */
  58488. setAsActiveScene(): void;
  58489. /**
  58490. * Launch the debugLayer.
  58491. * @param config Define the configuration of the inspector
  58492. * @return a promise fulfilled when the debug layer is visible
  58493. */
  58494. show(config?: IInspectorOptions): Promise<DebugLayer>;
  58495. }
  58496. }
  58497. declare module BABYLON.Debug {
  58498. /**
  58499. * Used to show the physics impostor around the specific mesh
  58500. */
  58501. export class PhysicsViewer {
  58502. /** @hidden */
  58503. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  58504. /** @hidden */
  58505. protected _meshes: Array<Nullable<AbstractMesh>>;
  58506. /** @hidden */
  58507. protected _scene: Nullable<Scene>;
  58508. /** @hidden */
  58509. protected _numMeshes: number;
  58510. /** @hidden */
  58511. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  58512. private _renderFunction;
  58513. private _utilityLayer;
  58514. private _debugBoxMesh;
  58515. private _debugSphereMesh;
  58516. private _debugCylinderMesh;
  58517. private _debugMaterial;
  58518. private _debugMeshMeshes;
  58519. /**
  58520. * Creates a new PhysicsViewer
  58521. * @param scene defines the hosting scene
  58522. */
  58523. constructor(scene: Scene);
  58524. /** @hidden */
  58525. protected _updateDebugMeshes(): void;
  58526. /**
  58527. * Renders a specified physic impostor
  58528. * @param impostor defines the impostor to render
  58529. * @param targetMesh defines the mesh represented by the impostor
  58530. * @returns the new debug mesh used to render the impostor
  58531. */
  58532. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58533. /**
  58534. * Hides a specified physic impostor
  58535. * @param impostor defines the impostor to hide
  58536. */
  58537. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58538. private _getDebugMaterial;
  58539. private _getDebugBoxMesh;
  58540. private _getDebugSphereMesh;
  58541. private _getDebugCylinderMesh;
  58542. private _getDebugMeshMesh;
  58543. private _getDebugMesh;
  58544. /** Releases all resources */
  58545. dispose(): void;
  58546. }
  58547. }
  58548. declare module BABYLON {
  58549. /**
  58550. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58551. * in order to better appreciate the issue one might have.
  58552. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58553. */
  58554. export class RayHelper {
  58555. /**
  58556. * Defines the ray we are currently tryin to visualize.
  58557. */
  58558. ray: Nullable<Ray>;
  58559. private _renderPoints;
  58560. private _renderLine;
  58561. private _renderFunction;
  58562. private _scene;
  58563. private _onAfterRenderObserver;
  58564. private _onAfterStepObserver;
  58565. private _attachedToMesh;
  58566. private _meshSpaceDirection;
  58567. private _meshSpaceOrigin;
  58568. /**
  58569. * Helper function to create a colored helper in a scene in one line.
  58570. * @param ray Defines the ray we are currently tryin to visualize
  58571. * @param scene Defines the scene the ray is used in
  58572. * @param color Defines the color we want to see the ray in
  58573. * @returns The newly created ray helper.
  58574. */
  58575. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58576. /**
  58577. * Instantiate a new ray helper.
  58578. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58579. * in order to better appreciate the issue one might have.
  58580. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58581. * @param ray Defines the ray we are currently tryin to visualize
  58582. */
  58583. constructor(ray: Ray);
  58584. /**
  58585. * Shows the ray we are willing to debug.
  58586. * @param scene Defines the scene the ray needs to be rendered in
  58587. * @param color Defines the color the ray needs to be rendered in
  58588. */
  58589. show(scene: Scene, color?: Color3): void;
  58590. /**
  58591. * Hides the ray we are debugging.
  58592. */
  58593. hide(): void;
  58594. private _render;
  58595. /**
  58596. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58597. * @param mesh Defines the mesh we want the helper attached to
  58598. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58599. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58600. * @param length Defines the length of the ray
  58601. */
  58602. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58603. /**
  58604. * Detach the ray helper from the mesh it has previously been attached to.
  58605. */
  58606. detachFromMesh(): void;
  58607. private _updateToMesh;
  58608. /**
  58609. * Dispose the helper and release its associated resources.
  58610. */
  58611. dispose(): void;
  58612. }
  58613. }
  58614. declare module BABYLON {
  58615. /**
  58616. * Defines the options associated with the creation of a SkeletonViewer.
  58617. */
  58618. export interface ISkeletonViewerOptions {
  58619. /** Should the system pause animations before building the Viewer? */
  58620. pauseAnimations: boolean;
  58621. /** Should the system return the skeleton to rest before building? */
  58622. returnToRest: boolean;
  58623. /** public Display Mode of the Viewer */
  58624. displayMode: number;
  58625. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58626. displayOptions: ISkeletonViewerDisplayOptions;
  58627. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58628. computeBonesUsingShaders: boolean;
  58629. /** Flag ignore non weighted bones */
  58630. useAllBones: boolean;
  58631. }
  58632. /**
  58633. * Defines how to display the various bone meshes for the viewer.
  58634. */
  58635. export interface ISkeletonViewerDisplayOptions {
  58636. /** How far down to start tapering the bone spurs */
  58637. midStep?: number;
  58638. /** How big is the midStep? */
  58639. midStepFactor?: number;
  58640. /** Base for the Sphere Size */
  58641. sphereBaseSize?: number;
  58642. /** The ratio of the sphere to the longest bone in units */
  58643. sphereScaleUnit?: number;
  58644. /** Ratio for the Sphere Size */
  58645. sphereFactor?: number;
  58646. /** Whether a spur should attach its far end to the child bone position */
  58647. spurFollowsChild?: boolean;
  58648. /** Whether to show local axes or not */
  58649. showLocalAxes?: boolean;
  58650. /** Length of each local axis */
  58651. localAxesSize?: number;
  58652. }
  58653. /**
  58654. * Defines the constructor options for the BoneWeight Shader.
  58655. */
  58656. export interface IBoneWeightShaderOptions {
  58657. /** Skeleton to Map */
  58658. skeleton: Skeleton;
  58659. /** Colors for Uninfluenced bones */
  58660. colorBase?: Color3;
  58661. /** Colors for 0.0-0.25 Weight bones */
  58662. colorZero?: Color3;
  58663. /** Color for 0.25-0.5 Weight Influence */
  58664. colorQuarter?: Color3;
  58665. /** Color for 0.5-0.75 Weight Influence */
  58666. colorHalf?: Color3;
  58667. /** Color for 0.75-1 Weight Influence */
  58668. colorFull?: Color3;
  58669. /** Color for Zero Weight Influence */
  58670. targetBoneIndex?: number;
  58671. }
  58672. /**
  58673. * Simple structure of the gradient steps for the Color Map.
  58674. */
  58675. export interface ISkeletonMapShaderColorMapKnot {
  58676. /** Color of the Knot */
  58677. color: Color3;
  58678. /** Location of the Knot */
  58679. location: number;
  58680. }
  58681. /**
  58682. * Defines the constructor options for the SkeletonMap Shader.
  58683. */
  58684. export interface ISkeletonMapShaderOptions {
  58685. /** Skeleton to Map */
  58686. skeleton: Skeleton;
  58687. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58688. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58689. }
  58690. }
  58691. declare module BABYLON {
  58692. /**
  58693. * Class containing static functions to help procedurally build meshes
  58694. */
  58695. export class RibbonBuilder {
  58696. /**
  58697. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58698. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58699. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58700. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58701. * * 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
  58702. * * 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
  58703. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  58704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58705. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58706. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58707. * * 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
  58708. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58709. * * 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
  58710. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58712. * @param name defines the name of the mesh
  58713. * @param options defines the options used to create the mesh
  58714. * @param scene defines the hosting scene
  58715. * @returns the ribbon mesh
  58716. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58717. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58718. */
  58719. static CreateRibbon(name: string, options: {
  58720. pathArray: Vector3[][];
  58721. closeArray?: boolean;
  58722. closePath?: boolean;
  58723. offset?: number;
  58724. updatable?: boolean;
  58725. sideOrientation?: number;
  58726. frontUVs?: Vector4;
  58727. backUVs?: Vector4;
  58728. instance?: Mesh;
  58729. invertUV?: boolean;
  58730. uvs?: Vector2[];
  58731. colors?: Color4[];
  58732. }, scene?: Nullable<Scene>): Mesh;
  58733. }
  58734. }
  58735. declare module BABYLON {
  58736. /**
  58737. * Class containing static functions to help procedurally build meshes
  58738. */
  58739. export class ShapeBuilder {
  58740. /**
  58741. * 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.
  58742. * * 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.
  58743. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58744. * * 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.
  58745. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58746. * * 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
  58747. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  58748. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58750. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58751. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58753. * @param name defines the name of the mesh
  58754. * @param options defines the options used to create the mesh
  58755. * @param scene defines the hosting scene
  58756. * @returns the extruded shape mesh
  58757. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58759. */
  58760. static ExtrudeShape(name: string, options: {
  58761. shape: Vector3[];
  58762. path: Vector3[];
  58763. scale?: number;
  58764. rotation?: number;
  58765. cap?: number;
  58766. updatable?: boolean;
  58767. sideOrientation?: number;
  58768. frontUVs?: Vector4;
  58769. backUVs?: Vector4;
  58770. instance?: Mesh;
  58771. invertUV?: boolean;
  58772. }, scene?: Nullable<Scene>): Mesh;
  58773. /**
  58774. * Creates an custom extruded shape mesh.
  58775. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58776. * * 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.
  58777. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58778. * * 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 beginning of the path
  58779. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58780. * * 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 beginning of the path
  58781. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58782. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58783. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58784. * * 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
  58785. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  58786. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58788. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58789. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58791. * @param name defines the name of the mesh
  58792. * @param options defines the options used to create the mesh
  58793. * @param scene defines the hosting scene
  58794. * @returns the custom extruded shape mesh
  58795. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58796. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58797. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58798. */
  58799. static ExtrudeShapeCustom(name: string, options: {
  58800. shape: Vector3[];
  58801. path: Vector3[];
  58802. scaleFunction?: any;
  58803. rotationFunction?: any;
  58804. ribbonCloseArray?: boolean;
  58805. ribbonClosePath?: boolean;
  58806. cap?: number;
  58807. updatable?: boolean;
  58808. sideOrientation?: number;
  58809. frontUVs?: Vector4;
  58810. backUVs?: Vector4;
  58811. instance?: Mesh;
  58812. invertUV?: boolean;
  58813. }, scene?: Nullable<Scene>): Mesh;
  58814. private static _ExtrudeShapeGeneric;
  58815. }
  58816. }
  58817. declare module BABYLON.Debug {
  58818. /**
  58819. * Class used to render a debug view of a given skeleton
  58820. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  58821. */
  58822. export class SkeletonViewer {
  58823. /** defines the skeleton to render */
  58824. skeleton: Skeleton;
  58825. /** defines the mesh attached to the skeleton */
  58826. mesh: AbstractMesh;
  58827. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58828. autoUpdateBonesMatrices: boolean;
  58829. /** defines the rendering group id to use with the viewer */
  58830. renderingGroupId: number;
  58831. /** is the options for the viewer */
  58832. options: Partial<ISkeletonViewerOptions>;
  58833. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  58834. static readonly DISPLAY_LINES: number;
  58835. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  58836. static readonly DISPLAY_SPHERES: number;
  58837. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  58838. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  58839. /** public static method to create a BoneWeight Shader
  58840. * @param options The constructor options
  58841. * @param scene The scene that the shader is scoped to
  58842. * @returns The created ShaderMaterial
  58843. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  58844. */
  58845. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  58846. /** public static method to create a BoneWeight Shader
  58847. * @param options The constructor options
  58848. * @param scene The scene that the shader is scoped to
  58849. * @returns The created ShaderMaterial
  58850. */
  58851. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  58852. /** private static method to create a BoneWeight Shader
  58853. * @param size The size of the buffer to create (usually the bone count)
  58854. * @param colorMap The gradient data to generate
  58855. * @param scene The scene that the shader is scoped to
  58856. * @returns an Array of floats from the color gradient values
  58857. */
  58858. private static _CreateBoneMapColorBuffer;
  58859. /** If SkeletonViewer scene scope. */
  58860. private _scene;
  58861. /** Gets or sets the color used to render the skeleton */
  58862. color: Color3;
  58863. /** Array of the points of the skeleton fo the line view. */
  58864. private _debugLines;
  58865. /** The SkeletonViewers Mesh. */
  58866. private _debugMesh;
  58867. /** The local axes Meshes. */
  58868. private _localAxes;
  58869. /** If SkeletonViewer is enabled. */
  58870. private _isEnabled;
  58871. /** If SkeletonViewer is ready. */
  58872. private _ready;
  58873. /** SkeletonViewer render observable. */
  58874. private _obs;
  58875. /** The Utility Layer to render the gizmos in. */
  58876. private _utilityLayer;
  58877. private _boneIndices;
  58878. /** Gets the Scene. */
  58879. get scene(): Scene;
  58880. /** Gets the utilityLayer. */
  58881. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58882. /** Checks Ready Status. */
  58883. get isReady(): Boolean;
  58884. /** Sets Ready Status. */
  58885. set ready(value: boolean);
  58886. /** Gets the debugMesh */
  58887. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58888. /** Sets the debugMesh */
  58889. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58890. /** Gets the displayMode */
  58891. get displayMode(): number;
  58892. /** Sets the displayMode */
  58893. set displayMode(value: number);
  58894. /**
  58895. * Creates a new SkeletonViewer
  58896. * @param skeleton defines the skeleton to render
  58897. * @param mesh defines the mesh attached to the skeleton
  58898. * @param scene defines the hosting scene
  58899. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58900. * @param renderingGroupId defines the rendering group id to use with the viewer
  58901. * @param options All of the extra constructor options for the SkeletonViewer
  58902. */
  58903. constructor(
  58904. /** defines the skeleton to render */
  58905. skeleton: Skeleton,
  58906. /** defines the mesh attached to the skeleton */
  58907. mesh: AbstractMesh,
  58908. /** The Scene scope*/
  58909. scene: Scene,
  58910. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58911. autoUpdateBonesMatrices?: boolean,
  58912. /** defines the rendering group id to use with the viewer */
  58913. renderingGroupId?: number,
  58914. /** is the options for the viewer */
  58915. options?: Partial<ISkeletonViewerOptions>);
  58916. /** The Dynamic bindings for the update functions */
  58917. private _bindObs;
  58918. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58919. update(): void;
  58920. /** Gets or sets a boolean indicating if the viewer is enabled */
  58921. set isEnabled(value: boolean);
  58922. get isEnabled(): boolean;
  58923. private _getBonePosition;
  58924. private _getLinesForBonesWithLength;
  58925. private _getLinesForBonesNoLength;
  58926. /** function to revert the mesh and scene back to the initial state. */
  58927. private _revert;
  58928. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58929. private _getAbsoluteBindPoseToRef;
  58930. /** function to build and bind sphere joint points and spur bone representations. */
  58931. private _buildSpheresAndSpurs;
  58932. private _buildLocalAxes;
  58933. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58934. private _displayLinesUpdate;
  58935. /** Changes the displayMode of the skeleton viewer
  58936. * @param mode The displayMode numerical value
  58937. */
  58938. changeDisplayMode(mode: number): void;
  58939. /** Sets a display option of the skeleton viewer
  58940. *
  58941. * | Option | Type | Default | Description |
  58942. * | ---------------- | ------- | ------- | ----------- |
  58943. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58944. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58945. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58946. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58947. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58948. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58949. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58950. *
  58951. * @param option String of the option name
  58952. * @param value The numerical option value
  58953. */
  58954. changeDisplayOptions(option: string, value: number): void;
  58955. /** Release associated resources */
  58956. dispose(): void;
  58957. }
  58958. }
  58959. declare module BABYLON {
  58960. /**
  58961. * Enum for Device Types
  58962. */
  58963. export enum DeviceType {
  58964. /** Generic */
  58965. Generic = 0,
  58966. /** Keyboard */
  58967. Keyboard = 1,
  58968. /** Mouse */
  58969. Mouse = 2,
  58970. /** Touch Pointers */
  58971. Touch = 3,
  58972. /** PS4 Dual Shock */
  58973. DualShock = 4,
  58974. /** Xbox */
  58975. Xbox = 5,
  58976. /** Switch Controller */
  58977. Switch = 6
  58978. }
  58979. /**
  58980. * Enum for All Pointers (Touch/Mouse)
  58981. */
  58982. export enum PointerInput {
  58983. /** Horizontal Axis */
  58984. Horizontal = 0,
  58985. /** Vertical Axis */
  58986. Vertical = 1,
  58987. /** Left Click or Touch */
  58988. LeftClick = 2,
  58989. /** Middle Click */
  58990. MiddleClick = 3,
  58991. /** Right Click */
  58992. RightClick = 4,
  58993. /** Browser Back */
  58994. BrowserBack = 5,
  58995. /** Browser Forward */
  58996. BrowserForward = 6
  58997. }
  58998. /**
  58999. * Enum for Dual Shock Gamepad
  59000. */
  59001. export enum DualShockInput {
  59002. /** Cross */
  59003. Cross = 0,
  59004. /** Circle */
  59005. Circle = 1,
  59006. /** Square */
  59007. Square = 2,
  59008. /** Triangle */
  59009. Triangle = 3,
  59010. /** L1 */
  59011. L1 = 4,
  59012. /** R1 */
  59013. R1 = 5,
  59014. /** L2 */
  59015. L2 = 6,
  59016. /** R2 */
  59017. R2 = 7,
  59018. /** Share */
  59019. Share = 8,
  59020. /** Options */
  59021. Options = 9,
  59022. /** L3 */
  59023. L3 = 10,
  59024. /** R3 */
  59025. R3 = 11,
  59026. /** DPadUp */
  59027. DPadUp = 12,
  59028. /** DPadDown */
  59029. DPadDown = 13,
  59030. /** DPadLeft */
  59031. DPadLeft = 14,
  59032. /** DRight */
  59033. DPadRight = 15,
  59034. /** Home */
  59035. Home = 16,
  59036. /** TouchPad */
  59037. TouchPad = 17,
  59038. /** LStickXAxis */
  59039. LStickXAxis = 18,
  59040. /** LStickYAxis */
  59041. LStickYAxis = 19,
  59042. /** RStickXAxis */
  59043. RStickXAxis = 20,
  59044. /** RStickYAxis */
  59045. RStickYAxis = 21
  59046. }
  59047. /**
  59048. * Enum for Xbox Gamepad
  59049. */
  59050. export enum XboxInput {
  59051. /** A */
  59052. A = 0,
  59053. /** B */
  59054. B = 1,
  59055. /** X */
  59056. X = 2,
  59057. /** Y */
  59058. Y = 3,
  59059. /** LB */
  59060. LB = 4,
  59061. /** RB */
  59062. RB = 5,
  59063. /** LT */
  59064. LT = 6,
  59065. /** RT */
  59066. RT = 7,
  59067. /** Back */
  59068. Back = 8,
  59069. /** Start */
  59070. Start = 9,
  59071. /** LS */
  59072. LS = 10,
  59073. /** RS */
  59074. RS = 11,
  59075. /** DPadUp */
  59076. DPadUp = 12,
  59077. /** DPadDown */
  59078. DPadDown = 13,
  59079. /** DPadLeft */
  59080. DPadLeft = 14,
  59081. /** DRight */
  59082. DPadRight = 15,
  59083. /** Home */
  59084. Home = 16,
  59085. /** LStickXAxis */
  59086. LStickXAxis = 17,
  59087. /** LStickYAxis */
  59088. LStickYAxis = 18,
  59089. /** RStickXAxis */
  59090. RStickXAxis = 19,
  59091. /** RStickYAxis */
  59092. RStickYAxis = 20
  59093. }
  59094. /**
  59095. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  59096. */
  59097. export enum SwitchInput {
  59098. /** B */
  59099. B = 0,
  59100. /** A */
  59101. A = 1,
  59102. /** Y */
  59103. Y = 2,
  59104. /** X */
  59105. X = 3,
  59106. /** L */
  59107. L = 4,
  59108. /** R */
  59109. R = 5,
  59110. /** ZL */
  59111. ZL = 6,
  59112. /** ZR */
  59113. ZR = 7,
  59114. /** Minus */
  59115. Minus = 8,
  59116. /** Plus */
  59117. Plus = 9,
  59118. /** LS */
  59119. LS = 10,
  59120. /** RS */
  59121. RS = 11,
  59122. /** DPadUp */
  59123. DPadUp = 12,
  59124. /** DPadDown */
  59125. DPadDown = 13,
  59126. /** DPadLeft */
  59127. DPadLeft = 14,
  59128. /** DRight */
  59129. DPadRight = 15,
  59130. /** Home */
  59131. Home = 16,
  59132. /** Capture */
  59133. Capture = 17,
  59134. /** LStickXAxis */
  59135. LStickXAxis = 18,
  59136. /** LStickYAxis */
  59137. LStickYAxis = 19,
  59138. /** RStickXAxis */
  59139. RStickXAxis = 20,
  59140. /** RStickYAxis */
  59141. RStickYAxis = 21
  59142. }
  59143. }
  59144. declare module BABYLON {
  59145. /**
  59146. * This class will take all inputs from Keyboard, Pointer, and
  59147. * any Gamepads and provide a polling system that all devices
  59148. * will use. This class assumes that there will only be one
  59149. * pointer device and one keyboard.
  59150. */
  59151. export class DeviceInputSystem implements IDisposable {
  59152. /**
  59153. * Returns onDeviceConnected callback property
  59154. * @returns Callback with function to execute when a device is connected
  59155. */
  59156. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  59157. /**
  59158. * Sets callback function when a device is connected and executes against all connected devices
  59159. * @param callback Function to execute when a device is connected
  59160. */
  59161. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  59162. /**
  59163. * Callback to be triggered when a device is disconnected
  59164. */
  59165. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  59166. /**
  59167. * Callback to be triggered when event driven input is updated
  59168. */
  59169. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  59170. private _inputs;
  59171. private _gamepads;
  59172. private _keyboardActive;
  59173. private _pointerActive;
  59174. private _elementToAttachTo;
  59175. private _keyboardDownEvent;
  59176. private _keyboardUpEvent;
  59177. private _pointerMoveEvent;
  59178. private _pointerDownEvent;
  59179. private _pointerUpEvent;
  59180. private _gamepadConnectedEvent;
  59181. private _gamepadDisconnectedEvent;
  59182. private _onDeviceConnected;
  59183. private static _MAX_KEYCODES;
  59184. private static _MAX_POINTER_INPUTS;
  59185. private constructor();
  59186. /**
  59187. * Creates a new DeviceInputSystem instance
  59188. * @param engine Engine to pull input element from
  59189. * @returns The new instance
  59190. */
  59191. static Create(engine: Engine): DeviceInputSystem;
  59192. /**
  59193. * Checks for current device input value, given an id and input index
  59194. * @param deviceName Id of connected device
  59195. * @param inputIndex Index of device input
  59196. * @returns Current value of input
  59197. */
  59198. /**
  59199. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  59200. * @param deviceType Enum specifiying device type
  59201. * @param deviceSlot "Slot" or index that device is referenced in
  59202. * @param inputIndex Id of input to be checked
  59203. * @returns Current value of input
  59204. */
  59205. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  59206. /**
  59207. * Dispose of all the eventlisteners
  59208. */
  59209. dispose(): void;
  59210. /**
  59211. * Checks for existing connections to devices and register them, if necessary
  59212. * Currently handles gamepads and mouse
  59213. */
  59214. private _checkForConnectedDevices;
  59215. /**
  59216. * Add a gamepad to the DeviceInputSystem
  59217. * @param gamepad A single DOM Gamepad object
  59218. */
  59219. private _addGamePad;
  59220. /**
  59221. * Add pointer device to DeviceInputSystem
  59222. * @param deviceType Type of Pointer to add
  59223. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  59224. * @param currentX Current X at point of adding
  59225. * @param currentY Current Y at point of adding
  59226. */
  59227. private _addPointerDevice;
  59228. /**
  59229. * Add device and inputs to device array
  59230. * @param deviceType Enum specifiying device type
  59231. * @param deviceSlot "Slot" or index that device is referenced in
  59232. * @param numberOfInputs Number of input entries to create for given device
  59233. */
  59234. private _registerDevice;
  59235. /**
  59236. * Given a specific device name, remove that device from the device map
  59237. * @param deviceType Enum specifiying device type
  59238. * @param deviceSlot "Slot" or index that device is referenced in
  59239. */
  59240. private _unregisterDevice;
  59241. /**
  59242. * Handle all actions that come from keyboard interaction
  59243. */
  59244. private _handleKeyActions;
  59245. /**
  59246. * Handle all actions that come from pointer interaction
  59247. */
  59248. private _handlePointerActions;
  59249. /**
  59250. * Handle all actions that come from gamepad interaction
  59251. */
  59252. private _handleGamepadActions;
  59253. /**
  59254. * Update all non-event based devices with each frame
  59255. * @param deviceType Enum specifiying device type
  59256. * @param deviceSlot "Slot" or index that device is referenced in
  59257. * @param inputIndex Id of input to be checked
  59258. */
  59259. private _updateDevice;
  59260. /**
  59261. * Gets DeviceType from the device name
  59262. * @param deviceName Name of Device from DeviceInputSystem
  59263. * @returns DeviceType enum value
  59264. */
  59265. private _getGamepadDeviceType;
  59266. }
  59267. }
  59268. declare module BABYLON {
  59269. /**
  59270. * Type to handle enforcement of inputs
  59271. */
  59272. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  59273. }
  59274. declare module BABYLON {
  59275. /**
  59276. * Class that handles all input for a specific device
  59277. */
  59278. export class DeviceSource<T extends DeviceType> {
  59279. /** Type of device */
  59280. readonly deviceType: DeviceType;
  59281. /** "Slot" or index that device is referenced in */
  59282. readonly deviceSlot: number;
  59283. /**
  59284. * Observable to handle device input changes per device
  59285. */
  59286. readonly onInputChangedObservable: Observable<{
  59287. inputIndex: DeviceInput<T>;
  59288. previousState: Nullable<number>;
  59289. currentState: Nullable<number>;
  59290. }>;
  59291. private readonly _deviceInputSystem;
  59292. /**
  59293. * Default Constructor
  59294. * @param deviceInputSystem Reference to DeviceInputSystem
  59295. * @param deviceType Type of device
  59296. * @param deviceSlot "Slot" or index that device is referenced in
  59297. */
  59298. constructor(deviceInputSystem: DeviceInputSystem,
  59299. /** Type of device */
  59300. deviceType: DeviceType,
  59301. /** "Slot" or index that device is referenced in */
  59302. deviceSlot?: number);
  59303. /**
  59304. * Get input for specific input
  59305. * @param inputIndex index of specific input on device
  59306. * @returns Input value from DeviceInputSystem
  59307. */
  59308. getInput(inputIndex: DeviceInput<T>): number;
  59309. }
  59310. /**
  59311. * Class to keep track of devices
  59312. */
  59313. export class DeviceSourceManager implements IDisposable {
  59314. /**
  59315. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  59316. */
  59317. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  59318. /**
  59319. * Observable to be triggered when after a device is disconnected
  59320. */
  59321. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  59322. private readonly _devices;
  59323. private readonly _firstDevice;
  59324. private readonly _deviceInputSystem;
  59325. /**
  59326. * Default Constructor
  59327. * @param engine engine to pull input element from
  59328. */
  59329. constructor(engine: Engine);
  59330. /**
  59331. * Gets a DeviceSource, given a type and slot
  59332. * @param deviceType Enum specifying device type
  59333. * @param deviceSlot "Slot" or index that device is referenced in
  59334. * @returns DeviceSource object
  59335. */
  59336. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  59337. /**
  59338. * Gets an array of DeviceSource objects for a given device type
  59339. * @param deviceType Enum specifying device type
  59340. * @returns Array of DeviceSource objects
  59341. */
  59342. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  59343. /**
  59344. * Returns a read-only list of all available devices
  59345. * @returns Read-only array with active devices
  59346. */
  59347. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  59348. /**
  59349. * Dispose of DeviceInputSystem and other parts
  59350. */
  59351. dispose(): void;
  59352. /**
  59353. * Function to add device name to device list
  59354. * @param deviceType Enum specifying device type
  59355. * @param deviceSlot "Slot" or index that device is referenced in
  59356. */
  59357. private _addDevice;
  59358. /**
  59359. * Function to remove device name to device list
  59360. * @param deviceType Enum specifying device type
  59361. * @param deviceSlot "Slot" or index that device is referenced in
  59362. */
  59363. private _removeDevice;
  59364. /**
  59365. * Updates array storing first connected device of each type
  59366. * @param type Type of Device
  59367. */
  59368. private _updateFirstDevices;
  59369. }
  59370. }
  59371. declare module BABYLON {
  59372. /**
  59373. * Options to create the null engine
  59374. */
  59375. export class NullEngineOptions {
  59376. /**
  59377. * Render width (Default: 512)
  59378. */
  59379. renderWidth: number;
  59380. /**
  59381. * Render height (Default: 256)
  59382. */
  59383. renderHeight: number;
  59384. /**
  59385. * Texture size (Default: 512)
  59386. */
  59387. textureSize: number;
  59388. /**
  59389. * If delta time between frames should be constant
  59390. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59391. */
  59392. deterministicLockstep: boolean;
  59393. /**
  59394. * Maximum about of steps between frames (Default: 4)
  59395. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59396. */
  59397. lockstepMaxSteps: number;
  59398. /**
  59399. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  59400. */
  59401. useHighPrecisionMatrix?: boolean;
  59402. }
  59403. /**
  59404. * The null engine class provides support for headless version of babylon.js.
  59405. * This can be used in server side scenario or for testing purposes
  59406. */
  59407. export class NullEngine extends Engine {
  59408. private _options;
  59409. /**
  59410. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  59411. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59412. * @returns true if engine is in deterministic lock step mode
  59413. */
  59414. isDeterministicLockStep(): boolean;
  59415. /**
  59416. * Gets the max steps when engine is running in deterministic lock step
  59417. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59418. * @returns the max steps
  59419. */
  59420. getLockstepMaxSteps(): number;
  59421. /**
  59422. * Gets the current hardware scaling level.
  59423. * By default the hardware scaling level is computed from the window device ratio.
  59424. * 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.
  59425. * @returns a number indicating the current hardware scaling level
  59426. */
  59427. getHardwareScalingLevel(): number;
  59428. constructor(options?: NullEngineOptions);
  59429. /**
  59430. * Creates a vertex buffer
  59431. * @param vertices the data for the vertex buffer
  59432. * @returns the new WebGL static buffer
  59433. */
  59434. createVertexBuffer(vertices: FloatArray): DataBuffer;
  59435. /**
  59436. * Creates a new index buffer
  59437. * @param indices defines the content of the index buffer
  59438. * @param updatable defines if the index buffer must be updatable
  59439. * @returns a new webGL buffer
  59440. */
  59441. createIndexBuffer(indices: IndicesArray): DataBuffer;
  59442. /**
  59443. * Clear the current render buffer or the current render target (if any is set up)
  59444. * @param color defines the color to use
  59445. * @param backBuffer defines if the back buffer must be cleared
  59446. * @param depth defines if the depth buffer must be cleared
  59447. * @param stencil defines if the stencil buffer must be cleared
  59448. */
  59449. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59450. /**
  59451. * Gets the current render width
  59452. * @param useScreen defines if screen size must be used (or the current render target if any)
  59453. * @returns a number defining the current render width
  59454. */
  59455. getRenderWidth(useScreen?: boolean): number;
  59456. /**
  59457. * Gets the current render height
  59458. * @param useScreen defines if screen size must be used (or the current render target if any)
  59459. * @returns a number defining the current render height
  59460. */
  59461. getRenderHeight(useScreen?: boolean): number;
  59462. /**
  59463. * Set the WebGL's viewport
  59464. * @param viewport defines the viewport element to be used
  59465. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  59466. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  59467. */
  59468. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59469. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  59470. /**
  59471. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  59472. * @param pipelineContext defines the pipeline context to use
  59473. * @param uniformsNames defines the list of uniform names
  59474. * @returns an array of webGL uniform locations
  59475. */
  59476. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  59477. /**
  59478. * Gets the lsit of active attributes for a given webGL program
  59479. * @param pipelineContext defines the pipeline context to use
  59480. * @param attributesNames defines the list of attribute names to get
  59481. * @returns an array of indices indicating the offset of each attribute
  59482. */
  59483. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59484. /**
  59485. * Binds an effect to the webGL context
  59486. * @param effect defines the effect to bind
  59487. */
  59488. bindSamplers(effect: Effect): void;
  59489. /**
  59490. * Activates an effect, making it the current one (ie. the one used for rendering)
  59491. * @param effect defines the effect to activate
  59492. */
  59493. enableEffect(effect: Effect): void;
  59494. /**
  59495. * Set various states to the webGL context
  59496. * @param culling defines backface culling state
  59497. * @param zOffset defines the value to apply to zOffset (0 by default)
  59498. * @param force defines if states must be applied even if cache is up to date
  59499. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  59500. */
  59501. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59502. /**
  59503. * Set the value of an uniform to an array of int32
  59504. * @param uniform defines the webGL uniform location where to store the value
  59505. * @param array defines the array of int32 to store
  59506. * @returns true if value was set
  59507. */
  59508. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59509. /**
  59510. * Set the value of an uniform to an array of int32 (stored as vec2)
  59511. * @param uniform defines the webGL uniform location where to store the value
  59512. * @param array defines the array of int32 to store
  59513. * @returns true if value was set
  59514. */
  59515. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59516. /**
  59517. * Set the value of an uniform to an array of int32 (stored as vec3)
  59518. * @param uniform defines the webGL uniform location where to store the value
  59519. * @param array defines the array of int32 to store
  59520. * @returns true if value was set
  59521. */
  59522. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59523. /**
  59524. * Set the value of an uniform to an array of int32 (stored as vec4)
  59525. * @param uniform defines the webGL uniform location where to store the value
  59526. * @param array defines the array of int32 to store
  59527. * @returns true if value was set
  59528. */
  59529. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59530. /**
  59531. * Set the value of an uniform to an array of float32
  59532. * @param uniform defines the webGL uniform location where to store the value
  59533. * @param array defines the array of float32 to store
  59534. * @returns true if value was set
  59535. */
  59536. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59537. /**
  59538. * Set the value of an uniform to an array of float32 (stored as vec2)
  59539. * @param uniform defines the webGL uniform location where to store the value
  59540. * @param array defines the array of float32 to store
  59541. * @returns true if value was set
  59542. */
  59543. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59544. /**
  59545. * Set the value of an uniform to an array of float32 (stored as vec3)
  59546. * @param uniform defines the webGL uniform location where to store the value
  59547. * @param array defines the array of float32 to store
  59548. * @returns true if value was set
  59549. */
  59550. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59551. /**
  59552. * Set the value of an uniform to an array of float32 (stored as vec4)
  59553. * @param uniform defines the webGL uniform location where to store the value
  59554. * @param array defines the array of float32 to store
  59555. * @returns true if value was set
  59556. */
  59557. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59558. /**
  59559. * Set the value of an uniform to an array of number
  59560. * @param uniform defines the webGL uniform location where to store the value
  59561. * @param array defines the array of number to store
  59562. * @returns true if value was set
  59563. */
  59564. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59565. /**
  59566. * Set the value of an uniform to an array of number (stored as vec2)
  59567. * @param uniform defines the webGL uniform location where to store the value
  59568. * @param array defines the array of number to store
  59569. * @returns true if value was set
  59570. */
  59571. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59572. /**
  59573. * Set the value of an uniform to an array of number (stored as vec3)
  59574. * @param uniform defines the webGL uniform location where to store the value
  59575. * @param array defines the array of number to store
  59576. * @returns true if value was set
  59577. */
  59578. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59579. /**
  59580. * Set the value of an uniform to an array of number (stored as vec4)
  59581. * @param uniform defines the webGL uniform location where to store the value
  59582. * @param array defines the array of number to store
  59583. * @returns true if value was set
  59584. */
  59585. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59586. /**
  59587. * Set the value of an uniform to an array of float32 (stored as matrices)
  59588. * @param uniform defines the webGL uniform location where to store the value
  59589. * @param matrices defines the array of float32 to store
  59590. * @returns true if value was set
  59591. */
  59592. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59593. /**
  59594. * Set the value of an uniform to a matrix (3x3)
  59595. * @param uniform defines the webGL uniform location where to store the value
  59596. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59597. * @returns true if value was set
  59598. */
  59599. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59600. /**
  59601. * Set the value of an uniform to a matrix (2x2)
  59602. * @param uniform defines the webGL uniform location where to store the value
  59603. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59604. * @returns true if value was set
  59605. */
  59606. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59607. /**
  59608. * Set the value of an uniform to a number (float)
  59609. * @param uniform defines the webGL uniform location where to store the value
  59610. * @param value defines the float number to store
  59611. * @returns true if value was set
  59612. */
  59613. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59614. /**
  59615. * Set the value of an uniform to a vec2
  59616. * @param uniform defines the webGL uniform location where to store the value
  59617. * @param x defines the 1st component of the value
  59618. * @param y defines the 2nd component of the value
  59619. * @returns true if value was set
  59620. */
  59621. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59622. /**
  59623. * Set the value of an uniform to a vec3
  59624. * @param uniform defines the webGL uniform location where to store the value
  59625. * @param x defines the 1st component of the value
  59626. * @param y defines the 2nd component of the value
  59627. * @param z defines the 3rd component of the value
  59628. * @returns true if value was set
  59629. */
  59630. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59631. /**
  59632. * Set the value of an uniform to a boolean
  59633. * @param uniform defines the webGL uniform location where to store the value
  59634. * @param bool defines the boolean to store
  59635. * @returns true if value was set
  59636. */
  59637. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59638. /**
  59639. * Set the value of an uniform to a vec4
  59640. * @param uniform defines the webGL uniform location where to store the value
  59641. * @param x defines the 1st component of the value
  59642. * @param y defines the 2nd component of the value
  59643. * @param z defines the 3rd component of the value
  59644. * @param w defines the 4th component of the value
  59645. * @returns true if value was set
  59646. */
  59647. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59648. /**
  59649. * Sets the current alpha mode
  59650. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59651. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59652. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59653. */
  59654. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59655. /**
  59656. * Bind webGl buffers directly to the webGL context
  59657. * @param vertexBuffers defines the vertex buffer to bind
  59658. * @param indexBuffer defines the index buffer to bind
  59659. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59660. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59661. * @param effect defines the effect associated with the vertex buffer
  59662. */
  59663. bindBuffers(vertexBuffers: {
  59664. [key: string]: VertexBuffer;
  59665. }, indexBuffer: DataBuffer, effect: Effect): void;
  59666. /**
  59667. * Force the entire cache to be cleared
  59668. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59669. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59670. */
  59671. wipeCaches(bruteForce?: boolean): void;
  59672. /**
  59673. * Send a draw order
  59674. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59675. * @param indexStart defines the starting index
  59676. * @param indexCount defines the number of index to draw
  59677. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59678. */
  59679. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59680. /**
  59681. * Draw a list of indexed primitives
  59682. * @param fillMode defines the primitive to use
  59683. * @param indexStart defines the starting index
  59684. * @param indexCount defines the number of index to draw
  59685. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59686. */
  59687. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59688. /**
  59689. * Draw a list of unindexed primitives
  59690. * @param fillMode defines the primitive to use
  59691. * @param verticesStart defines the index of first vertex to draw
  59692. * @param verticesCount defines the count of vertices to draw
  59693. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59694. */
  59695. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59696. /** @hidden */
  59697. protected _createTexture(): WebGLTexture;
  59698. /** @hidden */
  59699. _releaseTexture(texture: InternalTexture): void;
  59700. /**
  59701. * Usually called from Texture.ts.
  59702. * Passed information to create a WebGLTexture
  59703. * @param urlArg defines a value which contains one of the following:
  59704. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59705. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59706. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59707. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59708. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  59709. * @param scene needed for loading to the correct scene
  59710. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59711. * @param onLoad optional callback to be called upon successful completion
  59712. * @param onError optional callback to be called upon failure
  59713. * @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
  59714. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59715. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59716. * @param forcedExtension defines the extension to use to pick the right loader
  59717. * @param mimeType defines an optional mime type
  59718. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59719. */
  59720. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  59721. /**
  59722. * Creates a new render target texture
  59723. * @param size defines the size of the texture
  59724. * @param options defines the options used to create the texture
  59725. * @returns a new render target texture stored in an InternalTexture
  59726. */
  59727. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59728. /**
  59729. * Update the sampling mode of a given texture
  59730. * @param samplingMode defines the required sampling mode
  59731. * @param texture defines the texture to update
  59732. */
  59733. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59734. /**
  59735. * Binds the frame buffer to the specified texture.
  59736. * @param texture The texture to render to or null for the default canvas
  59737. * @param faceIndex The face of the texture to render to in case of cube texture
  59738. * @param requiredWidth The width of the target to render to
  59739. * @param requiredHeight The height of the target to render to
  59740. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59741. * @param lodLevel defines le lod level to bind to the frame buffer
  59742. */
  59743. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59744. /**
  59745. * Unbind the current render target texture from the webGL context
  59746. * @param texture defines the render target texture to unbind
  59747. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59748. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59749. */
  59750. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59751. /**
  59752. * Creates a dynamic vertex buffer
  59753. * @param vertices the data for the dynamic vertex buffer
  59754. * @returns the new WebGL dynamic buffer
  59755. */
  59756. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  59757. /**
  59758. * Update the content of a dynamic texture
  59759. * @param texture defines the texture to update
  59760. * @param canvas defines the canvas containing the source
  59761. * @param invertY defines if data must be stored with Y axis inverted
  59762. * @param premulAlpha defines if alpha is stored as premultiplied
  59763. * @param format defines the format of the data
  59764. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59765. */
  59766. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59767. /**
  59768. * Gets a boolean indicating if all created effects are ready
  59769. * @returns true if all effects are ready
  59770. */
  59771. areAllEffectsReady(): boolean;
  59772. /**
  59773. * @hidden
  59774. * Get the current error code of the webGL context
  59775. * @returns the error code
  59776. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  59777. */
  59778. getError(): number;
  59779. /** @hidden */
  59780. _getUnpackAlignement(): number;
  59781. /** @hidden */
  59782. _unpackFlipY(value: boolean): void;
  59783. /**
  59784. * Update a dynamic index buffer
  59785. * @param indexBuffer defines the target index buffer
  59786. * @param indices defines the data to update
  59787. * @param offset defines the offset in the target index buffer where update should start
  59788. */
  59789. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  59790. /**
  59791. * Updates a dynamic vertex buffer.
  59792. * @param vertexBuffer the vertex buffer to update
  59793. * @param vertices the data used to update the vertex buffer
  59794. * @param byteOffset the byte offset of the data (optional)
  59795. * @param byteLength the byte length of the data (optional)
  59796. */
  59797. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  59798. /** @hidden */
  59799. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  59800. /** @hidden */
  59801. _bindTexture(channel: number, texture: InternalTexture): void;
  59802. protected _deleteBuffer(buffer: WebGLBuffer): void;
  59803. /**
  59804. * 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
  59805. */
  59806. releaseEffects(): void;
  59807. displayLoadingUI(): void;
  59808. hideLoadingUI(): void;
  59809. /** @hidden */
  59810. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59811. /** @hidden */
  59812. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59813. /** @hidden */
  59814. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59815. /** @hidden */
  59816. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59817. }
  59818. }
  59819. declare module BABYLON {
  59820. /** @hidden */
  59821. export class _OcclusionDataStorage {
  59822. /** @hidden */
  59823. occlusionInternalRetryCounter: number;
  59824. /** @hidden */
  59825. isOcclusionQueryInProgress: boolean;
  59826. /** @hidden */
  59827. isOccluded: boolean;
  59828. /** @hidden */
  59829. occlusionRetryCount: number;
  59830. /** @hidden */
  59831. occlusionType: number;
  59832. /** @hidden */
  59833. occlusionQueryAlgorithmType: number;
  59834. }
  59835. interface Engine {
  59836. /**
  59837. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59838. * @return the new query
  59839. */
  59840. createQuery(): WebGLQuery;
  59841. /**
  59842. * Delete and release a webGL query
  59843. * @param query defines the query to delete
  59844. * @return the current engine
  59845. */
  59846. deleteQuery(query: WebGLQuery): Engine;
  59847. /**
  59848. * Check if a given query has resolved and got its value
  59849. * @param query defines the query to check
  59850. * @returns true if the query got its value
  59851. */
  59852. isQueryResultAvailable(query: WebGLQuery): boolean;
  59853. /**
  59854. * Gets the value of a given query
  59855. * @param query defines the query to check
  59856. * @returns the value of the query
  59857. */
  59858. getQueryResult(query: WebGLQuery): number;
  59859. /**
  59860. * Initiates an occlusion query
  59861. * @param algorithmType defines the algorithm to use
  59862. * @param query defines the query to use
  59863. * @returns the current engine
  59864. * @see https://doc.babylonjs.com/features/occlusionquery
  59865. */
  59866. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59867. /**
  59868. * Ends an occlusion query
  59869. * @see https://doc.babylonjs.com/features/occlusionquery
  59870. * @param algorithmType defines the algorithm to use
  59871. * @returns the current engine
  59872. */
  59873. endOcclusionQuery(algorithmType: number): Engine;
  59874. /**
  59875. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59876. * Please note that only one query can be issued at a time
  59877. * @returns a time token used to track the time span
  59878. */
  59879. startTimeQuery(): Nullable<_TimeToken>;
  59880. /**
  59881. * Ends a time query
  59882. * @param token defines the token used to measure the time span
  59883. * @returns the time spent (in ns)
  59884. */
  59885. endTimeQuery(token: _TimeToken): int;
  59886. /** @hidden */
  59887. _currentNonTimestampToken: Nullable<_TimeToken>;
  59888. /** @hidden */
  59889. _createTimeQuery(): WebGLQuery;
  59890. /** @hidden */
  59891. _deleteTimeQuery(query: WebGLQuery): void;
  59892. /** @hidden */
  59893. _getGlAlgorithmType(algorithmType: number): number;
  59894. /** @hidden */
  59895. _getTimeQueryResult(query: WebGLQuery): any;
  59896. /** @hidden */
  59897. _getTimeQueryAvailability(query: WebGLQuery): any;
  59898. }
  59899. interface AbstractMesh {
  59900. /**
  59901. * Backing filed
  59902. * @hidden
  59903. */
  59904. __occlusionDataStorage: _OcclusionDataStorage;
  59905. /**
  59906. * Access property
  59907. * @hidden
  59908. */
  59909. _occlusionDataStorage: _OcclusionDataStorage;
  59910. /**
  59911. * 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 decides to show or hide the object.
  59912. * The default value is -1 which means don't break the query and wait till the result
  59913. * @see https://doc.babylonjs.com/features/occlusionquery
  59914. */
  59915. occlusionRetryCount: number;
  59916. /**
  59917. * 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:
  59918. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query within the Mesh.
  59919. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59920. * * 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.
  59921. * @see https://doc.babylonjs.com/features/occlusionquery
  59922. */
  59923. occlusionType: number;
  59924. /**
  59925. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59926. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59927. * * 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.
  59928. * @see https://doc.babylonjs.com/features/occlusionquery
  59929. */
  59930. occlusionQueryAlgorithmType: number;
  59931. /**
  59932. * Gets or sets whether the mesh is occluded or not, it is used also to set the initial state of the mesh to be occluded or not
  59933. * @see https://doc.babylonjs.com/features/occlusionquery
  59934. */
  59935. isOccluded: boolean;
  59936. /**
  59937. * Flag to check the progress status of the query
  59938. * @see https://doc.babylonjs.com/features/occlusionquery
  59939. */
  59940. isOcclusionQueryInProgress: boolean;
  59941. }
  59942. }
  59943. declare module BABYLON {
  59944. /** @hidden */
  59945. export var _forceTransformFeedbackToBundle: boolean;
  59946. interface Engine {
  59947. /**
  59948. * Creates a webGL transform feedback object
  59949. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59950. * @returns the webGL transform feedback object
  59951. */
  59952. createTransformFeedback(): WebGLTransformFeedback;
  59953. /**
  59954. * Delete a webGL transform feedback object
  59955. * @param value defines the webGL transform feedback object to delete
  59956. */
  59957. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59958. /**
  59959. * Bind a webGL transform feedback object to the webgl context
  59960. * @param value defines the webGL transform feedback object to bind
  59961. */
  59962. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59963. /**
  59964. * Begins a transform feedback operation
  59965. * @param usePoints defines if points or triangles must be used
  59966. */
  59967. beginTransformFeedback(usePoints: boolean): void;
  59968. /**
  59969. * Ends a transform feedback operation
  59970. */
  59971. endTransformFeedback(): void;
  59972. /**
  59973. * Specify the varyings to use with transform feedback
  59974. * @param program defines the associated webGL program
  59975. * @param value defines the list of strings representing the varying names
  59976. */
  59977. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59978. /**
  59979. * Bind a webGL buffer for a transform feedback operation
  59980. * @param value defines the webGL buffer to bind
  59981. */
  59982. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59983. }
  59984. }
  59985. declare module BABYLON {
  59986. /**
  59987. * Class used to define an additional view for the engine
  59988. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59989. */
  59990. export class EngineView {
  59991. /** Defines the canvas where to render the view */
  59992. target: HTMLCanvasElement;
  59993. /** Defines an optional camera used to render the view (will use active camera else) */
  59994. camera?: Camera;
  59995. }
  59996. interface Engine {
  59997. /**
  59998. * Gets or sets the HTML element to use for attaching events
  59999. */
  60000. inputElement: Nullable<HTMLElement>;
  60001. /**
  60002. * Gets the current engine view
  60003. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60004. */
  60005. activeView: Nullable<EngineView>;
  60006. /** Gets or sets the list of views */
  60007. views: EngineView[];
  60008. /**
  60009. * Register a new child canvas
  60010. * @param canvas defines the canvas to register
  60011. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  60012. * @returns the associated view
  60013. */
  60014. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  60015. /**
  60016. * Remove a registered child canvas
  60017. * @param canvas defines the canvas to remove
  60018. * @returns the current engine
  60019. */
  60020. unRegisterView(canvas: HTMLCanvasElement): Engine;
  60021. }
  60022. }
  60023. declare module BABYLON {
  60024. interface Engine {
  60025. /** @hidden */
  60026. _excludedCompressedTextures: string[];
  60027. /** @hidden */
  60028. _textureFormatInUse: string;
  60029. /**
  60030. * Gets the list of texture formats supported
  60031. */
  60032. readonly texturesSupported: Array<string>;
  60033. /**
  60034. * Gets the texture format in use
  60035. */
  60036. readonly textureFormatInUse: Nullable<string>;
  60037. /**
  60038. * Set the compressed texture extensions or file names to skip.
  60039. *
  60040. * @param skippedFiles defines the list of those texture files you want to skip
  60041. * Example: [".dds", ".env", "myfile.png"]
  60042. */
  60043. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  60044. /**
  60045. * Set the compressed texture format to use, based on the formats you have, and the formats
  60046. * supported by the hardware / browser.
  60047. *
  60048. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  60049. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  60050. * to API arguments needed to compressed textures. This puts the burden on the container
  60051. * generator to house the arcane code for determining these for current & future formats.
  60052. *
  60053. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60054. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60055. *
  60056. * Note: The result of this call is not taken into account when a texture is base64.
  60057. *
  60058. * @param formatsAvailable defines the list of those format families you have created
  60059. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  60060. *
  60061. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  60062. * @returns The extension selected.
  60063. */
  60064. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  60065. }
  60066. }
  60067. declare module BABYLON {
  60068. /** @hidden */
  60069. export var rgbdEncodePixelShader: {
  60070. name: string;
  60071. shader: string;
  60072. };
  60073. }
  60074. declare module BABYLON {
  60075. /**
  60076. * Raw texture data and descriptor sufficient for WebGL texture upload
  60077. */
  60078. export interface EnvironmentTextureInfo {
  60079. /**
  60080. * Version of the environment map
  60081. */
  60082. version: number;
  60083. /**
  60084. * Width of image
  60085. */
  60086. width: number;
  60087. /**
  60088. * Irradiance information stored in the file.
  60089. */
  60090. irradiance: any;
  60091. /**
  60092. * Specular information stored in the file.
  60093. */
  60094. specular: any;
  60095. }
  60096. /**
  60097. * Defines One Image in the file. It requires only the position in the file
  60098. * as well as the length.
  60099. */
  60100. interface BufferImageData {
  60101. /**
  60102. * Length of the image data.
  60103. */
  60104. length: number;
  60105. /**
  60106. * Position of the data from the null terminator delimiting the end of the JSON.
  60107. */
  60108. position: number;
  60109. }
  60110. /**
  60111. * Defines the specular data enclosed in the file.
  60112. * This corresponds to the version 1 of the data.
  60113. */
  60114. export interface EnvironmentTextureSpecularInfoV1 {
  60115. /**
  60116. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  60117. */
  60118. specularDataPosition?: number;
  60119. /**
  60120. * This contains all the images data needed to reconstruct the cubemap.
  60121. */
  60122. mipmaps: Array<BufferImageData>;
  60123. /**
  60124. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  60125. */
  60126. lodGenerationScale: number;
  60127. }
  60128. /**
  60129. * Sets of helpers addressing the serialization and deserialization of environment texture
  60130. * stored in a BabylonJS env file.
  60131. * Those files are usually stored as .env files.
  60132. */
  60133. export class EnvironmentTextureTools {
  60134. /**
  60135. * Magic number identifying the env file.
  60136. */
  60137. private static _MagicBytes;
  60138. /**
  60139. * Gets the environment info from an env file.
  60140. * @param data The array buffer containing the .env bytes.
  60141. * @returns the environment file info (the json header) if successfully parsed.
  60142. */
  60143. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  60144. /**
  60145. * Creates an environment texture from a loaded cube texture.
  60146. * @param texture defines the cube texture to convert in env file
  60147. * @return a promise containing the environment data if successful.
  60148. */
  60149. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  60150. /**
  60151. * Creates a JSON representation of the spherical data.
  60152. * @param texture defines the texture containing the polynomials
  60153. * @return the JSON representation of the spherical info
  60154. */
  60155. private static _CreateEnvTextureIrradiance;
  60156. /**
  60157. * Creates the ArrayBufferViews used for initializing environment texture image data.
  60158. * @param data the image data
  60159. * @param info parameters that determine what views will be created for accessing the underlying buffer
  60160. * @return the views described by info providing access to the underlying buffer
  60161. */
  60162. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  60163. /**
  60164. * Uploads the texture info contained in the env file to the GPU.
  60165. * @param texture defines the internal texture to upload to
  60166. * @param data defines the data to load
  60167. * @param info defines the texture info retrieved through the GetEnvInfo method
  60168. * @returns a promise
  60169. */
  60170. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  60171. private static _OnImageReadyAsync;
  60172. /**
  60173. * Uploads the levels of image data to the GPU.
  60174. * @param texture defines the internal texture to upload to
  60175. * @param imageData defines the array buffer views of image data [mipmap][face]
  60176. * @returns a promise
  60177. */
  60178. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  60179. /**
  60180. * Uploads spherical polynomials information to the texture.
  60181. * @param texture defines the texture we are trying to upload the information to
  60182. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  60183. */
  60184. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  60185. /** @hidden */
  60186. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60187. }
  60188. }
  60189. declare module BABYLON {
  60190. /**
  60191. * Container for accessors for natively-stored mesh data buffers.
  60192. */
  60193. class NativeDataBuffer extends DataBuffer {
  60194. /**
  60195. * Accessor value used to identify/retrieve a natively-stored index buffer.
  60196. */
  60197. nativeIndexBuffer?: any;
  60198. /**
  60199. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  60200. */
  60201. nativeVertexBuffer?: any;
  60202. }
  60203. /** @hidden */
  60204. class NativeTexture extends InternalTexture {
  60205. getInternalTexture(): InternalTexture;
  60206. getViewCount(): number;
  60207. }
  60208. /** @hidden */
  60209. export class NativeEngine extends Engine {
  60210. private readonly _native;
  60211. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  60212. private readonly INVALID_HANDLE;
  60213. private _boundBuffersVertexArray;
  60214. private _currentDepthTest;
  60215. getHardwareScalingLevel(): number;
  60216. constructor();
  60217. dispose(): void;
  60218. /**
  60219. * Can be used to override the current requestAnimationFrame requester.
  60220. * @hidden
  60221. */
  60222. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  60223. /**
  60224. * Override default engine behavior.
  60225. * @param color
  60226. * @param backBuffer
  60227. * @param depth
  60228. * @param stencil
  60229. */
  60230. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  60231. /**
  60232. * Gets host document
  60233. * @returns the host document object
  60234. */
  60235. getHostDocument(): Nullable<Document>;
  60236. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  60237. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  60238. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  60239. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  60240. [key: string]: VertexBuffer;
  60241. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60242. bindBuffers(vertexBuffers: {
  60243. [key: string]: VertexBuffer;
  60244. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60245. recordVertexArrayObject(vertexBuffers: {
  60246. [key: string]: VertexBuffer;
  60247. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  60248. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60249. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60250. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  60251. /**
  60252. * Draw a list of indexed primitives
  60253. * @param fillMode defines the primitive to use
  60254. * @param indexStart defines the starting index
  60255. * @param indexCount defines the number of index to draw
  60256. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60257. */
  60258. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  60259. /**
  60260. * Draw a list of unindexed primitives
  60261. * @param fillMode defines the primitive to use
  60262. * @param verticesStart defines the index of first vertex to draw
  60263. * @param verticesCount defines the count of vertices to draw
  60264. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60265. */
  60266. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  60267. createPipelineContext(): IPipelineContext;
  60268. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  60269. /** @hidden */
  60270. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  60271. /** @hidden */
  60272. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  60273. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60274. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60275. protected _setProgram(program: WebGLProgram): void;
  60276. _releaseEffect(effect: Effect): void;
  60277. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  60278. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  60279. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  60280. bindSamplers(effect: Effect): void;
  60281. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  60282. getRenderWidth(useScreen?: boolean): number;
  60283. getRenderHeight(useScreen?: boolean): number;
  60284. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60285. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60286. /**
  60287. * Set the z offset to apply to current rendering
  60288. * @param value defines the offset to apply
  60289. */
  60290. setZOffset(value: number): void;
  60291. /**
  60292. * Gets the current value of the zOffset
  60293. * @returns the current zOffset state
  60294. */
  60295. getZOffset(): number;
  60296. /**
  60297. * Enable or disable depth buffering
  60298. * @param enable defines the state to set
  60299. */
  60300. setDepthBuffer(enable: boolean): void;
  60301. /**
  60302. * Gets a boolean indicating if depth writing is enabled
  60303. * @returns the current depth writing state
  60304. */
  60305. getDepthWrite(): boolean;
  60306. setDepthFunctionToGreater(): void;
  60307. setDepthFunctionToGreaterOrEqual(): void;
  60308. setDepthFunctionToLess(): void;
  60309. setDepthFunctionToLessOrEqual(): void;
  60310. /**
  60311. * Enable or disable depth writing
  60312. * @param enable defines the state to set
  60313. */
  60314. setDepthWrite(enable: boolean): void;
  60315. /**
  60316. * Enable or disable color writing
  60317. * @param enable defines the state to set
  60318. */
  60319. setColorWrite(enable: boolean): void;
  60320. /**
  60321. * Gets a boolean indicating if color writing is enabled
  60322. * @returns the current color writing state
  60323. */
  60324. getColorWrite(): boolean;
  60325. /**
  60326. * Sets alpha constants used by some alpha blending modes
  60327. * @param r defines the red component
  60328. * @param g defines the green component
  60329. * @param b defines the blue component
  60330. * @param a defines the alpha component
  60331. */
  60332. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  60333. /**
  60334. * Sets the current alpha mode
  60335. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  60336. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60337. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60338. */
  60339. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60340. /**
  60341. * Gets the current alpha mode
  60342. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60343. * @returns the current alpha mode
  60344. */
  60345. getAlphaMode(): number;
  60346. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  60347. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60348. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60349. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60350. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60351. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60352. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60353. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60354. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60355. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60356. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60357. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60358. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60359. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60360. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60361. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60362. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60363. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60364. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60365. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60366. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  60367. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  60368. wipeCaches(bruteForce?: boolean): void;
  60369. protected _createTexture(): WebGLTexture;
  60370. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  60371. /**
  60372. * Update the content of a dynamic texture
  60373. * @param texture defines the texture to update
  60374. * @param canvas defines the canvas containing the source
  60375. * @param invertY defines if data must be stored with Y axis inverted
  60376. * @param premulAlpha defines if alpha is stored as premultiplied
  60377. * @param format defines the format of the data
  60378. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60379. */
  60380. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60381. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  60382. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  60383. /**
  60384. * Usually called from Texture.ts.
  60385. * Passed information to create a WebGLTexture
  60386. * @param url defines a value which contains one of the following:
  60387. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60388. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60389. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60390. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60391. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  60392. * @param scene needed for loading to the correct scene
  60393. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60394. * @param onLoad optional callback to be called upon successful completion
  60395. * @param onError optional callback to be called upon failure
  60396. * @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
  60397. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60398. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60399. * @param forcedExtension defines the extension to use to pick the right loader
  60400. * @param mimeType defines an optional mime type
  60401. * @param loaderOptions options to be passed to the loader
  60402. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60403. */
  60404. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  60405. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  60406. _releaseFramebufferObjects(texture: InternalTexture): void;
  60407. /**
  60408. * Creates a cube texture
  60409. * @param rootUrl defines the url where the files to load is located
  60410. * @param scene defines the current scene
  60411. * @param files defines the list of files to load (1 per face)
  60412. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  60413. * @param onLoad defines an optional callback raised when the texture is loaded
  60414. * @param onError defines an optional callback raised if there is an issue to load the texture
  60415. * @param format defines the format of the data
  60416. * @param forcedExtension defines the extension to use to pick the right loader
  60417. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  60418. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60419. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60420. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  60421. * @returns the cube texture as an InternalTexture
  60422. */
  60423. 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;
  60424. createRenderTargetTexture(size: number | {
  60425. width: number;
  60426. height: number;
  60427. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  60428. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60429. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60430. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60431. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  60432. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  60433. /**
  60434. * Updates a dynamic vertex buffer.
  60435. * @param vertexBuffer the vertex buffer to update
  60436. * @param data the data used to update the vertex buffer
  60437. * @param byteOffset the byte offset of the data (optional)
  60438. * @param byteLength the byte length of the data (optional)
  60439. */
  60440. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  60441. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  60442. private _updateAnisotropicLevel;
  60443. private _getAddressMode;
  60444. /** @hidden */
  60445. _bindTexture(channel: number, texture: InternalTexture): void;
  60446. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  60447. releaseEffects(): void;
  60448. /** @hidden */
  60449. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60450. /** @hidden */
  60451. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60452. /** @hidden */
  60453. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60454. /** @hidden */
  60455. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60456. private _getNativeSamplingMode;
  60457. private _getNativeTextureFormat;
  60458. private _getNativeAlphaMode;
  60459. private _getNativeAttribType;
  60460. }
  60461. }
  60462. declare module BABYLON {
  60463. /**
  60464. * Helper class to create the best engine depending on the current hardware
  60465. */
  60466. export class EngineFactory {
  60467. /**
  60468. * Creates an engine based on the capabilities of the underlying hardware
  60469. * @param canvas Defines the canvas to use to display the result
  60470. * @param options Defines the options passed to the engine to create the context dependencies
  60471. * @returns a promise that resolves with the created engine
  60472. */
  60473. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  60474. }
  60475. }
  60476. declare module BABYLON {
  60477. /**
  60478. * Gather the list of clipboard event types as constants.
  60479. */
  60480. export class ClipboardEventTypes {
  60481. /**
  60482. * The clipboard event is fired when a copy command is active (pressed).
  60483. */
  60484. static readonly COPY: number;
  60485. /**
  60486. * The clipboard event is fired when a cut command is active (pressed).
  60487. */
  60488. static readonly CUT: number;
  60489. /**
  60490. * The clipboard event is fired when a paste command is active (pressed).
  60491. */
  60492. static readonly PASTE: number;
  60493. }
  60494. /**
  60495. * This class is used to store clipboard related info for the onClipboardObservable event.
  60496. */
  60497. export class ClipboardInfo {
  60498. /**
  60499. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60500. */
  60501. type: number;
  60502. /**
  60503. * Defines the related dom event
  60504. */
  60505. event: ClipboardEvent;
  60506. /**
  60507. *Creates an instance of ClipboardInfo.
  60508. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  60509. * @param event Defines the related dom event
  60510. */
  60511. constructor(
  60512. /**
  60513. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60514. */
  60515. type: number,
  60516. /**
  60517. * Defines the related dom event
  60518. */
  60519. event: ClipboardEvent);
  60520. /**
  60521. * Get the clipboard event's type from the keycode.
  60522. * @param keyCode Defines the keyCode for the current keyboard event.
  60523. * @return {number}
  60524. */
  60525. static GetTypeFromCharacter(keyCode: number): number;
  60526. }
  60527. }
  60528. declare module BABYLON {
  60529. /**
  60530. * Google Daydream controller
  60531. */
  60532. export class DaydreamController extends WebVRController {
  60533. /**
  60534. * Base Url for the controller model.
  60535. */
  60536. static MODEL_BASE_URL: string;
  60537. /**
  60538. * File name for the controller model.
  60539. */
  60540. static MODEL_FILENAME: string;
  60541. /**
  60542. * Gamepad Id prefix used to identify Daydream Controller.
  60543. */
  60544. static readonly GAMEPAD_ID_PREFIX: string;
  60545. /**
  60546. * Creates a new DaydreamController from a gamepad
  60547. * @param vrGamepad the gamepad that the controller should be created from
  60548. */
  60549. constructor(vrGamepad: any);
  60550. /**
  60551. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60552. * @param scene scene in which to add meshes
  60553. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60554. */
  60555. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60556. /**
  60557. * Called once for each button that changed state since the last frame
  60558. * @param buttonIdx Which button index changed
  60559. * @param state New state of the button
  60560. * @param changes Which properties on the state changed since last frame
  60561. */
  60562. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60563. }
  60564. }
  60565. declare module BABYLON {
  60566. /**
  60567. * Gear VR Controller
  60568. */
  60569. export class GearVRController extends WebVRController {
  60570. /**
  60571. * Base Url for the controller model.
  60572. */
  60573. static MODEL_BASE_URL: string;
  60574. /**
  60575. * File name for the controller model.
  60576. */
  60577. static MODEL_FILENAME: string;
  60578. /**
  60579. * Gamepad Id prefix used to identify this controller.
  60580. */
  60581. static readonly GAMEPAD_ID_PREFIX: string;
  60582. private readonly _buttonIndexToObservableNameMap;
  60583. /**
  60584. * Creates a new GearVRController from a gamepad
  60585. * @param vrGamepad the gamepad that the controller should be created from
  60586. */
  60587. constructor(vrGamepad: any);
  60588. /**
  60589. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60590. * @param scene scene in which to add meshes
  60591. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60592. */
  60593. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60594. /**
  60595. * Called once for each button that changed state since the last frame
  60596. * @param buttonIdx Which button index changed
  60597. * @param state New state of the button
  60598. * @param changes Which properties on the state changed since last frame
  60599. */
  60600. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60601. }
  60602. }
  60603. declare module BABYLON {
  60604. /**
  60605. * Generic Controller
  60606. */
  60607. export class GenericController extends WebVRController {
  60608. /**
  60609. * Base Url for the controller model.
  60610. */
  60611. static readonly MODEL_BASE_URL: string;
  60612. /**
  60613. * File name for the controller model.
  60614. */
  60615. static readonly MODEL_FILENAME: string;
  60616. /**
  60617. * Creates a new GenericController from a gamepad
  60618. * @param vrGamepad the gamepad that the controller should be created from
  60619. */
  60620. constructor(vrGamepad: any);
  60621. /**
  60622. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60623. * @param scene scene in which to add meshes
  60624. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60625. */
  60626. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60627. /**
  60628. * Called once for each button that changed state since the last frame
  60629. * @param buttonIdx Which button index changed
  60630. * @param state New state of the button
  60631. * @param changes Which properties on the state changed since last frame
  60632. */
  60633. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60634. }
  60635. }
  60636. declare module BABYLON {
  60637. /**
  60638. * Oculus Touch Controller
  60639. */
  60640. export class OculusTouchController extends WebVRController {
  60641. /**
  60642. * Base Url for the controller model.
  60643. */
  60644. static MODEL_BASE_URL: string;
  60645. /**
  60646. * File name for the left controller model.
  60647. */
  60648. static MODEL_LEFT_FILENAME: string;
  60649. /**
  60650. * File name for the right controller model.
  60651. */
  60652. static MODEL_RIGHT_FILENAME: string;
  60653. /**
  60654. * Base Url for the Quest controller model.
  60655. */
  60656. static QUEST_MODEL_BASE_URL: string;
  60657. /**
  60658. * @hidden
  60659. * If the controllers are running on a device that needs the updated Quest controller models
  60660. */
  60661. static _IsQuest: boolean;
  60662. /**
  60663. * Fired when the secondary trigger on this controller is modified
  60664. */
  60665. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60666. /**
  60667. * Fired when the thumb rest on this controller is modified
  60668. */
  60669. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60670. /**
  60671. * Creates a new OculusTouchController from a gamepad
  60672. * @param vrGamepad the gamepad that the controller should be created from
  60673. */
  60674. constructor(vrGamepad: any);
  60675. /**
  60676. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60677. * @param scene scene in which to add meshes
  60678. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60679. */
  60680. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60681. /**
  60682. * Fired when the A button on this controller is modified
  60683. */
  60684. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60685. /**
  60686. * Fired when the B button on this controller is modified
  60687. */
  60688. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60689. /**
  60690. * Fired when the X button on this controller is modified
  60691. */
  60692. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60693. /**
  60694. * Fired when the Y button on this controller is modified
  60695. */
  60696. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60697. /**
  60698. * Called once for each button that changed state since the last frame
  60699. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60700. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60701. * 2) secondary trigger (same)
  60702. * 3) A (right) X (left), touch, pressed = value
  60703. * 4) B / Y
  60704. * 5) thumb rest
  60705. * @param buttonIdx Which button index changed
  60706. * @param state New state of the button
  60707. * @param changes Which properties on the state changed since last frame
  60708. */
  60709. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60710. }
  60711. }
  60712. declare module BABYLON {
  60713. /**
  60714. * Vive Controller
  60715. */
  60716. export class ViveController extends WebVRController {
  60717. /**
  60718. * Base Url for the controller model.
  60719. */
  60720. static MODEL_BASE_URL: string;
  60721. /**
  60722. * File name for the controller model.
  60723. */
  60724. static MODEL_FILENAME: string;
  60725. /**
  60726. * Creates a new ViveController from a gamepad
  60727. * @param vrGamepad the gamepad that the controller should be created from
  60728. */
  60729. constructor(vrGamepad: any);
  60730. /**
  60731. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60732. * @param scene scene in which to add meshes
  60733. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60734. */
  60735. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60736. /**
  60737. * Fired when the left button on this controller is modified
  60738. */
  60739. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60740. /**
  60741. * Fired when the right button on this controller is modified
  60742. */
  60743. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60744. /**
  60745. * Fired when the menu button on this controller is modified
  60746. */
  60747. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60748. /**
  60749. * Called once for each button that changed state since the last frame
  60750. * Vive mapping:
  60751. * 0: touchpad
  60752. * 1: trigger
  60753. * 2: left AND right buttons
  60754. * 3: menu button
  60755. * @param buttonIdx Which button index changed
  60756. * @param state New state of the button
  60757. * @param changes Which properties on the state changed since last frame
  60758. */
  60759. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60760. }
  60761. }
  60762. declare module BABYLON {
  60763. /**
  60764. * Defines the WindowsMotionController object that the state of the windows motion controller
  60765. */
  60766. export class WindowsMotionController extends WebVRController {
  60767. /**
  60768. * The base url used to load the left and right controller models
  60769. */
  60770. static MODEL_BASE_URL: string;
  60771. /**
  60772. * The name of the left controller model file
  60773. */
  60774. static MODEL_LEFT_FILENAME: string;
  60775. /**
  60776. * The name of the right controller model file
  60777. */
  60778. static MODEL_RIGHT_FILENAME: string;
  60779. /**
  60780. * The controller name prefix for this controller type
  60781. */
  60782. static readonly GAMEPAD_ID_PREFIX: string;
  60783. /**
  60784. * The controller id pattern for this controller type
  60785. */
  60786. private static readonly GAMEPAD_ID_PATTERN;
  60787. private _loadedMeshInfo;
  60788. protected readonly _mapping: {
  60789. buttons: string[];
  60790. buttonMeshNames: {
  60791. trigger: string;
  60792. menu: string;
  60793. grip: string;
  60794. thumbstick: string;
  60795. trackpad: string;
  60796. };
  60797. buttonObservableNames: {
  60798. trigger: string;
  60799. menu: string;
  60800. grip: string;
  60801. thumbstick: string;
  60802. trackpad: string;
  60803. };
  60804. axisMeshNames: string[];
  60805. pointingPoseMeshName: string;
  60806. };
  60807. /**
  60808. * Fired when the trackpad on this controller is clicked
  60809. */
  60810. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60811. /**
  60812. * Fired when the trackpad on this controller is modified
  60813. */
  60814. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60815. /**
  60816. * The current x and y values of this controller's trackpad
  60817. */
  60818. trackpad: StickValues;
  60819. /**
  60820. * Creates a new WindowsMotionController from a gamepad
  60821. * @param vrGamepad the gamepad that the controller should be created from
  60822. */
  60823. constructor(vrGamepad: any);
  60824. /**
  60825. * Fired when the trigger on this controller is modified
  60826. */
  60827. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60828. /**
  60829. * Fired when the menu button on this controller is modified
  60830. */
  60831. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60832. /**
  60833. * Fired when the grip button on this controller is modified
  60834. */
  60835. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60836. /**
  60837. * Fired when the thumbstick button on this controller is modified
  60838. */
  60839. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60840. /**
  60841. * Fired when the touchpad button on this controller is modified
  60842. */
  60843. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60844. /**
  60845. * Fired when the touchpad values on this controller are modified
  60846. */
  60847. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60848. protected _updateTrackpad(): void;
  60849. /**
  60850. * Called once per frame by the engine.
  60851. */
  60852. update(): void;
  60853. /**
  60854. * Called once for each button that changed state since the last frame
  60855. * @param buttonIdx Which button index changed
  60856. * @param state New state of the button
  60857. * @param changes Which properties on the state changed since last frame
  60858. */
  60859. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60860. /**
  60861. * Moves the buttons on the controller mesh based on their current state
  60862. * @param buttonName the name of the button to move
  60863. * @param buttonValue the value of the button which determines the buttons new position
  60864. */
  60865. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60866. /**
  60867. * Moves the axis on the controller mesh based on its current state
  60868. * @param axis the index of the axis
  60869. * @param axisValue the value of the axis which determines the meshes new position
  60870. * @hidden
  60871. */
  60872. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60873. /**
  60874. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60875. * @param scene scene in which to add meshes
  60876. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60877. */
  60878. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60879. /**
  60880. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60881. * can be transformed by button presses and axes values, based on this._mapping.
  60882. *
  60883. * @param scene scene in which the meshes exist
  60884. * @param meshes list of meshes that make up the controller model to process
  60885. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60886. */
  60887. private processModel;
  60888. private createMeshInfo;
  60889. /**
  60890. * Gets the ray of the controller in the direction the controller is pointing
  60891. * @param length the length the resulting ray should be
  60892. * @returns a ray in the direction the controller is pointing
  60893. */
  60894. getForwardRay(length?: number): Ray;
  60895. /**
  60896. * Disposes of the controller
  60897. */
  60898. dispose(): void;
  60899. }
  60900. /**
  60901. * This class represents a new windows motion controller in XR.
  60902. */
  60903. export class XRWindowsMotionController extends WindowsMotionController {
  60904. /**
  60905. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60906. */
  60907. protected readonly _mapping: {
  60908. buttons: string[];
  60909. buttonMeshNames: {
  60910. trigger: string;
  60911. menu: string;
  60912. grip: string;
  60913. thumbstick: string;
  60914. trackpad: string;
  60915. };
  60916. buttonObservableNames: {
  60917. trigger: string;
  60918. menu: string;
  60919. grip: string;
  60920. thumbstick: string;
  60921. trackpad: string;
  60922. };
  60923. axisMeshNames: string[];
  60924. pointingPoseMeshName: string;
  60925. };
  60926. /**
  60927. * Construct a new XR-Based windows motion controller
  60928. *
  60929. * @param gamepadInfo the gamepad object from the browser
  60930. */
  60931. constructor(gamepadInfo: any);
  60932. /**
  60933. * holds the thumbstick values (X,Y)
  60934. */
  60935. thumbstickValues: StickValues;
  60936. /**
  60937. * Fired when the thumbstick on this controller is clicked
  60938. */
  60939. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60940. /**
  60941. * Fired when the thumbstick on this controller is modified
  60942. */
  60943. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60944. /**
  60945. * Fired when the touchpad button on this controller is modified
  60946. */
  60947. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60948. /**
  60949. * Fired when the touchpad values on this controller are modified
  60950. */
  60951. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60952. /**
  60953. * Fired when the thumbstick button on this controller is modified
  60954. * here to prevent breaking changes
  60955. */
  60956. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60957. /**
  60958. * updating the thumbstick(!) and not the trackpad.
  60959. * This is named this way due to the difference between WebVR and XR and to avoid
  60960. * changing the parent class.
  60961. */
  60962. protected _updateTrackpad(): void;
  60963. /**
  60964. * Disposes the class with joy
  60965. */
  60966. dispose(): void;
  60967. }
  60968. }
  60969. declare module BABYLON {
  60970. /**
  60971. * A directional light is defined by a direction (what a surprise!).
  60972. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60973. * 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.
  60974. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60975. */
  60976. export class DirectionalLight extends ShadowLight {
  60977. private _shadowFrustumSize;
  60978. /**
  60979. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60980. */
  60981. get shadowFrustumSize(): number;
  60982. /**
  60983. * Specifies a fix frustum size for the shadow generation.
  60984. */
  60985. set shadowFrustumSize(value: number);
  60986. private _shadowOrthoScale;
  60987. /**
  60988. * Gets the shadow projection scale against the optimal computed one.
  60989. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60990. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60991. */
  60992. get shadowOrthoScale(): number;
  60993. /**
  60994. * Sets the shadow projection scale against the optimal computed one.
  60995. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60996. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60997. */
  60998. set shadowOrthoScale(value: number);
  60999. /**
  61000. * Automatically compute the projection matrix to best fit (including all the casters)
  61001. * on each frame.
  61002. */
  61003. autoUpdateExtends: boolean;
  61004. /**
  61005. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  61006. * on each frame. autoUpdateExtends must be set to true for this to work
  61007. */
  61008. autoCalcShadowZBounds: boolean;
  61009. private _orthoLeft;
  61010. private _orthoRight;
  61011. private _orthoTop;
  61012. private _orthoBottom;
  61013. /**
  61014. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  61015. * The directional light is emitted from everywhere in the given direction.
  61016. * It can cast shadows.
  61017. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61018. * @param name The friendly name of the light
  61019. * @param direction The direction of the light
  61020. * @param scene The scene the light belongs to
  61021. */
  61022. constructor(name: string, direction: Vector3, scene: Scene);
  61023. /**
  61024. * Returns the string "DirectionalLight".
  61025. * @return The class name
  61026. */
  61027. getClassName(): string;
  61028. /**
  61029. * Returns the integer 1.
  61030. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61031. */
  61032. getTypeID(): number;
  61033. /**
  61034. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  61035. * Returns the DirectionalLight Shadow projection matrix.
  61036. */
  61037. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61038. /**
  61039. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  61040. * Returns the DirectionalLight Shadow projection matrix.
  61041. */
  61042. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  61043. /**
  61044. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  61045. * Returns the DirectionalLight Shadow projection matrix.
  61046. */
  61047. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61048. protected _buildUniformLayout(): void;
  61049. /**
  61050. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  61051. * @param effect The effect to update
  61052. * @param lightIndex The index of the light in the effect to update
  61053. * @returns The directional light
  61054. */
  61055. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  61056. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  61057. /**
  61058. * Gets the minZ used for shadow according to both the scene and the light.
  61059. *
  61060. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61061. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61062. * @param activeCamera The camera we are returning the min for
  61063. * @returns the depth min z
  61064. */
  61065. getDepthMinZ(activeCamera: Camera): number;
  61066. /**
  61067. * Gets the maxZ used for shadow according to both the scene and the light.
  61068. *
  61069. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61070. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61071. * @param activeCamera The camera we are returning the max for
  61072. * @returns the depth max z
  61073. */
  61074. getDepthMaxZ(activeCamera: Camera): number;
  61075. /**
  61076. * Prepares the list of defines specific to the light type.
  61077. * @param defines the list of defines
  61078. * @param lightIndex defines the index of the light for the effect
  61079. */
  61080. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61081. }
  61082. }
  61083. declare module BABYLON {
  61084. /**
  61085. * Class containing static functions to help procedurally build meshes
  61086. */
  61087. export class HemisphereBuilder {
  61088. /**
  61089. * Creates a hemisphere mesh
  61090. * @param name defines the name of the mesh
  61091. * @param options defines the options used to create the mesh
  61092. * @param scene defines the hosting scene
  61093. * @returns the hemisphere mesh
  61094. */
  61095. static CreateHemisphere(name: string, options: {
  61096. segments?: number;
  61097. diameter?: number;
  61098. sideOrientation?: number;
  61099. }, scene: any): Mesh;
  61100. }
  61101. }
  61102. declare module BABYLON {
  61103. /**
  61104. * A spot light is defined by a position, a direction, an angle, and an exponent.
  61105. * These values define a cone of light starting from the position, emitting toward the direction.
  61106. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  61107. * and the exponent defines the speed of the decay of the light with distance (reach).
  61108. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61109. */
  61110. export class SpotLight extends ShadowLight {
  61111. private _angle;
  61112. private _innerAngle;
  61113. private _cosHalfAngle;
  61114. private _lightAngleScale;
  61115. private _lightAngleOffset;
  61116. /**
  61117. * Gets the cone angle of the spot light in Radians.
  61118. */
  61119. get angle(): number;
  61120. /**
  61121. * Sets the cone angle of the spot light in Radians.
  61122. */
  61123. set angle(value: number);
  61124. /**
  61125. * Only used in gltf falloff mode, this defines the angle where
  61126. * the directional falloff will start before cutting at angle which could be seen
  61127. * as outer angle.
  61128. */
  61129. get innerAngle(): number;
  61130. /**
  61131. * Only used in gltf falloff mode, this defines the angle where
  61132. * the directional falloff will start before cutting at angle which could be seen
  61133. * as outer angle.
  61134. */
  61135. set innerAngle(value: number);
  61136. private _shadowAngleScale;
  61137. /**
  61138. * Allows scaling the angle of the light for shadow generation only.
  61139. */
  61140. get shadowAngleScale(): number;
  61141. /**
  61142. * Allows scaling the angle of the light for shadow generation only.
  61143. */
  61144. set shadowAngleScale(value: number);
  61145. /**
  61146. * The light decay speed with the distance from the emission spot.
  61147. */
  61148. exponent: number;
  61149. private _projectionTextureMatrix;
  61150. /**
  61151. * Allows reading the projection texture
  61152. */
  61153. get projectionTextureMatrix(): Matrix;
  61154. protected _projectionTextureLightNear: number;
  61155. /**
  61156. * Gets the near clip of the Spotlight for texture projection.
  61157. */
  61158. get projectionTextureLightNear(): number;
  61159. /**
  61160. * Sets the near clip of the Spotlight for texture projection.
  61161. */
  61162. set projectionTextureLightNear(value: number);
  61163. protected _projectionTextureLightFar: number;
  61164. /**
  61165. * Gets the far clip of the Spotlight for texture projection.
  61166. */
  61167. get projectionTextureLightFar(): number;
  61168. /**
  61169. * Sets the far clip of the Spotlight for texture projection.
  61170. */
  61171. set projectionTextureLightFar(value: number);
  61172. protected _projectionTextureUpDirection: Vector3;
  61173. /**
  61174. * Gets the Up vector of the Spotlight for texture projection.
  61175. */
  61176. get projectionTextureUpDirection(): Vector3;
  61177. /**
  61178. * Sets the Up vector of the Spotlight for texture projection.
  61179. */
  61180. set projectionTextureUpDirection(value: Vector3);
  61181. private _projectionTexture;
  61182. /**
  61183. * Gets the projection texture of the light.
  61184. */
  61185. get projectionTexture(): Nullable<BaseTexture>;
  61186. /**
  61187. * Sets the projection texture of the light.
  61188. */
  61189. set projectionTexture(value: Nullable<BaseTexture>);
  61190. private static _IsProceduralTexture;
  61191. private static _IsTexture;
  61192. private _projectionTextureViewLightDirty;
  61193. private _projectionTextureProjectionLightDirty;
  61194. private _projectionTextureDirty;
  61195. private _projectionTextureViewTargetVector;
  61196. private _projectionTextureViewLightMatrix;
  61197. private _projectionTextureProjectionLightMatrix;
  61198. private _projectionTextureScalingMatrix;
  61199. /**
  61200. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  61201. * It can cast shadows.
  61202. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61203. * @param name The light friendly name
  61204. * @param position The position of the spot light in the scene
  61205. * @param direction The direction of the light in the scene
  61206. * @param angle The cone angle of the light in Radians
  61207. * @param exponent The light decay speed with the distance from the emission spot
  61208. * @param scene The scene the lights belongs to
  61209. */
  61210. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  61211. /**
  61212. * Returns the string "SpotLight".
  61213. * @returns the class name
  61214. */
  61215. getClassName(): string;
  61216. /**
  61217. * Returns the integer 2.
  61218. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61219. */
  61220. getTypeID(): number;
  61221. /**
  61222. * Overrides the direction setter to recompute the projection texture view light Matrix.
  61223. */
  61224. protected _setDirection(value: Vector3): void;
  61225. /**
  61226. * Overrides the position setter to recompute the projection texture view light Matrix.
  61227. */
  61228. protected _setPosition(value: Vector3): void;
  61229. /**
  61230. * 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.
  61231. * Returns the SpotLight.
  61232. */
  61233. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61234. protected _computeProjectionTextureViewLightMatrix(): void;
  61235. protected _computeProjectionTextureProjectionLightMatrix(): void;
  61236. /**
  61237. * Main function for light texture projection matrix computing.
  61238. */
  61239. protected _computeProjectionTextureMatrix(): void;
  61240. protected _buildUniformLayout(): void;
  61241. private _computeAngleValues;
  61242. /**
  61243. * Sets the passed Effect "effect" with the Light textures.
  61244. * @param effect The effect to update
  61245. * @param lightIndex The index of the light in the effect to update
  61246. * @returns The light
  61247. */
  61248. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  61249. /**
  61250. * Sets the passed Effect object with the SpotLight transformed position (or position if not parented) and normalized direction.
  61251. * @param effect The effect to update
  61252. * @param lightIndex The index of the light in the effect to update
  61253. * @returns The spot light
  61254. */
  61255. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  61256. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61257. /**
  61258. * Disposes the light and the associated resources.
  61259. */
  61260. dispose(): void;
  61261. /**
  61262. * Prepares the list of defines specific to the light type.
  61263. * @param defines the list of defines
  61264. * @param lightIndex defines the index of the light for the effect
  61265. */
  61266. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61267. }
  61268. }
  61269. declare module BABYLON {
  61270. /**
  61271. * Gizmo that enables viewing a light
  61272. */
  61273. export class LightGizmo extends Gizmo {
  61274. private _lightMesh;
  61275. private _material;
  61276. private _cachedPosition;
  61277. private _cachedForward;
  61278. private _attachedMeshParent;
  61279. private _pointerObserver;
  61280. /**
  61281. * Event that fires each time the gizmo is clicked
  61282. */
  61283. onClickedObservable: Observable<Light>;
  61284. /**
  61285. * Creates a LightGizmo
  61286. * @param gizmoLayer The utility layer the gizmo will be added to
  61287. */
  61288. constructor(gizmoLayer?: UtilityLayerRenderer);
  61289. private _light;
  61290. /**
  61291. * The light that the gizmo is attached to
  61292. */
  61293. set light(light: Nullable<Light>);
  61294. get light(): Nullable<Light>;
  61295. /**
  61296. * Gets the material used to render the light gizmo
  61297. */
  61298. get material(): StandardMaterial;
  61299. /**
  61300. * @hidden
  61301. * Updates the gizmo to match the attached mesh's position/rotation
  61302. */
  61303. protected _update(): void;
  61304. private static _Scale;
  61305. /**
  61306. * Creates the lines for a light mesh
  61307. */
  61308. private static _CreateLightLines;
  61309. /**
  61310. * Disposes of the light gizmo
  61311. */
  61312. dispose(): void;
  61313. private static _CreateHemisphericLightMesh;
  61314. private static _CreatePointLightMesh;
  61315. private static _CreateSpotLightMesh;
  61316. private static _CreateDirectionalLightMesh;
  61317. }
  61318. }
  61319. declare module BABYLON {
  61320. /**
  61321. * Gizmo that enables viewing a camera
  61322. */
  61323. export class CameraGizmo extends Gizmo {
  61324. private _cameraMesh;
  61325. private _cameraLinesMesh;
  61326. private _material;
  61327. private _pointerObserver;
  61328. /**
  61329. * Event that fires each time the gizmo is clicked
  61330. */
  61331. onClickedObservable: Observable<Camera>;
  61332. /**
  61333. * Creates a CameraGizmo
  61334. * @param gizmoLayer The utility layer the gizmo will be added to
  61335. */
  61336. constructor(gizmoLayer?: UtilityLayerRenderer);
  61337. private _camera;
  61338. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61339. get displayFrustum(): boolean;
  61340. set displayFrustum(value: boolean);
  61341. /**
  61342. * The camera that the gizmo is attached to
  61343. */
  61344. set camera(camera: Nullable<Camera>);
  61345. get camera(): Nullable<Camera>;
  61346. /**
  61347. * Gets the material used to render the camera gizmo
  61348. */
  61349. get material(): StandardMaterial;
  61350. /**
  61351. * @hidden
  61352. * Updates the gizmo to match the attached mesh's position/rotation
  61353. */
  61354. protected _update(): void;
  61355. private static _Scale;
  61356. private _invProjection;
  61357. /**
  61358. * Disposes of the camera gizmo
  61359. */
  61360. dispose(): void;
  61361. private static _CreateCameraMesh;
  61362. private static _CreateCameraFrustum;
  61363. }
  61364. }
  61365. declare module BABYLON {
  61366. /** @hidden */
  61367. export var backgroundFragmentDeclaration: {
  61368. name: string;
  61369. shader: string;
  61370. };
  61371. }
  61372. declare module BABYLON {
  61373. /** @hidden */
  61374. export var backgroundUboDeclaration: {
  61375. name: string;
  61376. shader: string;
  61377. };
  61378. }
  61379. declare module BABYLON {
  61380. /** @hidden */
  61381. export var backgroundPixelShader: {
  61382. name: string;
  61383. shader: string;
  61384. };
  61385. }
  61386. declare module BABYLON {
  61387. /** @hidden */
  61388. export var backgroundVertexDeclaration: {
  61389. name: string;
  61390. shader: string;
  61391. };
  61392. }
  61393. declare module BABYLON {
  61394. /** @hidden */
  61395. export var backgroundVertexShader: {
  61396. name: string;
  61397. shader: string;
  61398. };
  61399. }
  61400. declare module BABYLON {
  61401. /**
  61402. * Background material used to create an efficient environment around your scene.
  61403. */
  61404. export class BackgroundMaterial extends PushMaterial {
  61405. /**
  61406. * Standard reflectance value at parallel view angle.
  61407. */
  61408. static StandardReflectance0: number;
  61409. /**
  61410. * Standard reflectance value at grazing angle.
  61411. */
  61412. static StandardReflectance90: number;
  61413. protected _primaryColor: Color3;
  61414. /**
  61415. * Key light Color (multiply against the environment texture)
  61416. */
  61417. primaryColor: Color3;
  61418. protected __perceptualColor: Nullable<Color3>;
  61419. /**
  61420. * Experimental Internal Use Only.
  61421. *
  61422. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  61423. * This acts as a helper to set the primary color to a more "human friendly" value.
  61424. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  61425. * output color as close as possible from the chosen value.
  61426. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  61427. * part of lighting setup.)
  61428. */
  61429. get _perceptualColor(): Nullable<Color3>;
  61430. set _perceptualColor(value: Nullable<Color3>);
  61431. protected _primaryColorShadowLevel: float;
  61432. /**
  61433. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  61434. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  61435. */
  61436. get primaryColorShadowLevel(): float;
  61437. set primaryColorShadowLevel(value: float);
  61438. protected _primaryColorHighlightLevel: float;
  61439. /**
  61440. * Defines the level of the highlights (highlight area of the reflection map) in order to help scaling the colors.
  61441. * The primary color is used at the level chosen to define what the white area would look.
  61442. */
  61443. get primaryColorHighlightLevel(): float;
  61444. set primaryColorHighlightLevel(value: float);
  61445. protected _reflectionTexture: Nullable<BaseTexture>;
  61446. /**
  61447. * Reflection Texture used in the material.
  61448. * Should be author in a specific way for the best result (refer to the documentation).
  61449. */
  61450. reflectionTexture: Nullable<BaseTexture>;
  61451. protected _reflectionBlur: float;
  61452. /**
  61453. * Reflection Texture level of blur.
  61454. *
  61455. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  61456. * texture twice.
  61457. */
  61458. reflectionBlur: float;
  61459. protected _diffuseTexture: Nullable<BaseTexture>;
  61460. /**
  61461. * Diffuse Texture used in the material.
  61462. * Should be author in a specific way for the best result (refer to the documentation).
  61463. */
  61464. diffuseTexture: Nullable<BaseTexture>;
  61465. protected _shadowLights: Nullable<IShadowLight[]>;
  61466. /**
  61467. * Specify the list of lights casting shadow on the material.
  61468. * All scene shadow lights will be included if null.
  61469. */
  61470. shadowLights: Nullable<IShadowLight[]>;
  61471. protected _shadowLevel: float;
  61472. /**
  61473. * Helps adjusting the shadow to a softer level if required.
  61474. * 0 means black shadows and 1 means no shadows.
  61475. */
  61476. shadowLevel: float;
  61477. protected _sceneCenter: Vector3;
  61478. /**
  61479. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  61480. * It is usually zero but might be interesting to modify according to your setup.
  61481. */
  61482. sceneCenter: Vector3;
  61483. protected _opacityFresnel: boolean;
  61484. /**
  61485. * This helps specifying that the material is falling off to the sky box at grazing angle.
  61486. * This helps ensuring a nice transition when the camera goes under the ground.
  61487. */
  61488. opacityFresnel: boolean;
  61489. protected _reflectionFresnel: boolean;
  61490. /**
  61491. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  61492. * This helps adding a mirror texture on the ground.
  61493. */
  61494. reflectionFresnel: boolean;
  61495. protected _reflectionFalloffDistance: number;
  61496. /**
  61497. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  61498. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  61499. */
  61500. reflectionFalloffDistance: number;
  61501. protected _reflectionAmount: number;
  61502. /**
  61503. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  61504. */
  61505. reflectionAmount: number;
  61506. protected _reflectionReflectance0: number;
  61507. /**
  61508. * This specifies the weight of the reflection at grazing angle.
  61509. */
  61510. reflectionReflectance0: number;
  61511. protected _reflectionReflectance90: number;
  61512. /**
  61513. * This specifies the weight of the reflection at a perpendicular point of view.
  61514. */
  61515. reflectionReflectance90: number;
  61516. /**
  61517. * Sets the reflection reflectance fresnel values according to the default standard
  61518. * empirically know to work well :-)
  61519. */
  61520. set reflectionStandardFresnelWeight(value: number);
  61521. protected _useRGBColor: boolean;
  61522. /**
  61523. * Helps to directly use the maps channels instead of their level.
  61524. */
  61525. useRGBColor: boolean;
  61526. protected _enableNoise: boolean;
  61527. /**
  61528. * This helps reducing the banding effect that could occur on the background.
  61529. */
  61530. enableNoise: boolean;
  61531. /**
  61532. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61533. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  61534. * Recommended to be keep at 1.0 except for special cases.
  61535. */
  61536. get fovMultiplier(): number;
  61537. set fovMultiplier(value: number);
  61538. private _fovMultiplier;
  61539. /**
  61540. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61541. */
  61542. useEquirectangularFOV: boolean;
  61543. private _maxSimultaneousLights;
  61544. /**
  61545. * Number of Simultaneous lights allowed on the material.
  61546. */
  61547. maxSimultaneousLights: int;
  61548. private _shadowOnly;
  61549. /**
  61550. * Make the material only render shadows
  61551. */
  61552. shadowOnly: boolean;
  61553. /**
  61554. * Default configuration related to image processing available in the Background Material.
  61555. */
  61556. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61557. /**
  61558. * Keep track of the image processing observer to allow dispose and replace.
  61559. */
  61560. private _imageProcessingObserver;
  61561. /**
  61562. * Attaches a new image processing configuration to the PBR Material.
  61563. * @param configuration (if null the scene configuration will be use)
  61564. */
  61565. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61566. /**
  61567. * Gets the image processing configuration used either in this material.
  61568. */
  61569. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61570. /**
  61571. * Sets the Default image processing configuration used either in the this material.
  61572. *
  61573. * If sets to null, the scene one is in use.
  61574. */
  61575. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61576. /**
  61577. * Gets whether the color curves effect is enabled.
  61578. */
  61579. get cameraColorCurvesEnabled(): boolean;
  61580. /**
  61581. * Sets whether the color curves effect is enabled.
  61582. */
  61583. set cameraColorCurvesEnabled(value: boolean);
  61584. /**
  61585. * Gets whether the color grading effect is enabled.
  61586. */
  61587. get cameraColorGradingEnabled(): boolean;
  61588. /**
  61589. * Gets whether the color grading effect is enabled.
  61590. */
  61591. set cameraColorGradingEnabled(value: boolean);
  61592. /**
  61593. * Gets whether tonemapping is enabled or not.
  61594. */
  61595. get cameraToneMappingEnabled(): boolean;
  61596. /**
  61597. * Sets whether tonemapping is enabled or not
  61598. */
  61599. set cameraToneMappingEnabled(value: boolean);
  61600. /**
  61601. * The camera exposure used on this material.
  61602. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61603. * This corresponds to a photographic exposure.
  61604. */
  61605. get cameraExposure(): float;
  61606. /**
  61607. * The camera exposure used on this material.
  61608. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61609. * This corresponds to a photographic exposure.
  61610. */
  61611. set cameraExposure(value: float);
  61612. /**
  61613. * Gets The camera contrast used on this material.
  61614. */
  61615. get cameraContrast(): float;
  61616. /**
  61617. * Sets The camera contrast used on this material.
  61618. */
  61619. set cameraContrast(value: float);
  61620. /**
  61621. * Gets the Color Grading 2D Lookup Texture.
  61622. */
  61623. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61624. /**
  61625. * Sets the Color Grading 2D Lookup Texture.
  61626. */
  61627. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61628. /**
  61629. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  61630. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61631. * 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;
  61632. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61633. */
  61634. get cameraColorCurves(): Nullable<ColorCurves>;
  61635. /**
  61636. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  61637. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61638. * 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;
  61639. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61640. */
  61641. set cameraColorCurves(value: Nullable<ColorCurves>);
  61642. /**
  61643. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61644. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61645. */
  61646. switchToBGR: boolean;
  61647. private _renderTargets;
  61648. private _reflectionControls;
  61649. private _white;
  61650. private _primaryShadowColor;
  61651. private _primaryHighlightColor;
  61652. /**
  61653. * Instantiates a Background Material in the given scene
  61654. * @param name The friendly name of the material
  61655. * @param scene The scene to add the material to
  61656. */
  61657. constructor(name: string, scene: Scene);
  61658. /**
  61659. * Gets a boolean indicating that current material needs to register RTT
  61660. */
  61661. get hasRenderTargetTextures(): boolean;
  61662. /**
  61663. * The entire material has been created in order to prevent overdraw.
  61664. * @returns false
  61665. */
  61666. needAlphaTesting(): boolean;
  61667. /**
  61668. * The entire material has been created in order to prevent overdraw.
  61669. * @returns true if blending is enable
  61670. */
  61671. needAlphaBlending(): boolean;
  61672. /**
  61673. * Checks whether the material is ready to be rendered for a given mesh.
  61674. * @param mesh The mesh to render
  61675. * @param subMesh The submesh to check against
  61676. * @param useInstances Specify wether or not the material is used with instances
  61677. * @returns true if all the dependencies are ready (Textures, Effects...)
  61678. */
  61679. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61680. /**
  61681. * Compute the primary color according to the chosen perceptual color.
  61682. */
  61683. private _computePrimaryColorFromPerceptualColor;
  61684. /**
  61685. * Compute the highlights and shadow colors according to their chosen levels.
  61686. */
  61687. private _computePrimaryColors;
  61688. /**
  61689. * Build the uniform buffer used in the material.
  61690. */
  61691. buildUniformLayout(): void;
  61692. /**
  61693. * Unbind the material.
  61694. */
  61695. unbind(): void;
  61696. /**
  61697. * Bind only the world matrix to the material.
  61698. * @param world The world matrix to bind.
  61699. */
  61700. bindOnlyWorldMatrix(world: Matrix): void;
  61701. /**
  61702. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61703. * @param world The world matrix to bind.
  61704. * @param subMesh The submesh to bind for.
  61705. */
  61706. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61707. /**
  61708. * Checks to see if a texture is used in the material.
  61709. * @param texture - Base texture to use.
  61710. * @returns - Boolean specifying if a texture is used in the material.
  61711. */
  61712. hasTexture(texture: BaseTexture): boolean;
  61713. /**
  61714. * Dispose the material.
  61715. * @param forceDisposeEffect Force disposal of the associated effect.
  61716. * @param forceDisposeTextures Force disposal of the associated textures.
  61717. */
  61718. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61719. /**
  61720. * Clones the material.
  61721. * @param name The cloned name.
  61722. * @returns The cloned material.
  61723. */
  61724. clone(name: string): BackgroundMaterial;
  61725. /**
  61726. * Serializes the current material to its JSON representation.
  61727. * @returns The JSON representation.
  61728. */
  61729. serialize(): any;
  61730. /**
  61731. * Gets the class name of the material
  61732. * @returns "BackgroundMaterial"
  61733. */
  61734. getClassName(): string;
  61735. /**
  61736. * Parse a JSON input to create back a background material.
  61737. * @param source The JSON data to parse
  61738. * @param scene The scene to create the parsed material in
  61739. * @param rootUrl The root url of the assets the material depends upon
  61740. * @returns the instantiated BackgroundMaterial.
  61741. */
  61742. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61743. }
  61744. }
  61745. declare module BABYLON {
  61746. /**
  61747. * Represents the different options available during the creation of
  61748. * a Environment helper.
  61749. *
  61750. * This can control the default ground, skybox and image processing setup of your scene.
  61751. */
  61752. export interface IEnvironmentHelperOptions {
  61753. /**
  61754. * Specifies whether or not to create a ground.
  61755. * True by default.
  61756. */
  61757. createGround: boolean;
  61758. /**
  61759. * Specifies the ground size.
  61760. * 15 by default.
  61761. */
  61762. groundSize: number;
  61763. /**
  61764. * The texture used on the ground for the main color.
  61765. * Comes from the BabylonJS CDN by default.
  61766. *
  61767. * Remarks: Can be either a texture or a url.
  61768. */
  61769. groundTexture: string | BaseTexture;
  61770. /**
  61771. * The color mixed in the ground texture by default.
  61772. * BabylonJS clearColor by default.
  61773. */
  61774. groundColor: Color3;
  61775. /**
  61776. * Specifies the ground opacity.
  61777. * 1 by default.
  61778. */
  61779. groundOpacity: number;
  61780. /**
  61781. * Enables the ground to receive shadows.
  61782. * True by default.
  61783. */
  61784. enableGroundShadow: boolean;
  61785. /**
  61786. * Helps preventing the shadow to be fully black on the ground.
  61787. * 0.5 by default.
  61788. */
  61789. groundShadowLevel: number;
  61790. /**
  61791. * Creates a mirror texture attach to the ground.
  61792. * false by default.
  61793. */
  61794. enableGroundMirror: boolean;
  61795. /**
  61796. * Specifies the ground mirror size ratio.
  61797. * 0.3 by default as the default kernel is 64.
  61798. */
  61799. groundMirrorSizeRatio: number;
  61800. /**
  61801. * Specifies the ground mirror blur kernel size.
  61802. * 64 by default.
  61803. */
  61804. groundMirrorBlurKernel: number;
  61805. /**
  61806. * Specifies the ground mirror visibility amount.
  61807. * 1 by default
  61808. */
  61809. groundMirrorAmount: number;
  61810. /**
  61811. * Specifies the ground mirror reflectance weight.
  61812. * This uses the standard weight of the background material to setup the fresnel effect
  61813. * of the mirror.
  61814. * 1 by default.
  61815. */
  61816. groundMirrorFresnelWeight: number;
  61817. /**
  61818. * Specifies the ground mirror Falloff distance.
  61819. * This can helps reducing the size of the reflection.
  61820. * 0 by Default.
  61821. */
  61822. groundMirrorFallOffDistance: number;
  61823. /**
  61824. * Specifies the ground mirror texture type.
  61825. * Unsigned Int by Default.
  61826. */
  61827. groundMirrorTextureType: number;
  61828. /**
  61829. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61830. * the shown objects.
  61831. */
  61832. groundYBias: number;
  61833. /**
  61834. * Specifies whether or not to create a skybox.
  61835. * True by default.
  61836. */
  61837. createSkybox: boolean;
  61838. /**
  61839. * Specifies the skybox size.
  61840. * 20 by default.
  61841. */
  61842. skyboxSize: number;
  61843. /**
  61844. * The texture used on the skybox for the main color.
  61845. * Comes from the BabylonJS CDN by default.
  61846. *
  61847. * Remarks: Can be either a texture or a url.
  61848. */
  61849. skyboxTexture: string | BaseTexture;
  61850. /**
  61851. * The color mixed in the skybox texture by default.
  61852. * BabylonJS clearColor by default.
  61853. */
  61854. skyboxColor: Color3;
  61855. /**
  61856. * The background rotation around the Y axis of the scene.
  61857. * This helps aligning the key lights of your scene with the background.
  61858. * 0 by default.
  61859. */
  61860. backgroundYRotation: number;
  61861. /**
  61862. * Compute automatically the size of the elements to best fit with the scene.
  61863. */
  61864. sizeAuto: boolean;
  61865. /**
  61866. * Default position of the rootMesh if autoSize is not true.
  61867. */
  61868. rootPosition: Vector3;
  61869. /**
  61870. * Sets up the image processing in the scene.
  61871. * true by default.
  61872. */
  61873. setupImageProcessing: boolean;
  61874. /**
  61875. * The texture used as your environment texture in the scene.
  61876. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61877. *
  61878. * Remarks: Can be either a texture or a url.
  61879. */
  61880. environmentTexture: string | BaseTexture;
  61881. /**
  61882. * The value of the exposure to apply to the scene.
  61883. * 0.6 by default if setupImageProcessing is true.
  61884. */
  61885. cameraExposure: number;
  61886. /**
  61887. * The value of the contrast to apply to the scene.
  61888. * 1.6 by default if setupImageProcessing is true.
  61889. */
  61890. cameraContrast: number;
  61891. /**
  61892. * Specifies whether or not tonemapping should be enabled in the scene.
  61893. * true by default if setupImageProcessing is true.
  61894. */
  61895. toneMappingEnabled: boolean;
  61896. }
  61897. /**
  61898. * The Environment helper class can be used to add a fully featured none expensive background to your scene.
  61899. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61900. * It also helps with the default setup of your imageProcessing configuration.
  61901. */
  61902. export class EnvironmentHelper {
  61903. /**
  61904. * Default ground texture URL.
  61905. */
  61906. private static _groundTextureCDNUrl;
  61907. /**
  61908. * Default skybox texture URL.
  61909. */
  61910. private static _skyboxTextureCDNUrl;
  61911. /**
  61912. * Default environment texture URL.
  61913. */
  61914. private static _environmentTextureCDNUrl;
  61915. /**
  61916. * Creates the default options for the helper.
  61917. */
  61918. private static _getDefaultOptions;
  61919. private _rootMesh;
  61920. /**
  61921. * Gets the root mesh created by the helper.
  61922. */
  61923. get rootMesh(): Mesh;
  61924. private _skybox;
  61925. /**
  61926. * Gets the skybox created by the helper.
  61927. */
  61928. get skybox(): Nullable<Mesh>;
  61929. private _skyboxTexture;
  61930. /**
  61931. * Gets the skybox texture created by the helper.
  61932. */
  61933. get skyboxTexture(): Nullable<BaseTexture>;
  61934. private _skyboxMaterial;
  61935. /**
  61936. * Gets the skybox material created by the helper.
  61937. */
  61938. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61939. private _ground;
  61940. /**
  61941. * Gets the ground mesh created by the helper.
  61942. */
  61943. get ground(): Nullable<Mesh>;
  61944. private _groundTexture;
  61945. /**
  61946. * Gets the ground texture created by the helper.
  61947. */
  61948. get groundTexture(): Nullable<BaseTexture>;
  61949. private _groundMirror;
  61950. /**
  61951. * Gets the ground mirror created by the helper.
  61952. */
  61953. get groundMirror(): Nullable<MirrorTexture>;
  61954. /**
  61955. * Gets the ground mirror render list to helps pushing the meshes
  61956. * you wish in the ground reflection.
  61957. */
  61958. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61959. private _groundMaterial;
  61960. /**
  61961. * Gets the ground material created by the helper.
  61962. */
  61963. get groundMaterial(): Nullable<BackgroundMaterial>;
  61964. /**
  61965. * Stores the creation options.
  61966. */
  61967. private readonly _scene;
  61968. private _options;
  61969. /**
  61970. * This observable will be notified with any error during the creation of the environment,
  61971. * mainly texture creation errors.
  61972. */
  61973. onErrorObservable: Observable<{
  61974. message?: string;
  61975. exception?: any;
  61976. }>;
  61977. /**
  61978. * constructor
  61979. * @param options Defines the options we want to customize the helper
  61980. * @param scene The scene to add the material to
  61981. */
  61982. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61983. /**
  61984. * Updates the background according to the new options
  61985. * @param options
  61986. */
  61987. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61988. /**
  61989. * Sets the primary color of all the available elements.
  61990. * @param color the main color to affect to the ground and the background
  61991. */
  61992. setMainColor(color: Color3): void;
  61993. /**
  61994. * Setup the image processing according to the specified options.
  61995. */
  61996. private _setupImageProcessing;
  61997. /**
  61998. * Setup the environment texture according to the specified options.
  61999. */
  62000. private _setupEnvironmentTexture;
  62001. /**
  62002. * Setup the background according to the specified options.
  62003. */
  62004. private _setupBackground;
  62005. /**
  62006. * Get the scene sizes according to the setup.
  62007. */
  62008. private _getSceneSize;
  62009. /**
  62010. * Setup the ground according to the specified options.
  62011. */
  62012. private _setupGround;
  62013. /**
  62014. * Setup the ground material according to the specified options.
  62015. */
  62016. private _setupGroundMaterial;
  62017. /**
  62018. * Setup the ground diffuse texture according to the specified options.
  62019. */
  62020. private _setupGroundDiffuseTexture;
  62021. /**
  62022. * Setup the ground mirror texture according to the specified options.
  62023. */
  62024. private _setupGroundMirrorTexture;
  62025. /**
  62026. * Setup the ground to receive the mirror texture.
  62027. */
  62028. private _setupMirrorInGroundMaterial;
  62029. /**
  62030. * Setup the skybox according to the specified options.
  62031. */
  62032. private _setupSkybox;
  62033. /**
  62034. * Setup the skybox material according to the specified options.
  62035. */
  62036. private _setupSkyboxMaterial;
  62037. /**
  62038. * Setup the skybox reflection texture according to the specified options.
  62039. */
  62040. private _setupSkyboxReflectionTexture;
  62041. private _errorHandler;
  62042. /**
  62043. * Dispose all the elements created by the Helper.
  62044. */
  62045. dispose(): void;
  62046. }
  62047. }
  62048. declare module BABYLON {
  62049. /**
  62050. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  62051. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  62052. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62053. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62054. */
  62055. export abstract class TextureDome<T extends Texture> extends TransformNode {
  62056. protected onError: Nullable<(message?: string, exception?: any) => void>;
  62057. /**
  62058. * Define the source as a Monoscopic panoramic 360/180.
  62059. */
  62060. static readonly MODE_MONOSCOPIC: number;
  62061. /**
  62062. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  62063. */
  62064. static readonly MODE_TOPBOTTOM: number;
  62065. /**
  62066. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  62067. */
  62068. static readonly MODE_SIDEBYSIDE: number;
  62069. private _halfDome;
  62070. private _crossEye;
  62071. protected _useDirectMapping: boolean;
  62072. /**
  62073. * The texture being displayed on the sphere
  62074. */
  62075. protected _texture: T;
  62076. /**
  62077. * Gets the texture being displayed on the sphere
  62078. */
  62079. get texture(): T;
  62080. /**
  62081. * Sets the texture being displayed on the sphere
  62082. */
  62083. set texture(newTexture: T);
  62084. /**
  62085. * The skybox material
  62086. */
  62087. protected _material: BackgroundMaterial;
  62088. /**
  62089. * The surface used for the dome
  62090. */
  62091. protected _mesh: Mesh;
  62092. /**
  62093. * Gets the mesh used for the dome.
  62094. */
  62095. get mesh(): Mesh;
  62096. /**
  62097. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  62098. */
  62099. private _halfDomeMask;
  62100. /**
  62101. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  62102. * Also see the options.resolution property.
  62103. */
  62104. get fovMultiplier(): number;
  62105. set fovMultiplier(value: number);
  62106. protected _textureMode: number;
  62107. /**
  62108. * Gets or set the current texture mode for the texture. It can be:
  62109. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62110. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62111. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62112. */
  62113. get textureMode(): number;
  62114. /**
  62115. * Sets the current texture mode for the texture. It can be:
  62116. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62117. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62118. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62119. */
  62120. set textureMode(value: number);
  62121. /**
  62122. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  62123. */
  62124. get halfDome(): boolean;
  62125. /**
  62126. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  62127. */
  62128. set halfDome(enabled: boolean);
  62129. /**
  62130. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  62131. */
  62132. set crossEye(enabled: boolean);
  62133. /**
  62134. * Is it a cross-eye texture?
  62135. */
  62136. get crossEye(): boolean;
  62137. /**
  62138. * The background material of this dome.
  62139. */
  62140. get material(): BackgroundMaterial;
  62141. /**
  62142. * Oberserver used in Stereoscopic VR Mode.
  62143. */
  62144. private _onBeforeCameraRenderObserver;
  62145. /**
  62146. * Observable raised when an error occurred while loading the texture
  62147. */
  62148. onLoadErrorObservable: Observable<string>;
  62149. /**
  62150. * Observable raised when the texture finished loading
  62151. */
  62152. onLoadObservable: Observable<void>;
  62153. /**
  62154. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  62155. * @param name Element's name, child elements will append suffixes for their own names.
  62156. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  62157. * @param options An object containing optional or exposed sub element properties
  62158. */
  62159. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  62160. resolution?: number;
  62161. clickToPlay?: boolean;
  62162. autoPlay?: boolean;
  62163. loop?: boolean;
  62164. size?: number;
  62165. poster?: string;
  62166. faceForward?: boolean;
  62167. useDirectMapping?: boolean;
  62168. halfDomeMode?: boolean;
  62169. crossEyeMode?: boolean;
  62170. generateMipMaps?: boolean;
  62171. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  62172. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  62173. protected _changeTextureMode(value: number): void;
  62174. /**
  62175. * Releases resources associated with this node.
  62176. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  62177. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  62178. */
  62179. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  62180. }
  62181. }
  62182. declare module BABYLON {
  62183. /**
  62184. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  62185. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  62186. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62187. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62188. */
  62189. export class PhotoDome extends TextureDome<Texture> {
  62190. /**
  62191. * Define the image as a Monoscopic panoramic 360 image.
  62192. */
  62193. static readonly MODE_MONOSCOPIC: number;
  62194. /**
  62195. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  62196. */
  62197. static readonly MODE_TOPBOTTOM: number;
  62198. /**
  62199. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  62200. */
  62201. static readonly MODE_SIDEBYSIDE: number;
  62202. /**
  62203. * Gets or sets the texture being displayed on the sphere
  62204. */
  62205. get photoTexture(): Texture;
  62206. /**
  62207. * sets the texture being displayed on the sphere
  62208. */
  62209. set photoTexture(value: Texture);
  62210. /**
  62211. * Gets the current video mode for the video. It can be:
  62212. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62213. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62214. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62215. */
  62216. get imageMode(): number;
  62217. /**
  62218. * Sets the current video mode for the video. It can be:
  62219. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62220. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62221. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62222. */
  62223. set imageMode(value: number);
  62224. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  62225. }
  62226. }
  62227. declare module BABYLON {
  62228. /**
  62229. * Direct draw surface info
  62230. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  62231. */
  62232. export interface DDSInfo {
  62233. /**
  62234. * Width of the texture
  62235. */
  62236. width: number;
  62237. /**
  62238. * Width of the texture
  62239. */
  62240. height: number;
  62241. /**
  62242. * Number of Mipmaps for the texture
  62243. * @see https://en.wikipedia.org/wiki/Mipmap
  62244. */
  62245. mipmapCount: number;
  62246. /**
  62247. * If the textures format is a known fourCC format
  62248. * @see https://www.fourcc.org/
  62249. */
  62250. isFourCC: boolean;
  62251. /**
  62252. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  62253. */
  62254. isRGB: boolean;
  62255. /**
  62256. * If the texture is a lumincance format
  62257. */
  62258. isLuminance: boolean;
  62259. /**
  62260. * If this is a cube texture
  62261. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  62262. */
  62263. isCube: boolean;
  62264. /**
  62265. * If the texture is a compressed format eg. FOURCC_DXT1
  62266. */
  62267. isCompressed: boolean;
  62268. /**
  62269. * The dxgiFormat of the texture
  62270. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  62271. */
  62272. dxgiFormat: number;
  62273. /**
  62274. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  62275. */
  62276. textureType: number;
  62277. /**
  62278. * Sphericle polynomial created for the dds texture
  62279. */
  62280. sphericalPolynomial?: SphericalPolynomial;
  62281. }
  62282. /**
  62283. * Class used to provide DDS decompression tools
  62284. */
  62285. export class DDSTools {
  62286. /**
  62287. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  62288. */
  62289. static StoreLODInAlphaChannel: boolean;
  62290. /**
  62291. * Gets DDS information from an array buffer
  62292. * @param data defines the array buffer view to read data from
  62293. * @returns the DDS information
  62294. */
  62295. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  62296. private static _FloatView;
  62297. private static _Int32View;
  62298. private static _ToHalfFloat;
  62299. private static _FromHalfFloat;
  62300. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  62301. private static _GetHalfFloatRGBAArrayBuffer;
  62302. private static _GetFloatRGBAArrayBuffer;
  62303. private static _GetFloatAsUIntRGBAArrayBuffer;
  62304. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  62305. private static _GetRGBAArrayBuffer;
  62306. private static _ExtractLongWordOrder;
  62307. private static _GetRGBArrayBuffer;
  62308. private static _GetLuminanceArrayBuffer;
  62309. /**
  62310. * Uploads DDS Levels to a Babylon Texture
  62311. * @hidden
  62312. */
  62313. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  62314. }
  62315. interface ThinEngine {
  62316. /**
  62317. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62318. * @param rootUrl defines the url where the file to load is located
  62319. * @param scene defines the current scene
  62320. * @param lodScale defines scale to apply to the mip map selection
  62321. * @param lodOffset defines offset to apply to the mip map selection
  62322. * @param onLoad defines an optional callback raised when the texture is loaded
  62323. * @param onError defines an optional callback raised if there is an issue to load the texture
  62324. * @param format defines the format of the data
  62325. * @param forcedExtension defines the extension to use to pick the right loader
  62326. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62327. * @returns the cube texture as an InternalTexture
  62328. */
  62329. 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;
  62330. }
  62331. }
  62332. declare module BABYLON {
  62333. /**
  62334. * Implementation of the DDS Texture Loader.
  62335. * @hidden
  62336. */
  62337. export class _DDSTextureLoader implements IInternalTextureLoader {
  62338. /**
  62339. * Defines whether the loader supports cascade loading the different faces.
  62340. */
  62341. readonly supportCascades: boolean;
  62342. /**
  62343. * This returns if the loader support the current file information.
  62344. * @param extension defines the file extension of the file being loaded
  62345. * @returns true if the loader can load the specified file
  62346. */
  62347. canLoad(extension: string): boolean;
  62348. /**
  62349. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62350. * @param data contains the texture data
  62351. * @param texture defines the BabylonJS internal texture
  62352. * @param createPolynomials will be true if polynomials have been requested
  62353. * @param onLoad defines the callback to trigger once the texture is ready
  62354. * @param onError defines the callback to trigger in case of error
  62355. */
  62356. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62357. /**
  62358. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62359. * @param data contains the texture data
  62360. * @param texture defines the BabylonJS internal texture
  62361. * @param callback defines the method to call once ready to upload
  62362. */
  62363. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62364. }
  62365. }
  62366. declare module BABYLON {
  62367. /**
  62368. * Implementation of the ENV Texture Loader.
  62369. * @hidden
  62370. */
  62371. export class _ENVTextureLoader implements IInternalTextureLoader {
  62372. /**
  62373. * Defines whether the loader supports cascade loading the different faces.
  62374. */
  62375. readonly supportCascades: boolean;
  62376. /**
  62377. * This returns if the loader support the current file information.
  62378. * @param extension defines the file extension of the file being loaded
  62379. * @returns true if the loader can load the specified file
  62380. */
  62381. canLoad(extension: string): boolean;
  62382. /**
  62383. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62384. * @param data contains the texture data
  62385. * @param texture defines the BabylonJS internal texture
  62386. * @param createPolynomials will be true if polynomials have been requested
  62387. * @param onLoad defines the callback to trigger once the texture is ready
  62388. * @param onError defines the callback to trigger in case of error
  62389. */
  62390. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62391. /**
  62392. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62393. * @param data contains the texture data
  62394. * @param texture defines the BabylonJS internal texture
  62395. * @param callback defines the method to call once ready to upload
  62396. */
  62397. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62398. }
  62399. }
  62400. declare module BABYLON {
  62401. /**
  62402. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62403. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62404. */
  62405. export class KhronosTextureContainer {
  62406. /** contents of the KTX container file */
  62407. data: ArrayBufferView;
  62408. private static HEADER_LEN;
  62409. private static COMPRESSED_2D;
  62410. private static COMPRESSED_3D;
  62411. private static TEX_2D;
  62412. private static TEX_3D;
  62413. /**
  62414. * Gets the openGL type
  62415. */
  62416. glType: number;
  62417. /**
  62418. * Gets the openGL type size
  62419. */
  62420. glTypeSize: number;
  62421. /**
  62422. * Gets the openGL format
  62423. */
  62424. glFormat: number;
  62425. /**
  62426. * Gets the openGL internal format
  62427. */
  62428. glInternalFormat: number;
  62429. /**
  62430. * Gets the base internal format
  62431. */
  62432. glBaseInternalFormat: number;
  62433. /**
  62434. * Gets image width in pixel
  62435. */
  62436. pixelWidth: number;
  62437. /**
  62438. * Gets image height in pixel
  62439. */
  62440. pixelHeight: number;
  62441. /**
  62442. * Gets image depth in pixels
  62443. */
  62444. pixelDepth: number;
  62445. /**
  62446. * Gets the number of array elements
  62447. */
  62448. numberOfArrayElements: number;
  62449. /**
  62450. * Gets the number of faces
  62451. */
  62452. numberOfFaces: number;
  62453. /**
  62454. * Gets the number of mipmap levels
  62455. */
  62456. numberOfMipmapLevels: number;
  62457. /**
  62458. * Gets the bytes of key value data
  62459. */
  62460. bytesOfKeyValueData: number;
  62461. /**
  62462. * Gets the load type
  62463. */
  62464. loadType: number;
  62465. /**
  62466. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  62467. */
  62468. isInvalid: boolean;
  62469. /**
  62470. * Creates a new KhronosTextureContainer
  62471. * @param data contents of the KTX container file
  62472. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  62473. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  62474. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  62475. */
  62476. constructor(
  62477. /** contents of the KTX container file */
  62478. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  62479. /**
  62480. * Uploads KTX content to a Babylon Texture.
  62481. * It is assumed that the texture has already been created & is currently bound
  62482. * @hidden
  62483. */
  62484. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  62485. private _upload2DCompressedLevels;
  62486. /**
  62487. * Checks if the given data starts with a KTX file identifier.
  62488. * @param data the data to check
  62489. * @returns true if the data is a KTX file or false otherwise
  62490. */
  62491. static IsValid(data: ArrayBufferView): boolean;
  62492. }
  62493. }
  62494. declare module BABYLON {
  62495. /**
  62496. * Helper class to push actions to a pool of workers.
  62497. */
  62498. export class WorkerPool implements IDisposable {
  62499. private _workerInfos;
  62500. private _pendingActions;
  62501. /**
  62502. * Constructor
  62503. * @param workers Array of workers to use for actions
  62504. */
  62505. constructor(workers: Array<Worker>);
  62506. /**
  62507. * Terminates all workers and clears any pending actions.
  62508. */
  62509. dispose(): void;
  62510. /**
  62511. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62512. * pended until a worker has completed its action.
  62513. * @param action The action to perform. Call onComplete when the action is complete.
  62514. */
  62515. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62516. private _execute;
  62517. }
  62518. }
  62519. declare module BABYLON {
  62520. /**
  62521. * Class for loading KTX2 files
  62522. */
  62523. export class KhronosTextureContainer2 {
  62524. private static _WorkerPoolPromise?;
  62525. private static _Initialized;
  62526. private static _Ktx2Decoder;
  62527. /**
  62528. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62529. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62530. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62531. * Urls you can change:
  62532. * URLConfig.jsDecoderModule
  62533. * URLConfig.wasmUASTCToASTC
  62534. * URLConfig.wasmUASTCToBC7
  62535. * URLConfig.wasmUASTCToRGBA_UNORM
  62536. * URLConfig.wasmUASTCToRGBA_SRGB
  62537. * URLConfig.jsMSCTranscoder
  62538. * URLConfig.wasmMSCTranscoder
  62539. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  62540. */
  62541. static URLConfig: {
  62542. jsDecoderModule: string;
  62543. wasmUASTCToASTC: null;
  62544. wasmUASTCToBC7: null;
  62545. wasmUASTCToRGBA_UNORM: null;
  62546. wasmUASTCToRGBA_SRGB: null;
  62547. jsMSCTranscoder: null;
  62548. wasmMSCTranscoder: null;
  62549. };
  62550. /**
  62551. * Default number of workers used to handle data decoding
  62552. */
  62553. static DefaultNumWorkers: number;
  62554. private static GetDefaultNumWorkers;
  62555. private _engine;
  62556. private static _CreateWorkerPool;
  62557. /**
  62558. * Constructor
  62559. * @param engine The engine to use
  62560. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62561. */
  62562. constructor(engine: ThinEngine, numWorkers?: number);
  62563. /** @hidden */
  62564. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62565. /**
  62566. * Stop all async operations and release resources.
  62567. */
  62568. dispose(): void;
  62569. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62570. /**
  62571. * Checks if the given data starts with a KTX2 file identifier.
  62572. * @param data the data to check
  62573. * @returns true if the data is a KTX2 file or false otherwise
  62574. */
  62575. static IsValid(data: ArrayBufferView): boolean;
  62576. }
  62577. }
  62578. declare module BABYLON {
  62579. /**
  62580. * Implementation of the KTX Texture Loader.
  62581. * @hidden
  62582. */
  62583. export class _KTXTextureLoader implements IInternalTextureLoader {
  62584. /**
  62585. * Defines whether the loader supports cascade loading the different faces.
  62586. */
  62587. readonly supportCascades: boolean;
  62588. /**
  62589. * This returns if the loader support the current file information.
  62590. * @param extension defines the file extension of the file being loaded
  62591. * @param mimeType defines the optional mime type of the file being loaded
  62592. * @returns true if the loader can load the specified file
  62593. */
  62594. canLoad(extension: string, mimeType?: string): boolean;
  62595. /**
  62596. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62597. * @param data contains the texture data
  62598. * @param texture defines the BabylonJS internal texture
  62599. * @param createPolynomials will be true if polynomials have been requested
  62600. * @param onLoad defines the callback to trigger once the texture is ready
  62601. * @param onError defines the callback to trigger in case of error
  62602. */
  62603. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62604. /**
  62605. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62606. * @param data contains the texture data
  62607. * @param texture defines the BabylonJS internal texture
  62608. * @param callback defines the method to call once ready to upload
  62609. */
  62610. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62611. }
  62612. }
  62613. declare module BABYLON {
  62614. /** @hidden */
  62615. export var _forceSceneHelpersToBundle: boolean;
  62616. interface Scene {
  62617. /**
  62618. * Creates a default light for the scene.
  62619. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62620. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62621. */
  62622. createDefaultLight(replace?: boolean): void;
  62623. /**
  62624. * Creates a default camera for the scene.
  62625. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62626. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62627. * @param replace has default false, when true replaces the active camera in the scene
  62628. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62629. */
  62630. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62631. /**
  62632. * Creates a default camera and a default light.
  62633. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62634. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62635. * @param replace has the default false, when true replaces the active camera/light in the scene
  62636. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62637. */
  62638. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62639. /**
  62640. * Creates a new sky box
  62641. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62642. * @param environmentTexture defines the texture to use as environment texture
  62643. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62644. * @param scale defines the overall scale of the skybox
  62645. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62646. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62647. * @returns a new mesh holding the sky box
  62648. */
  62649. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62650. /**
  62651. * Creates a new environment
  62652. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62653. * @param options defines the options you can use to configure the environment
  62654. * @returns the new EnvironmentHelper
  62655. */
  62656. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62657. /**
  62658. * Creates a new VREXperienceHelper
  62659. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62660. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62661. * @returns a new VREXperienceHelper
  62662. */
  62663. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62664. /**
  62665. * Creates a new WebXRDefaultExperience
  62666. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62667. * @param options experience options
  62668. * @returns a promise for a new WebXRDefaultExperience
  62669. */
  62670. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62671. }
  62672. }
  62673. declare module BABYLON {
  62674. /**
  62675. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62676. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62677. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62678. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62679. */
  62680. export class VideoDome extends TextureDome<VideoTexture> {
  62681. /**
  62682. * Define the video source as a Monoscopic panoramic 360 video.
  62683. */
  62684. static readonly MODE_MONOSCOPIC: number;
  62685. /**
  62686. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62687. */
  62688. static readonly MODE_TOPBOTTOM: number;
  62689. /**
  62690. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62691. */
  62692. static readonly MODE_SIDEBYSIDE: number;
  62693. /**
  62694. * Get the video texture associated with this video dome
  62695. */
  62696. get videoTexture(): VideoTexture;
  62697. /**
  62698. * Get the video mode of this dome
  62699. */
  62700. get videoMode(): number;
  62701. /**
  62702. * Set the video mode of this dome.
  62703. * @see textureMode
  62704. */
  62705. set videoMode(value: number);
  62706. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62707. }
  62708. }
  62709. declare module BABYLON {
  62710. /**
  62711. * This class can be used to get instrumentation data from a Babylon engine
  62712. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62713. */
  62714. export class EngineInstrumentation implements IDisposable {
  62715. /**
  62716. * Define the instrumented engine.
  62717. */
  62718. engine: Engine;
  62719. private _captureGPUFrameTime;
  62720. private _gpuFrameTimeToken;
  62721. private _gpuFrameTime;
  62722. private _captureShaderCompilationTime;
  62723. private _shaderCompilationTime;
  62724. private _onBeginFrameObserver;
  62725. private _onEndFrameObserver;
  62726. private _onBeforeShaderCompilationObserver;
  62727. private _onAfterShaderCompilationObserver;
  62728. /**
  62729. * Gets the perf counter used for GPU frame time
  62730. */
  62731. get gpuFrameTimeCounter(): PerfCounter;
  62732. /**
  62733. * Gets the GPU frame time capture status
  62734. */
  62735. get captureGPUFrameTime(): boolean;
  62736. /**
  62737. * Enable or disable the GPU frame time capture
  62738. */
  62739. set captureGPUFrameTime(value: boolean);
  62740. /**
  62741. * Gets the perf counter used for shader compilation time
  62742. */
  62743. get shaderCompilationTimeCounter(): PerfCounter;
  62744. /**
  62745. * Gets the shader compilation time capture status
  62746. */
  62747. get captureShaderCompilationTime(): boolean;
  62748. /**
  62749. * Enable or disable the shader compilation time capture
  62750. */
  62751. set captureShaderCompilationTime(value: boolean);
  62752. /**
  62753. * Instantiates a new engine instrumentation.
  62754. * This class can be used to get instrumentation data from a Babylon engine
  62755. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62756. * @param engine Defines the engine to instrument
  62757. */
  62758. constructor(
  62759. /**
  62760. * Define the instrumented engine.
  62761. */
  62762. engine: Engine);
  62763. /**
  62764. * Dispose and release associated resources.
  62765. */
  62766. dispose(): void;
  62767. }
  62768. }
  62769. declare module BABYLON {
  62770. /**
  62771. * This class can be used to get instrumentation data from a Babylon engine
  62772. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62773. */
  62774. export class SceneInstrumentation implements IDisposable {
  62775. /**
  62776. * Defines the scene to instrument
  62777. */
  62778. scene: Scene;
  62779. private _captureActiveMeshesEvaluationTime;
  62780. private _activeMeshesEvaluationTime;
  62781. private _captureRenderTargetsRenderTime;
  62782. private _renderTargetsRenderTime;
  62783. private _captureFrameTime;
  62784. private _frameTime;
  62785. private _captureRenderTime;
  62786. private _renderTime;
  62787. private _captureInterFrameTime;
  62788. private _interFrameTime;
  62789. private _captureParticlesRenderTime;
  62790. private _particlesRenderTime;
  62791. private _captureSpritesRenderTime;
  62792. private _spritesRenderTime;
  62793. private _capturePhysicsTime;
  62794. private _physicsTime;
  62795. private _captureAnimationsTime;
  62796. private _animationsTime;
  62797. private _captureCameraRenderTime;
  62798. private _cameraRenderTime;
  62799. private _onBeforeActiveMeshesEvaluationObserver;
  62800. private _onAfterActiveMeshesEvaluationObserver;
  62801. private _onBeforeRenderTargetsRenderObserver;
  62802. private _onAfterRenderTargetsRenderObserver;
  62803. private _onAfterRenderObserver;
  62804. private _onBeforeDrawPhaseObserver;
  62805. private _onAfterDrawPhaseObserver;
  62806. private _onBeforeAnimationsObserver;
  62807. private _onBeforeParticlesRenderingObserver;
  62808. private _onAfterParticlesRenderingObserver;
  62809. private _onBeforeSpritesRenderingObserver;
  62810. private _onAfterSpritesRenderingObserver;
  62811. private _onBeforePhysicsObserver;
  62812. private _onAfterPhysicsObserver;
  62813. private _onAfterAnimationsObserver;
  62814. private _onBeforeCameraRenderObserver;
  62815. private _onAfterCameraRenderObserver;
  62816. /**
  62817. * Gets the perf counter used for active meshes evaluation time
  62818. */
  62819. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62820. /**
  62821. * Gets the active meshes evaluation time capture status
  62822. */
  62823. get captureActiveMeshesEvaluationTime(): boolean;
  62824. /**
  62825. * Enable or disable the active meshes evaluation time capture
  62826. */
  62827. set captureActiveMeshesEvaluationTime(value: boolean);
  62828. /**
  62829. * Gets the perf counter used for render targets render time
  62830. */
  62831. get renderTargetsRenderTimeCounter(): PerfCounter;
  62832. /**
  62833. * Gets the render targets render time capture status
  62834. */
  62835. get captureRenderTargetsRenderTime(): boolean;
  62836. /**
  62837. * Enable or disable the render targets render time capture
  62838. */
  62839. set captureRenderTargetsRenderTime(value: boolean);
  62840. /**
  62841. * Gets the perf counter used for particles render time
  62842. */
  62843. get particlesRenderTimeCounter(): PerfCounter;
  62844. /**
  62845. * Gets the particles render time capture status
  62846. */
  62847. get captureParticlesRenderTime(): boolean;
  62848. /**
  62849. * Enable or disable the particles render time capture
  62850. */
  62851. set captureParticlesRenderTime(value: boolean);
  62852. /**
  62853. * Gets the perf counter used for sprites render time
  62854. */
  62855. get spritesRenderTimeCounter(): PerfCounter;
  62856. /**
  62857. * Gets the sprites render time capture status
  62858. */
  62859. get captureSpritesRenderTime(): boolean;
  62860. /**
  62861. * Enable or disable the sprites render time capture
  62862. */
  62863. set captureSpritesRenderTime(value: boolean);
  62864. /**
  62865. * Gets the perf counter used for physics time
  62866. */
  62867. get physicsTimeCounter(): PerfCounter;
  62868. /**
  62869. * Gets the physics time capture status
  62870. */
  62871. get capturePhysicsTime(): boolean;
  62872. /**
  62873. * Enable or disable the physics time capture
  62874. */
  62875. set capturePhysicsTime(value: boolean);
  62876. /**
  62877. * Gets the perf counter used for animations time
  62878. */
  62879. get animationsTimeCounter(): PerfCounter;
  62880. /**
  62881. * Gets the animations time capture status
  62882. */
  62883. get captureAnimationsTime(): boolean;
  62884. /**
  62885. * Enable or disable the animations time capture
  62886. */
  62887. set captureAnimationsTime(value: boolean);
  62888. /**
  62889. * Gets the perf counter used for frame time capture
  62890. */
  62891. get frameTimeCounter(): PerfCounter;
  62892. /**
  62893. * Gets the frame time capture status
  62894. */
  62895. get captureFrameTime(): boolean;
  62896. /**
  62897. * Enable or disable the frame time capture
  62898. */
  62899. set captureFrameTime(value: boolean);
  62900. /**
  62901. * Gets the perf counter used for inter-frames time capture
  62902. */
  62903. get interFrameTimeCounter(): PerfCounter;
  62904. /**
  62905. * Gets the inter-frames time capture status
  62906. */
  62907. get captureInterFrameTime(): boolean;
  62908. /**
  62909. * Enable or disable the inter-frames time capture
  62910. */
  62911. set captureInterFrameTime(value: boolean);
  62912. /**
  62913. * Gets the perf counter used for render time capture
  62914. */
  62915. get renderTimeCounter(): PerfCounter;
  62916. /**
  62917. * Gets the render time capture status
  62918. */
  62919. get captureRenderTime(): boolean;
  62920. /**
  62921. * Enable or disable the render time capture
  62922. */
  62923. set captureRenderTime(value: boolean);
  62924. /**
  62925. * Gets the perf counter used for camera render time capture
  62926. */
  62927. get cameraRenderTimeCounter(): PerfCounter;
  62928. /**
  62929. * Gets the camera render time capture status
  62930. */
  62931. get captureCameraRenderTime(): boolean;
  62932. /**
  62933. * Enable or disable the camera render time capture
  62934. */
  62935. set captureCameraRenderTime(value: boolean);
  62936. /**
  62937. * Gets the perf counter used for draw calls
  62938. */
  62939. get drawCallsCounter(): PerfCounter;
  62940. /**
  62941. * Instantiates a new scene instrumentation.
  62942. * This class can be used to get instrumentation data from a Babylon engine
  62943. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62944. * @param scene Defines the scene to instrument
  62945. */
  62946. constructor(
  62947. /**
  62948. * Defines the scene to instrument
  62949. */
  62950. scene: Scene);
  62951. /**
  62952. * Dispose and release associated resources.
  62953. */
  62954. dispose(): void;
  62955. }
  62956. }
  62957. declare module BABYLON {
  62958. /** @hidden */
  62959. export var glowMapGenerationPixelShader: {
  62960. name: string;
  62961. shader: string;
  62962. };
  62963. }
  62964. declare module BABYLON {
  62965. /** @hidden */
  62966. export var glowMapGenerationVertexShader: {
  62967. name: string;
  62968. shader: string;
  62969. };
  62970. }
  62971. declare module BABYLON {
  62972. /**
  62973. * Effect layer options. This helps customizing the behaviour
  62974. * of the effect layer.
  62975. */
  62976. export interface IEffectLayerOptions {
  62977. /**
  62978. * Multiplication factor apply to the canvas size to compute the render target size
  62979. * used to generated the objects (the smaller the faster).
  62980. */
  62981. mainTextureRatio: number;
  62982. /**
  62983. * Enforces a fixed size texture to ensure effect stability across devices.
  62984. */
  62985. mainTextureFixedSize?: number;
  62986. /**
  62987. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62988. */
  62989. alphaBlendingMode: number;
  62990. /**
  62991. * The camera attached to the layer.
  62992. */
  62993. camera: Nullable<Camera>;
  62994. /**
  62995. * The rendering group to draw the layer in.
  62996. */
  62997. renderingGroupId: number;
  62998. }
  62999. /**
  63000. * The effect layer Helps adding post process effect blended with the main pass.
  63001. *
  63002. * This can be for instance use to generate glow or highlight effects on the scene.
  63003. *
  63004. * The effect layer class can not be used directly and is intented to inherited from to be
  63005. * customized per effects.
  63006. */
  63007. export abstract class EffectLayer {
  63008. private _vertexBuffers;
  63009. private _indexBuffer;
  63010. private _cachedDefines;
  63011. private _effectLayerMapGenerationEffect;
  63012. private _effectLayerOptions;
  63013. private _mergeEffect;
  63014. protected _scene: Scene;
  63015. protected _engine: Engine;
  63016. protected _maxSize: number;
  63017. protected _mainTextureDesiredSize: ISize;
  63018. protected _mainTexture: RenderTargetTexture;
  63019. protected _shouldRender: boolean;
  63020. protected _postProcesses: PostProcess[];
  63021. protected _textures: BaseTexture[];
  63022. protected _emissiveTextureAndColor: {
  63023. texture: Nullable<BaseTexture>;
  63024. color: Color4;
  63025. };
  63026. /**
  63027. * The name of the layer
  63028. */
  63029. name: string;
  63030. /**
  63031. * The clear color of the texture used to generate the glow map.
  63032. */
  63033. neutralColor: Color4;
  63034. /**
  63035. * Specifies whether the highlight layer is enabled or not.
  63036. */
  63037. isEnabled: boolean;
  63038. /**
  63039. * Gets the camera attached to the layer.
  63040. */
  63041. get camera(): Nullable<Camera>;
  63042. /**
  63043. * Gets the rendering group id the layer should render in.
  63044. */
  63045. get renderingGroupId(): number;
  63046. set renderingGroupId(renderingGroupId: number);
  63047. /**
  63048. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  63049. */
  63050. disableBoundingBoxesFromEffectLayer: boolean;
  63051. /**
  63052. * An event triggered when the effect layer has been disposed.
  63053. */
  63054. onDisposeObservable: Observable<EffectLayer>;
  63055. /**
  63056. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  63057. */
  63058. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  63059. /**
  63060. * An event triggered when the generated texture is being merged in the scene.
  63061. */
  63062. onBeforeComposeObservable: Observable<EffectLayer>;
  63063. /**
  63064. * An event triggered when the mesh is rendered into the effect render target.
  63065. */
  63066. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  63067. /**
  63068. * An event triggered after the mesh has been rendered into the effect render target.
  63069. */
  63070. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  63071. /**
  63072. * An event triggered when the generated texture has been merged in the scene.
  63073. */
  63074. onAfterComposeObservable: Observable<EffectLayer>;
  63075. /**
  63076. * An event triggered when the effect layer changes its size.
  63077. */
  63078. onSizeChangedObservable: Observable<EffectLayer>;
  63079. /** @hidden */
  63080. static _SceneComponentInitialization: (scene: Scene) => void;
  63081. /**
  63082. * Instantiates a new effect Layer and references it in the scene.
  63083. * @param name The name of the layer
  63084. * @param scene The scene to use the layer in
  63085. */
  63086. constructor(
  63087. /** The Friendly of the effect in the scene */
  63088. name: string, scene: Scene);
  63089. /**
  63090. * Get the effect name of the layer.
  63091. * @return The effect name
  63092. */
  63093. abstract getEffectName(): string;
  63094. /**
  63095. * Checks for the readiness of the element composing the layer.
  63096. * @param subMesh the mesh to check for
  63097. * @param useInstances specify whether or not to use instances to render the mesh
  63098. * @return true if ready otherwise, false
  63099. */
  63100. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63101. /**
  63102. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63103. * @returns true if the effect requires stencil during the main canvas render pass.
  63104. */
  63105. abstract needStencil(): boolean;
  63106. /**
  63107. * Create the merge effect. This is the shader use to blit the information back
  63108. * to the main canvas at the end of the scene rendering.
  63109. * @returns The effect containing the shader used to merge the effect on the main canvas
  63110. */
  63111. protected abstract _createMergeEffect(): Effect;
  63112. /**
  63113. * Creates the render target textures and post processes used in the effect layer.
  63114. */
  63115. protected abstract _createTextureAndPostProcesses(): void;
  63116. /**
  63117. * Implementation specific of rendering the generating effect on the main canvas.
  63118. * @param effect The effect used to render through
  63119. */
  63120. protected abstract _internalRender(effect: Effect): void;
  63121. /**
  63122. * Sets the required values for both the emissive texture and and the main color.
  63123. */
  63124. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63125. /**
  63126. * Free any resources and references associated to a mesh.
  63127. * Internal use
  63128. * @param mesh The mesh to free.
  63129. */
  63130. abstract _disposeMesh(mesh: Mesh): void;
  63131. /**
  63132. * Serializes this layer (Glow or Highlight for example)
  63133. * @returns a serialized layer object
  63134. */
  63135. abstract serialize?(): any;
  63136. /**
  63137. * Initializes the effect layer with the required options.
  63138. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  63139. */
  63140. protected _init(options: Partial<IEffectLayerOptions>): void;
  63141. /**
  63142. * Generates the index buffer of the full screen quad blending to the main canvas.
  63143. */
  63144. private _generateIndexBuffer;
  63145. /**
  63146. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  63147. */
  63148. private _generateVertexBuffer;
  63149. /**
  63150. * Sets the main texture desired size which is the closest power of two
  63151. * of the engine canvas size.
  63152. */
  63153. private _setMainTextureSize;
  63154. /**
  63155. * Creates the main texture for the effect layer.
  63156. */
  63157. protected _createMainTexture(): void;
  63158. /**
  63159. * Adds specific effects defines.
  63160. * @param defines The defines to add specifics to.
  63161. */
  63162. protected _addCustomEffectDefines(defines: string[]): void;
  63163. /**
  63164. * Checks for the readiness of the element composing the layer.
  63165. * @param subMesh the mesh to check for
  63166. * @param useInstances specify whether or not to use instances to render the mesh
  63167. * @param emissiveTexture the associated emissive texture used to generate the glow
  63168. * @return true if ready otherwise, false
  63169. */
  63170. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  63171. /**
  63172. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  63173. */
  63174. render(): void;
  63175. /**
  63176. * Determine if a given mesh will be used in the current effect.
  63177. * @param mesh mesh to test
  63178. * @returns true if the mesh will be used
  63179. */
  63180. hasMesh(mesh: AbstractMesh): boolean;
  63181. /**
  63182. * Returns true if the layer contains information to display, otherwise false.
  63183. * @returns true if the glow layer should be rendered
  63184. */
  63185. shouldRender(): boolean;
  63186. /**
  63187. * Returns true if the mesh should render, otherwise false.
  63188. * @param mesh The mesh to render
  63189. * @returns true if it should render otherwise false
  63190. */
  63191. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  63192. /**
  63193. * Returns true if the mesh can be rendered, otherwise false.
  63194. * @param mesh The mesh to render
  63195. * @param material The material used on the mesh
  63196. * @returns true if it can be rendered otherwise false
  63197. */
  63198. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63199. /**
  63200. * Returns true if the mesh should render, otherwise false.
  63201. * @param mesh The mesh to render
  63202. * @returns true if it should render otherwise false
  63203. */
  63204. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  63205. /**
  63206. * Renders the submesh passed in parameter to the generation map.
  63207. */
  63208. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  63209. /**
  63210. * Defines whether the current material of the mesh should be use to render the effect.
  63211. * @param mesh defines the current mesh to render
  63212. */
  63213. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63214. /**
  63215. * Rebuild the required buffers.
  63216. * @hidden Internal use only.
  63217. */
  63218. _rebuild(): void;
  63219. /**
  63220. * Dispose only the render target textures and post process.
  63221. */
  63222. private _disposeTextureAndPostProcesses;
  63223. /**
  63224. * Dispose the highlight layer and free resources.
  63225. */
  63226. dispose(): void;
  63227. /**
  63228. * Gets the class name of the effect layer
  63229. * @returns the string with the class name of the effect layer
  63230. */
  63231. getClassName(): string;
  63232. /**
  63233. * Creates an effect layer from parsed effect layer data
  63234. * @param parsedEffectLayer defines effect layer data
  63235. * @param scene defines the current scene
  63236. * @param rootUrl defines the root URL containing the effect layer information
  63237. * @returns a parsed effect Layer
  63238. */
  63239. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  63240. }
  63241. }
  63242. declare module BABYLON {
  63243. interface AbstractScene {
  63244. /**
  63245. * The list of effect layers (highlights/glow) added to the scene
  63246. * @see https://doc.babylonjs.com/how_to/highlight_layer
  63247. * @see https://doc.babylonjs.com/how_to/glow_layer
  63248. */
  63249. effectLayers: Array<EffectLayer>;
  63250. /**
  63251. * Removes the given effect layer from this scene.
  63252. * @param toRemove defines the effect layer to remove
  63253. * @returns the index of the removed effect layer
  63254. */
  63255. removeEffectLayer(toRemove: EffectLayer): number;
  63256. /**
  63257. * Adds the given effect layer to this scene
  63258. * @param newEffectLayer defines the effect layer to add
  63259. */
  63260. addEffectLayer(newEffectLayer: EffectLayer): void;
  63261. }
  63262. /**
  63263. * Defines the layer scene component responsible to manage any effect layers
  63264. * in a given scene.
  63265. */
  63266. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  63267. /**
  63268. * The component name helpful to identify the component in the list of scene components.
  63269. */
  63270. readonly name: string;
  63271. /**
  63272. * The scene the component belongs to.
  63273. */
  63274. scene: Scene;
  63275. private _engine;
  63276. private _renderEffects;
  63277. private _needStencil;
  63278. private _previousStencilState;
  63279. /**
  63280. * Creates a new instance of the component for the given scene
  63281. * @param scene Defines the scene to register the component in
  63282. */
  63283. constructor(scene: Scene);
  63284. /**
  63285. * Registers the component in a given scene
  63286. */
  63287. register(): void;
  63288. /**
  63289. * Rebuilds the elements related to this component in case of
  63290. * context lost for instance.
  63291. */
  63292. rebuild(): void;
  63293. /**
  63294. * Serializes the component data to the specified json object
  63295. * @param serializationObject The object to serialize to
  63296. */
  63297. serialize(serializationObject: any): void;
  63298. /**
  63299. * Adds all the elements from the container to the scene
  63300. * @param container the container holding the elements
  63301. */
  63302. addFromContainer(container: AbstractScene): void;
  63303. /**
  63304. * Removes all the elements in the container from the scene
  63305. * @param container contains the elements to remove
  63306. * @param dispose if the removed element should be disposed (default: false)
  63307. */
  63308. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63309. /**
  63310. * Disposes the component and the associated resources.
  63311. */
  63312. dispose(): void;
  63313. private _isReadyForMesh;
  63314. private _renderMainTexture;
  63315. private _setStencil;
  63316. private _setStencilBack;
  63317. private _draw;
  63318. private _drawCamera;
  63319. private _drawRenderingGroup;
  63320. }
  63321. }
  63322. declare module BABYLON {
  63323. /** @hidden */
  63324. export var glowMapMergePixelShader: {
  63325. name: string;
  63326. shader: string;
  63327. };
  63328. }
  63329. declare module BABYLON {
  63330. /** @hidden */
  63331. export var glowMapMergeVertexShader: {
  63332. name: string;
  63333. shader: string;
  63334. };
  63335. }
  63336. declare module BABYLON {
  63337. interface AbstractScene {
  63338. /**
  63339. * Return a the first highlight layer of the scene with a given name.
  63340. * @param name The name of the highlight layer to look for.
  63341. * @return The highlight layer if found otherwise null.
  63342. */
  63343. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63344. }
  63345. /**
  63346. * Glow layer options. This helps customizing the behaviour
  63347. * of the glow layer.
  63348. */
  63349. export interface IGlowLayerOptions {
  63350. /**
  63351. * Multiplication factor apply to the canvas size to compute the render target size
  63352. * used to generated the glowing objects (the smaller the faster).
  63353. */
  63354. mainTextureRatio: number;
  63355. /**
  63356. * Enforces a fixed size texture to ensure resize independent blur.
  63357. */
  63358. mainTextureFixedSize?: number;
  63359. /**
  63360. * How big is the kernel of the blur texture.
  63361. */
  63362. blurKernelSize: number;
  63363. /**
  63364. * The camera attached to the layer.
  63365. */
  63366. camera: Nullable<Camera>;
  63367. /**
  63368. * Enable MSAA by choosing the number of samples.
  63369. */
  63370. mainTextureSamples?: number;
  63371. /**
  63372. * The rendering group to draw the layer in.
  63373. */
  63374. renderingGroupId: number;
  63375. }
  63376. /**
  63377. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  63378. *
  63379. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  63380. *
  63381. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  63382. */
  63383. export class GlowLayer extends EffectLayer {
  63384. /**
  63385. * Effect Name of the layer.
  63386. */
  63387. static readonly EffectName: string;
  63388. /**
  63389. * The default blur kernel size used for the glow.
  63390. */
  63391. static DefaultBlurKernelSize: number;
  63392. /**
  63393. * The default texture size ratio used for the glow.
  63394. */
  63395. static DefaultTextureRatio: number;
  63396. /**
  63397. * Sets the kernel size of the blur.
  63398. */
  63399. set blurKernelSize(value: number);
  63400. /**
  63401. * Gets the kernel size of the blur.
  63402. */
  63403. get blurKernelSize(): number;
  63404. /**
  63405. * Sets the glow intensity.
  63406. */
  63407. set intensity(value: number);
  63408. /**
  63409. * Gets the glow intensity.
  63410. */
  63411. get intensity(): number;
  63412. private _options;
  63413. private _intensity;
  63414. private _horizontalBlurPostprocess1;
  63415. private _verticalBlurPostprocess1;
  63416. private _horizontalBlurPostprocess2;
  63417. private _verticalBlurPostprocess2;
  63418. private _blurTexture1;
  63419. private _blurTexture2;
  63420. private _postProcesses1;
  63421. private _postProcesses2;
  63422. private _includedOnlyMeshes;
  63423. private _excludedMeshes;
  63424. private _meshesUsingTheirOwnMaterials;
  63425. /**
  63426. * Callback used to let the user override the color selection on a per mesh basis
  63427. */
  63428. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  63429. /**
  63430. * Callback used to let the user override the texture selection on a per mesh basis
  63431. */
  63432. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  63433. /**
  63434. * Instantiates a new glow Layer and references it to the scene.
  63435. * @param name The name of the layer
  63436. * @param scene The scene to use the layer in
  63437. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63438. */
  63439. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63440. /**
  63441. * Get the effect name of the layer.
  63442. * @return The effect name
  63443. */
  63444. getEffectName(): string;
  63445. /**
  63446. * Create the merge effect. This is the shader use to blit the information back
  63447. * to the main canvas at the end of the scene rendering.
  63448. */
  63449. protected _createMergeEffect(): Effect;
  63450. /**
  63451. * Creates the render target textures and post processes used in the glow layer.
  63452. */
  63453. protected _createTextureAndPostProcesses(): void;
  63454. /**
  63455. * Checks for the readiness of the element composing the layer.
  63456. * @param subMesh the mesh to check for
  63457. * @param useInstances specify whether or not to use instances to render the mesh
  63458. * @param emissiveTexture the associated emissive texture used to generate the glow
  63459. * @return true if ready otherwise, false
  63460. */
  63461. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63462. /**
  63463. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63464. */
  63465. needStencil(): boolean;
  63466. /**
  63467. * Returns true if the mesh can be rendered, otherwise false.
  63468. * @param mesh The mesh to render
  63469. * @param material The material used on the mesh
  63470. * @returns true if it can be rendered otherwise false
  63471. */
  63472. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63473. /**
  63474. * Implementation specific of rendering the generating effect on the main canvas.
  63475. * @param effect The effect used to render through
  63476. */
  63477. protected _internalRender(effect: Effect): void;
  63478. /**
  63479. * Sets the required values for both the emissive texture and and the main color.
  63480. */
  63481. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63482. /**
  63483. * Returns true if the mesh should render, otherwise false.
  63484. * @param mesh The mesh to render
  63485. * @returns true if it should render otherwise false
  63486. */
  63487. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63488. /**
  63489. * Adds specific effects defines.
  63490. * @param defines The defines to add specifics to.
  63491. */
  63492. protected _addCustomEffectDefines(defines: string[]): void;
  63493. /**
  63494. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63495. * @param mesh The mesh to exclude from the glow layer
  63496. */
  63497. addExcludedMesh(mesh: Mesh): void;
  63498. /**
  63499. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63500. * @param mesh The mesh to remove
  63501. */
  63502. removeExcludedMesh(mesh: Mesh): void;
  63503. /**
  63504. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63505. * @param mesh The mesh to include in the glow layer
  63506. */
  63507. addIncludedOnlyMesh(mesh: Mesh): void;
  63508. /**
  63509. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63510. * @param mesh The mesh to remove
  63511. */
  63512. removeIncludedOnlyMesh(mesh: Mesh): void;
  63513. /**
  63514. * Determine if a given mesh will be used in the glow layer
  63515. * @param mesh The mesh to test
  63516. * @returns true if the mesh will be highlighted by the current glow layer
  63517. */
  63518. hasMesh(mesh: AbstractMesh): boolean;
  63519. /**
  63520. * Defines whether the current material of the mesh should be use to render the effect.
  63521. * @param mesh defines the current mesh to render
  63522. */
  63523. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63524. /**
  63525. * Add a mesh to be rendered through its own material and not with emissive only.
  63526. * @param mesh The mesh for which we need to use its material
  63527. */
  63528. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63529. /**
  63530. * Remove a mesh from being rendered through its own material and not with emissive only.
  63531. * @param mesh The mesh for which we need to not use its material
  63532. */
  63533. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63534. /**
  63535. * Free any resources and references associated to a mesh.
  63536. * Internal use
  63537. * @param mesh The mesh to free.
  63538. * @hidden
  63539. */
  63540. _disposeMesh(mesh: Mesh): void;
  63541. /**
  63542. * Gets the class name of the effect layer
  63543. * @returns the string with the class name of the effect layer
  63544. */
  63545. getClassName(): string;
  63546. /**
  63547. * Serializes this glow layer
  63548. * @returns a serialized glow layer object
  63549. */
  63550. serialize(): any;
  63551. /**
  63552. * Creates a Glow Layer from parsed glow layer data
  63553. * @param parsedGlowLayer defines glow layer data
  63554. * @param scene defines the current scene
  63555. * @param rootUrl defines the root URL containing the glow layer information
  63556. * @returns a parsed Glow Layer
  63557. */
  63558. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63559. }
  63560. }
  63561. declare module BABYLON {
  63562. /** @hidden */
  63563. export var glowBlurPostProcessPixelShader: {
  63564. name: string;
  63565. shader: string;
  63566. };
  63567. }
  63568. declare module BABYLON {
  63569. interface AbstractScene {
  63570. /**
  63571. * Return a the first highlight layer of the scene with a given name.
  63572. * @param name The name of the highlight layer to look for.
  63573. * @return The highlight layer if found otherwise null.
  63574. */
  63575. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63576. }
  63577. /**
  63578. * Highlight layer options. This helps customizing the behaviour
  63579. * of the highlight layer.
  63580. */
  63581. export interface IHighlightLayerOptions {
  63582. /**
  63583. * Multiplication factor apply to the canvas size to compute the render target size
  63584. * used to generated the glowing objects (the smaller the faster).
  63585. */
  63586. mainTextureRatio: number;
  63587. /**
  63588. * Enforces a fixed size texture to ensure resize independent blur.
  63589. */
  63590. mainTextureFixedSize?: number;
  63591. /**
  63592. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63593. * of the picture to blur (the smaller the faster).
  63594. */
  63595. blurTextureSizeRatio: number;
  63596. /**
  63597. * How big in texel of the blur texture is the vertical blur.
  63598. */
  63599. blurVerticalSize: number;
  63600. /**
  63601. * How big in texel of the blur texture is the horizontal blur.
  63602. */
  63603. blurHorizontalSize: number;
  63604. /**
  63605. * Alpha blending mode used to apply the blur. Default is combine.
  63606. */
  63607. alphaBlendingMode: number;
  63608. /**
  63609. * The camera attached to the layer.
  63610. */
  63611. camera: Nullable<Camera>;
  63612. /**
  63613. * Should we display highlight as a solid stroke?
  63614. */
  63615. isStroke?: boolean;
  63616. /**
  63617. * The rendering group to draw the layer in.
  63618. */
  63619. renderingGroupId: number;
  63620. }
  63621. /**
  63622. * The highlight layer Helps adding a glow effect around a mesh.
  63623. *
  63624. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63625. * glowy meshes to your scene.
  63626. *
  63627. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63628. */
  63629. export class HighlightLayer extends EffectLayer {
  63630. name: string;
  63631. /**
  63632. * Effect Name of the highlight layer.
  63633. */
  63634. static readonly EffectName: string;
  63635. /**
  63636. * The neutral color used during the preparation of the glow effect.
  63637. * This is black by default as the blend operation is a blend operation.
  63638. */
  63639. static NeutralColor: Color4;
  63640. /**
  63641. * Stencil value used for glowing meshes.
  63642. */
  63643. static GlowingMeshStencilReference: number;
  63644. /**
  63645. * Stencil value used for the other meshes in the scene.
  63646. */
  63647. static NormalMeshStencilReference: number;
  63648. /**
  63649. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63650. */
  63651. innerGlow: boolean;
  63652. /**
  63653. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63654. */
  63655. outerGlow: boolean;
  63656. /**
  63657. * Specifies the horizontal size of the blur.
  63658. */
  63659. set blurHorizontalSize(value: number);
  63660. /**
  63661. * Specifies the vertical size of the blur.
  63662. */
  63663. set blurVerticalSize(value: number);
  63664. /**
  63665. * Gets the horizontal size of the blur.
  63666. */
  63667. get blurHorizontalSize(): number;
  63668. /**
  63669. * Gets the vertical size of the blur.
  63670. */
  63671. get blurVerticalSize(): number;
  63672. /**
  63673. * An event triggered when the highlight layer is being blurred.
  63674. */
  63675. onBeforeBlurObservable: Observable<HighlightLayer>;
  63676. /**
  63677. * An event triggered when the highlight layer has been blurred.
  63678. */
  63679. onAfterBlurObservable: Observable<HighlightLayer>;
  63680. private _instanceGlowingMeshStencilReference;
  63681. private _options;
  63682. private _downSamplePostprocess;
  63683. private _horizontalBlurPostprocess;
  63684. private _verticalBlurPostprocess;
  63685. private _blurTexture;
  63686. private _meshes;
  63687. private _excludedMeshes;
  63688. /**
  63689. * Instantiates a new highlight Layer and references it to the scene..
  63690. * @param name The name of the layer
  63691. * @param scene The scene to use the layer in
  63692. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63693. */
  63694. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63695. /**
  63696. * Get the effect name of the layer.
  63697. * @return The effect name
  63698. */
  63699. getEffectName(): string;
  63700. /**
  63701. * Create the merge effect. This is the shader use to blit the information back
  63702. * to the main canvas at the end of the scene rendering.
  63703. */
  63704. protected _createMergeEffect(): Effect;
  63705. /**
  63706. * Creates the render target textures and post processes used in the highlight layer.
  63707. */
  63708. protected _createTextureAndPostProcesses(): void;
  63709. /**
  63710. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63711. */
  63712. needStencil(): boolean;
  63713. /**
  63714. * Checks for the readiness of the element composing the layer.
  63715. * @param subMesh the mesh to check for
  63716. * @param useInstances specify wether or not to use instances to render the mesh
  63717. * @param emissiveTexture the associated emissive texture used to generate the glow
  63718. * @return true if ready otherwise, false
  63719. */
  63720. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63721. /**
  63722. * Implementation specific of rendering the generating effect on the main canvas.
  63723. * @param effect The effect used to render through
  63724. */
  63725. protected _internalRender(effect: Effect): void;
  63726. /**
  63727. * Returns true if the layer contains information to display, otherwise false.
  63728. */
  63729. shouldRender(): boolean;
  63730. /**
  63731. * Returns true if the mesh should render, otherwise false.
  63732. * @param mesh The mesh to render
  63733. * @returns true if it should render otherwise false
  63734. */
  63735. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63736. /**
  63737. * Returns true if the mesh can be rendered, otherwise false.
  63738. * @param mesh The mesh to render
  63739. * @param material The material used on the mesh
  63740. * @returns true if it can be rendered otherwise false
  63741. */
  63742. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63743. /**
  63744. * Adds specific effects defines.
  63745. * @param defines The defines to add specifics to.
  63746. */
  63747. protected _addCustomEffectDefines(defines: string[]): void;
  63748. /**
  63749. * Sets the required values for both the emissive texture and and the main color.
  63750. */
  63751. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63752. /**
  63753. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63754. * @param mesh The mesh to exclude from the highlight layer
  63755. */
  63756. addExcludedMesh(mesh: Mesh): void;
  63757. /**
  63758. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63759. * @param mesh The mesh to highlight
  63760. */
  63761. removeExcludedMesh(mesh: Mesh): void;
  63762. /**
  63763. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63764. * @param mesh mesh to test
  63765. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63766. */
  63767. hasMesh(mesh: AbstractMesh): boolean;
  63768. /**
  63769. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63770. * @param mesh The mesh to highlight
  63771. * @param color The color of the highlight
  63772. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63773. */
  63774. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63775. /**
  63776. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63777. * @param mesh The mesh to highlight
  63778. */
  63779. removeMesh(mesh: Mesh): void;
  63780. /**
  63781. * Remove all the meshes currently referenced in the highlight layer
  63782. */
  63783. removeAllMeshes(): void;
  63784. /**
  63785. * Force the stencil to the normal expected value for none glowing parts
  63786. */
  63787. private _defaultStencilReference;
  63788. /**
  63789. * Free any resources and references associated to a mesh.
  63790. * Internal use
  63791. * @param mesh The mesh to free.
  63792. * @hidden
  63793. */
  63794. _disposeMesh(mesh: Mesh): void;
  63795. /**
  63796. * Dispose the highlight layer and free resources.
  63797. */
  63798. dispose(): void;
  63799. /**
  63800. * Gets the class name of the effect layer
  63801. * @returns the string with the class name of the effect layer
  63802. */
  63803. getClassName(): string;
  63804. /**
  63805. * Serializes this Highlight layer
  63806. * @returns a serialized Highlight layer object
  63807. */
  63808. serialize(): any;
  63809. /**
  63810. * Creates a Highlight layer from parsed Highlight layer data
  63811. * @param parsedHightlightLayer defines the Highlight layer data
  63812. * @param scene defines the current scene
  63813. * @param rootUrl defines the root URL containing the Highlight layer information
  63814. * @returns a parsed Highlight layer
  63815. */
  63816. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63817. }
  63818. }
  63819. declare module BABYLON {
  63820. interface AbstractScene {
  63821. /**
  63822. * The list of layers (background and foreground) of the scene
  63823. */
  63824. layers: Array<Layer>;
  63825. }
  63826. /**
  63827. * Defines the layer scene component responsible to manage any layers
  63828. * in a given scene.
  63829. */
  63830. export class LayerSceneComponent implements ISceneComponent {
  63831. /**
  63832. * The component name helpful to identify the component in the list of scene components.
  63833. */
  63834. readonly name: string;
  63835. /**
  63836. * The scene the component belongs to.
  63837. */
  63838. scene: Scene;
  63839. private _engine;
  63840. /**
  63841. * Creates a new instance of the component for the given scene
  63842. * @param scene Defines the scene to register the component in
  63843. */
  63844. constructor(scene: Scene);
  63845. /**
  63846. * Registers the component in a given scene
  63847. */
  63848. register(): void;
  63849. /**
  63850. * Rebuilds the elements related to this component in case of
  63851. * context lost for instance.
  63852. */
  63853. rebuild(): void;
  63854. /**
  63855. * Disposes the component and the associated resources.
  63856. */
  63857. dispose(): void;
  63858. private _draw;
  63859. private _drawCameraPredicate;
  63860. private _drawCameraBackground;
  63861. private _drawCameraForeground;
  63862. private _drawRenderTargetPredicate;
  63863. private _drawRenderTargetBackground;
  63864. private _drawRenderTargetForeground;
  63865. /**
  63866. * Adds all the elements from the container to the scene
  63867. * @param container the container holding the elements
  63868. */
  63869. addFromContainer(container: AbstractScene): void;
  63870. /**
  63871. * Removes all the elements in the container from the scene
  63872. * @param container contains the elements to remove
  63873. * @param dispose if the removed element should be disposed (default: false)
  63874. */
  63875. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63876. }
  63877. }
  63878. declare module BABYLON {
  63879. /** @hidden */
  63880. export var layerPixelShader: {
  63881. name: string;
  63882. shader: string;
  63883. };
  63884. }
  63885. declare module BABYLON {
  63886. /** @hidden */
  63887. export var layerVertexShader: {
  63888. name: string;
  63889. shader: string;
  63890. };
  63891. }
  63892. declare module BABYLON {
  63893. /**
  63894. * This represents a full screen 2d layer.
  63895. * This can be useful to display a picture in the background of your scene for instance.
  63896. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63897. */
  63898. export class Layer {
  63899. /**
  63900. * Define the name of the layer.
  63901. */
  63902. name: string;
  63903. /**
  63904. * Define the texture the layer should display.
  63905. */
  63906. texture: Nullable<Texture>;
  63907. /**
  63908. * Is the layer in background or foreground.
  63909. */
  63910. isBackground: boolean;
  63911. /**
  63912. * Define the color of the layer (instead of texture).
  63913. */
  63914. color: Color4;
  63915. /**
  63916. * Define the scale of the layer in order to zoom in out of the texture.
  63917. */
  63918. scale: Vector2;
  63919. /**
  63920. * Define an offset for the layer in order to shift the texture.
  63921. */
  63922. offset: Vector2;
  63923. /**
  63924. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63925. */
  63926. alphaBlendingMode: number;
  63927. /**
  63928. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63929. * Alpha test will not mix with the background color in case of transparency.
  63930. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63931. */
  63932. alphaTest: boolean;
  63933. /**
  63934. * Define a mask to restrict the layer to only some of the scene cameras.
  63935. */
  63936. layerMask: number;
  63937. /**
  63938. * Define the list of render target the layer is visible into.
  63939. */
  63940. renderTargetTextures: RenderTargetTexture[];
  63941. /**
  63942. * Define if the layer is only used in renderTarget or if it also
  63943. * renders in the main frame buffer of the canvas.
  63944. */
  63945. renderOnlyInRenderTargetTextures: boolean;
  63946. private _scene;
  63947. private _vertexBuffers;
  63948. private _indexBuffer;
  63949. private _effect;
  63950. private _previousDefines;
  63951. /**
  63952. * An event triggered when the layer is disposed.
  63953. */
  63954. onDisposeObservable: Observable<Layer>;
  63955. private _onDisposeObserver;
  63956. /**
  63957. * Back compatibility with callback before the onDisposeObservable existed.
  63958. * The set callback will be triggered when the layer has been disposed.
  63959. */
  63960. set onDispose(callback: () => void);
  63961. /**
  63962. * An event triggered before rendering the scene
  63963. */
  63964. onBeforeRenderObservable: Observable<Layer>;
  63965. private _onBeforeRenderObserver;
  63966. /**
  63967. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63968. * The set callback will be triggered just before rendering the layer.
  63969. */
  63970. set onBeforeRender(callback: () => void);
  63971. /**
  63972. * An event triggered after rendering the scene
  63973. */
  63974. onAfterRenderObservable: Observable<Layer>;
  63975. private _onAfterRenderObserver;
  63976. /**
  63977. * Back compatibility with callback before the onAfterRenderObservable existed.
  63978. * The set callback will be triggered just after rendering the layer.
  63979. */
  63980. set onAfterRender(callback: () => void);
  63981. /**
  63982. * Instantiates a new layer.
  63983. * This represents a full screen 2d layer.
  63984. * This can be useful to display a picture in the background of your scene for instance.
  63985. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63986. * @param name Define the name of the layer in the scene
  63987. * @param imgUrl Define the url of the texture to display in the layer
  63988. * @param scene Define the scene the layer belongs to
  63989. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63990. * @param color Defines a color for the layer
  63991. */
  63992. constructor(
  63993. /**
  63994. * Define the name of the layer.
  63995. */
  63996. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63997. private _createIndexBuffer;
  63998. /** @hidden */
  63999. _rebuild(): void;
  64000. /**
  64001. * Renders the layer in the scene.
  64002. */
  64003. render(): void;
  64004. /**
  64005. * Disposes and releases the associated resources.
  64006. */
  64007. dispose(): void;
  64008. }
  64009. }
  64010. declare module BABYLON {
  64011. /** @hidden */
  64012. export var lensFlarePixelShader: {
  64013. name: string;
  64014. shader: string;
  64015. };
  64016. }
  64017. declare module BABYLON {
  64018. /** @hidden */
  64019. export var lensFlareVertexShader: {
  64020. name: string;
  64021. shader: string;
  64022. };
  64023. }
  64024. declare module BABYLON {
  64025. /**
  64026. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64027. * It is usually composed of several `lensFlare`.
  64028. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64029. */
  64030. export class LensFlareSystem {
  64031. /**
  64032. * Define the name of the lens flare system
  64033. */
  64034. name: string;
  64035. /**
  64036. * List of lens flares used in this system.
  64037. */
  64038. lensFlares: LensFlare[];
  64039. /**
  64040. * Define a limit from the border the lens flare can be visible.
  64041. */
  64042. borderLimit: number;
  64043. /**
  64044. * Define a viewport border we do not want to see the lens flare in.
  64045. */
  64046. viewportBorder: number;
  64047. /**
  64048. * Define a predicate which could limit the list of meshes able to occlude the effect.
  64049. */
  64050. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  64051. /**
  64052. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  64053. */
  64054. layerMask: number;
  64055. /**
  64056. * Define the id of the lens flare system in the scene.
  64057. * (equal to name by default)
  64058. */
  64059. id: string;
  64060. private _scene;
  64061. private _emitter;
  64062. private _vertexBuffers;
  64063. private _indexBuffer;
  64064. private _effect;
  64065. private _positionX;
  64066. private _positionY;
  64067. private _isEnabled;
  64068. /** @hidden */
  64069. static _SceneComponentInitialization: (scene: Scene) => void;
  64070. /**
  64071. * Instantiates a lens flare system.
  64072. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64073. * It is usually composed of several `lensFlare`.
  64074. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64075. * @param name Define the name of the lens flare system in the scene
  64076. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  64077. * @param scene Define the scene the lens flare system belongs to
  64078. */
  64079. constructor(
  64080. /**
  64081. * Define the name of the lens flare system
  64082. */
  64083. name: string, emitter: any, scene: Scene);
  64084. /**
  64085. * Define if the lens flare system is enabled.
  64086. */
  64087. get isEnabled(): boolean;
  64088. set isEnabled(value: boolean);
  64089. /**
  64090. * Get the scene the effects belongs to.
  64091. * @returns the scene holding the lens flare system
  64092. */
  64093. getScene(): Scene;
  64094. /**
  64095. * Get the emitter of the lens flare system.
  64096. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64097. * @returns the emitter of the lens flare system
  64098. */
  64099. getEmitter(): any;
  64100. /**
  64101. * Set the emitter of the lens flare system.
  64102. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64103. * @param newEmitter Define the new emitter of the system
  64104. */
  64105. setEmitter(newEmitter: any): void;
  64106. /**
  64107. * Get the lens flare system emitter position.
  64108. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  64109. * @returns the position
  64110. */
  64111. getEmitterPosition(): Vector3;
  64112. /**
  64113. * @hidden
  64114. */
  64115. computeEffectivePosition(globalViewport: Viewport): boolean;
  64116. /** @hidden */
  64117. _isVisible(): boolean;
  64118. /**
  64119. * @hidden
  64120. */
  64121. render(): boolean;
  64122. /**
  64123. * Dispose and release the lens flare with its associated resources.
  64124. */
  64125. dispose(): void;
  64126. /**
  64127. * Parse a lens flare system from a JSON representation
  64128. * @param parsedLensFlareSystem Define the JSON to parse
  64129. * @param scene Define the scene the parsed system should be instantiated in
  64130. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  64131. * @returns the parsed system
  64132. */
  64133. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  64134. /**
  64135. * Serialize the current Lens Flare System into a JSON representation.
  64136. * @returns the serialized JSON
  64137. */
  64138. serialize(): any;
  64139. }
  64140. }
  64141. declare module BABYLON {
  64142. /**
  64143. * This represents one of the lens effect in a `lensFlareSystem`.
  64144. * It controls one of the individual texture used in the effect.
  64145. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64146. */
  64147. export class LensFlare {
  64148. /**
  64149. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64150. */
  64151. size: number;
  64152. /**
  64153. * 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.
  64154. */
  64155. position: number;
  64156. /**
  64157. * Define the lens color.
  64158. */
  64159. color: Color3;
  64160. /**
  64161. * Define the lens texture.
  64162. */
  64163. texture: Nullable<Texture>;
  64164. /**
  64165. * Define the alpha mode to render this particular lens.
  64166. */
  64167. alphaMode: number;
  64168. private _system;
  64169. /**
  64170. * Creates a new Lens Flare.
  64171. * This represents one of the lens effect in a `lensFlareSystem`.
  64172. * It controls one of the individual texture used in the effect.
  64173. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64174. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  64175. * @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.
  64176. * @param color Define the lens color
  64177. * @param imgUrl Define the lens texture url
  64178. * @param system Define the `lensFlareSystem` this flare is part of
  64179. * @returns The newly created Lens Flare
  64180. */
  64181. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  64182. /**
  64183. * Instantiates a new Lens Flare.
  64184. * This represents one of the lens effect in a `lensFlareSystem`.
  64185. * It controls one of the individual texture used in the effect.
  64186. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64187. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  64188. * @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.
  64189. * @param color Define the lens color
  64190. * @param imgUrl Define the lens texture url
  64191. * @param system Define the `lensFlareSystem` this flare is part of
  64192. */
  64193. constructor(
  64194. /**
  64195. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64196. */
  64197. size: number,
  64198. /**
  64199. * 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.
  64200. */
  64201. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  64202. /**
  64203. * Dispose and release the lens flare with its associated resources.
  64204. */
  64205. dispose(): void;
  64206. }
  64207. }
  64208. declare module BABYLON {
  64209. interface AbstractScene {
  64210. /**
  64211. * The list of lens flare system added to the scene
  64212. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64213. */
  64214. lensFlareSystems: Array<LensFlareSystem>;
  64215. /**
  64216. * Removes the given lens flare system from this scene.
  64217. * @param toRemove The lens flare system to remove
  64218. * @returns The index of the removed lens flare system
  64219. */
  64220. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  64221. /**
  64222. * Adds the given lens flare system to this scene
  64223. * @param newLensFlareSystem The lens flare system to add
  64224. */
  64225. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  64226. /**
  64227. * Gets a lens flare system using its name
  64228. * @param name defines the name to look for
  64229. * @returns the lens flare system or null if not found
  64230. */
  64231. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  64232. /**
  64233. * Gets a lens flare system using its id
  64234. * @param id defines the id to look for
  64235. * @returns the lens flare system or null if not found
  64236. */
  64237. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  64238. }
  64239. /**
  64240. * Defines the lens flare scene component responsible to manage any lens flares
  64241. * in a given scene.
  64242. */
  64243. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  64244. /**
  64245. * The component name helpful to identify the component in the list of scene components.
  64246. */
  64247. readonly name: string;
  64248. /**
  64249. * The scene the component belongs to.
  64250. */
  64251. scene: Scene;
  64252. /**
  64253. * Creates a new instance of the component for the given scene
  64254. * @param scene Defines the scene to register the component in
  64255. */
  64256. constructor(scene: Scene);
  64257. /**
  64258. * Registers the component in a given scene
  64259. */
  64260. register(): void;
  64261. /**
  64262. * Rebuilds the elements related to this component in case of
  64263. * context lost for instance.
  64264. */
  64265. rebuild(): void;
  64266. /**
  64267. * Adds all the elements from the container to the scene
  64268. * @param container the container holding the elements
  64269. */
  64270. addFromContainer(container: AbstractScene): void;
  64271. /**
  64272. * Removes all the elements in the container from the scene
  64273. * @param container contains the elements to remove
  64274. * @param dispose if the removed element should be disposed (default: false)
  64275. */
  64276. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64277. /**
  64278. * Serializes the component data to the specified json object
  64279. * @param serializationObject The object to serialize to
  64280. */
  64281. serialize(serializationObject: any): void;
  64282. /**
  64283. * Disposes the component and the associated resources.
  64284. */
  64285. dispose(): void;
  64286. private _draw;
  64287. }
  64288. }
  64289. declare module BABYLON {
  64290. /** @hidden */
  64291. export var depthPixelShader: {
  64292. name: string;
  64293. shader: string;
  64294. };
  64295. }
  64296. declare module BABYLON {
  64297. /** @hidden */
  64298. export var depthVertexShader: {
  64299. name: string;
  64300. shader: string;
  64301. };
  64302. }
  64303. declare module BABYLON {
  64304. /**
  64305. * This represents a depth renderer in Babylon.
  64306. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64307. */
  64308. export class DepthRenderer {
  64309. private _scene;
  64310. private _depthMap;
  64311. private _effect;
  64312. private readonly _storeNonLinearDepth;
  64313. private readonly _clearColor;
  64314. /** Get if the depth renderer is using packed depth or not */
  64315. readonly isPacked: boolean;
  64316. private _cachedDefines;
  64317. private _camera;
  64318. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64319. enabled: boolean;
  64320. /**
  64321. * Specifies that the depth renderer will only be used within
  64322. * the camera it is created for.
  64323. * This can help forcing its rendering during the camera processing.
  64324. */
  64325. useOnlyInActiveCamera: boolean;
  64326. /** @hidden */
  64327. static _SceneComponentInitialization: (scene: Scene) => void;
  64328. /**
  64329. * Instantiates a depth renderer
  64330. * @param scene The scene the renderer belongs to
  64331. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64332. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64333. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64334. */
  64335. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64336. /**
  64337. * Creates the depth rendering effect and checks if the effect is ready.
  64338. * @param subMesh The submesh to be used to render the depth map of
  64339. * @param useInstances If multiple world instances should be used
  64340. * @returns if the depth renderer is ready to render the depth map
  64341. */
  64342. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64343. /**
  64344. * Gets the texture which the depth map will be written to.
  64345. * @returns The depth map texture
  64346. */
  64347. getDepthMap(): RenderTargetTexture;
  64348. /**
  64349. * Disposes of the depth renderer.
  64350. */
  64351. dispose(): void;
  64352. }
  64353. }
  64354. declare module BABYLON {
  64355. /** @hidden */
  64356. export var minmaxReduxPixelShader: {
  64357. name: string;
  64358. shader: string;
  64359. };
  64360. }
  64361. declare module BABYLON {
  64362. /**
  64363. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64364. * and maximum values from all values of the texture.
  64365. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64366. * The source values are read from the red channel of the texture.
  64367. */
  64368. export class MinMaxReducer {
  64369. /**
  64370. * Observable triggered when the computation has been performed
  64371. */
  64372. onAfterReductionPerformed: Observable<{
  64373. min: number;
  64374. max: number;
  64375. }>;
  64376. protected _camera: Camera;
  64377. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64378. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64379. protected _postProcessManager: PostProcessManager;
  64380. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64381. protected _forceFullscreenViewport: boolean;
  64382. /**
  64383. * Creates a min/max reducer
  64384. * @param camera The camera to use for the post processes
  64385. */
  64386. constructor(camera: Camera);
  64387. /**
  64388. * Gets the texture used to read the values from.
  64389. */
  64390. get sourceTexture(): Nullable<RenderTargetTexture>;
  64391. /**
  64392. * Sets the source texture to read the values from.
  64393. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64394. * because in such textures '1' value must not be taken into account to compute the maximum
  64395. * as this value is used to clear the texture.
  64396. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64397. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64398. * @param depthRedux Indicates if the texture is a depth texture or not
  64399. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64400. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64401. */
  64402. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64403. /**
  64404. * Defines the refresh rate of the computation.
  64405. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64406. */
  64407. get refreshRate(): number;
  64408. set refreshRate(value: number);
  64409. protected _activated: boolean;
  64410. /**
  64411. * Gets the activation status of the reducer
  64412. */
  64413. get activated(): boolean;
  64414. /**
  64415. * Activates the reduction computation.
  64416. * When activated, the observers registered in onAfterReductionPerformed are
  64417. * called after the computation is performed
  64418. */
  64419. activate(): void;
  64420. /**
  64421. * Deactivates the reduction computation.
  64422. */
  64423. deactivate(): void;
  64424. /**
  64425. * Disposes the min/max reducer
  64426. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  64427. */
  64428. dispose(disposeAll?: boolean): void;
  64429. }
  64430. }
  64431. declare module BABYLON {
  64432. /**
  64433. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64434. */
  64435. export class DepthReducer extends MinMaxReducer {
  64436. private _depthRenderer;
  64437. private _depthRendererId;
  64438. /**
  64439. * Gets the depth renderer used for the computation.
  64440. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64441. */
  64442. get depthRenderer(): Nullable<DepthRenderer>;
  64443. /**
  64444. * Creates a depth reducer
  64445. * @param camera The camera used to render the depth texture
  64446. */
  64447. constructor(camera: Camera);
  64448. /**
  64449. * Sets the depth renderer to use to generate the depth map
  64450. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64451. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64452. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64453. */
  64454. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64455. /** @hidden */
  64456. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64457. /**
  64458. * Activates the reduction computation.
  64459. * When activated, the observers registered in onAfterReductionPerformed are
  64460. * called after the computation is performed
  64461. */
  64462. activate(): void;
  64463. /**
  64464. * Deactivates the reduction computation.
  64465. */
  64466. deactivate(): void;
  64467. /**
  64468. * Disposes the depth reducer
  64469. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  64470. */
  64471. dispose(disposeAll?: boolean): void;
  64472. }
  64473. }
  64474. declare module BABYLON {
  64475. /**
  64476. * A CSM implementation allowing casting shadows on large scenes.
  64477. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64478. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64479. */
  64480. export class CascadedShadowGenerator extends ShadowGenerator {
  64481. private static readonly frustumCornersNDCSpace;
  64482. /**
  64483. * Name of the CSM class
  64484. */
  64485. static CLASSNAME: string;
  64486. /**
  64487. * Defines the default number of cascades used by the CSM.
  64488. */
  64489. static readonly DEFAULT_CASCADES_COUNT: number;
  64490. /**
  64491. * Defines the minimum number of cascades used by the CSM.
  64492. */
  64493. static readonly MIN_CASCADES_COUNT: number;
  64494. /**
  64495. * Defines the maximum number of cascades used by the CSM.
  64496. */
  64497. static readonly MAX_CASCADES_COUNT: number;
  64498. protected _validateFilter(filter: number): number;
  64499. /**
  64500. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64501. */
  64502. penumbraDarkness: number;
  64503. private _numCascades;
  64504. /**
  64505. * Gets or set the number of cascades used by the CSM.
  64506. */
  64507. get numCascades(): number;
  64508. set numCascades(value: number);
  64509. /**
  64510. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64511. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64512. */
  64513. stabilizeCascades: boolean;
  64514. private _freezeShadowCastersBoundingInfo;
  64515. private _freezeShadowCastersBoundingInfoObservable;
  64516. /**
  64517. * Enables or disables the shadow casters bounding info computation.
  64518. * If your shadow casters don't move, you can disable this feature.
  64519. * If it is enabled, the bounding box computation is done every frame.
  64520. */
  64521. get freezeShadowCastersBoundingInfo(): boolean;
  64522. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64523. private _scbiMin;
  64524. private _scbiMax;
  64525. protected _computeShadowCastersBoundingInfo(): void;
  64526. protected _shadowCastersBoundingInfo: BoundingInfo;
  64527. /**
  64528. * Gets or sets the shadow casters bounding info.
  64529. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64530. * so that the system won't overwrite the bounds you provide
  64531. */
  64532. get shadowCastersBoundingInfo(): BoundingInfo;
  64533. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64534. protected _breaksAreDirty: boolean;
  64535. protected _minDistance: number;
  64536. protected _maxDistance: number;
  64537. /**
  64538. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64539. *
  64540. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64541. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64542. * @param min minimal distance for the breaks (default to 0.)
  64543. * @param max maximal distance for the breaks (default to 1.)
  64544. */
  64545. setMinMaxDistance(min: number, max: number): void;
  64546. /** Gets the minimal distance used in the cascade break computation */
  64547. get minDistance(): number;
  64548. /** Gets the maximal distance used in the cascade break computation */
  64549. get maxDistance(): number;
  64550. /**
  64551. * Gets the class name of that object
  64552. * @returns "CascadedShadowGenerator"
  64553. */
  64554. getClassName(): string;
  64555. private _cascadeMinExtents;
  64556. private _cascadeMaxExtents;
  64557. /**
  64558. * Gets a cascade minimum extents
  64559. * @param cascadeIndex index of the cascade
  64560. * @returns the minimum cascade extents
  64561. */
  64562. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64563. /**
  64564. * Gets a cascade maximum extents
  64565. * @param cascadeIndex index of the cascade
  64566. * @returns the maximum cascade extents
  64567. */
  64568. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64569. private _cascades;
  64570. private _currentLayer;
  64571. private _viewSpaceFrustumsZ;
  64572. private _viewMatrices;
  64573. private _projectionMatrices;
  64574. private _transformMatrices;
  64575. private _transformMatricesAsArray;
  64576. private _frustumLengths;
  64577. private _lightSizeUVCorrection;
  64578. private _depthCorrection;
  64579. private _frustumCornersWorldSpace;
  64580. private _frustumCenter;
  64581. private _shadowCameraPos;
  64582. private _shadowMaxZ;
  64583. /**
  64584. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64585. * It defaults to camera.maxZ
  64586. */
  64587. get shadowMaxZ(): number;
  64588. /**
  64589. * Sets the shadow max z distance.
  64590. */
  64591. set shadowMaxZ(value: number);
  64592. protected _debug: boolean;
  64593. /**
  64594. * Gets or sets the debug flag.
  64595. * When enabled, the cascades are materialized by different colors on the screen.
  64596. */
  64597. get debug(): boolean;
  64598. set debug(dbg: boolean);
  64599. private _depthClamp;
  64600. /**
  64601. * Gets or sets the depth clamping value.
  64602. *
  64603. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64604. * to account for the shadow casters far away.
  64605. *
  64606. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64607. */
  64608. get depthClamp(): boolean;
  64609. set depthClamp(value: boolean);
  64610. private _cascadeBlendPercentage;
  64611. /**
  64612. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64613. * It defaults to 0.1 (10% blending).
  64614. */
  64615. get cascadeBlendPercentage(): number;
  64616. set cascadeBlendPercentage(value: number);
  64617. private _lambda;
  64618. /**
  64619. * Gets or set the lambda parameter.
  64620. * This parameter is used to split the camera frustum and create the cascades.
  64621. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  64622. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64623. */
  64624. get lambda(): number;
  64625. set lambda(value: number);
  64626. /**
  64627. * Gets the view matrix corresponding to a given cascade
  64628. * @param cascadeNum cascade to retrieve the view matrix from
  64629. * @returns the cascade view matrix
  64630. */
  64631. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64632. /**
  64633. * Gets the projection matrix corresponding to a given cascade
  64634. * @param cascadeNum cascade to retrieve the projection matrix from
  64635. * @returns the cascade projection matrix
  64636. */
  64637. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64638. /**
  64639. * Gets the transformation matrix corresponding to a given cascade
  64640. * @param cascadeNum cascade to retrieve the transformation matrix from
  64641. * @returns the cascade transformation matrix
  64642. */
  64643. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64644. private _depthRenderer;
  64645. /**
  64646. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64647. *
  64648. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64649. *
  64650. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64651. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64652. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  64653. */
  64654. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64655. private _depthReducer;
  64656. private _autoCalcDepthBounds;
  64657. /**
  64658. * Gets or sets the autoCalcDepthBounds property.
  64659. *
  64660. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64661. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64662. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64663. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64664. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64665. */
  64666. get autoCalcDepthBounds(): boolean;
  64667. set autoCalcDepthBounds(value: boolean);
  64668. /**
  64669. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64670. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64671. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64672. * for setting the refresh rate on the renderer yourself!
  64673. */
  64674. get autoCalcDepthBoundsRefreshRate(): number;
  64675. set autoCalcDepthBoundsRefreshRate(value: number);
  64676. /**
  64677. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64678. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64679. * you change the camera near/far planes!
  64680. */
  64681. splitFrustum(): void;
  64682. private _splitFrustum;
  64683. private _computeMatrices;
  64684. private _computeFrustumInWorldSpace;
  64685. private _computeCascadeFrustum;
  64686. /**
  64687. * Support test.
  64688. */
  64689. static get IsSupported(): boolean;
  64690. /** @hidden */
  64691. static _SceneComponentInitialization: (scene: Scene) => void;
  64692. /**
  64693. * Creates a Cascaded Shadow Generator object.
  64694. * A ShadowGenerator is the required tool to use the shadows.
  64695. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64696. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64697. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64698. * @param light The directional light object generating the shadows.
  64699. * @param usefulFloatFirst 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.
  64700. */
  64701. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64702. protected _initializeGenerator(): void;
  64703. protected _createTargetRenderTexture(): void;
  64704. protected _initializeShadowMap(): void;
  64705. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64706. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64707. /**
  64708. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64709. * @param defines Defines of the material we want to update
  64710. * @param lightIndex Index of the light in the enabled light list of the material
  64711. */
  64712. prepareDefines(defines: any, lightIndex: number): void;
  64713. /**
  64714. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64715. * defined in the generator but impacting the effect).
  64716. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64717. * @param effect The effect we are binfing the information for
  64718. */
  64719. bindShadowLight(lightIndex: string, effect: Effect): void;
  64720. /**
  64721. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64722. * (eq to view projection * shadow projection matrices)
  64723. * @returns The transform matrix used to create the shadow map
  64724. */
  64725. getTransformMatrix(): Matrix;
  64726. /**
  64727. * Disposes the ShadowGenerator.
  64728. * Returns nothing.
  64729. */
  64730. dispose(): void;
  64731. /**
  64732. * Serializes the shadow generator setup to a json object.
  64733. * @returns The serialized JSON object
  64734. */
  64735. serialize(): any;
  64736. /**
  64737. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64738. * @param parsedShadowGenerator The JSON object to parse
  64739. * @param scene The scene to create the shadow map for
  64740. * @returns The parsed shadow generator
  64741. */
  64742. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64743. }
  64744. }
  64745. declare module BABYLON {
  64746. /**
  64747. * Defines the shadow generator component responsible to manage any shadow generators
  64748. * in a given scene.
  64749. */
  64750. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64751. /**
  64752. * The component name helpful to identify the component in the list of scene components.
  64753. */
  64754. readonly name: string;
  64755. /**
  64756. * The scene the component belongs to.
  64757. */
  64758. scene: Scene;
  64759. /**
  64760. * Creates a new instance of the component for the given scene
  64761. * @param scene Defines the scene to register the component in
  64762. */
  64763. constructor(scene: Scene);
  64764. /**
  64765. * Registers the component in a given scene
  64766. */
  64767. register(): void;
  64768. /**
  64769. * Rebuilds the elements related to this component in case of
  64770. * context lost for instance.
  64771. */
  64772. rebuild(): void;
  64773. /**
  64774. * Serializes the component data to the specified json object
  64775. * @param serializationObject The object to serialize to
  64776. */
  64777. serialize(serializationObject: any): void;
  64778. /**
  64779. * Adds all the elements from the container to the scene
  64780. * @param container the container holding the elements
  64781. */
  64782. addFromContainer(container: AbstractScene): void;
  64783. /**
  64784. * Removes all the elements in the container from the scene
  64785. * @param container contains the elements to remove
  64786. * @param dispose if the removed element should be disposed (default: false)
  64787. */
  64788. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64789. /**
  64790. * Rebuilds the elements related to this component in case of
  64791. * context lost for instance.
  64792. */
  64793. dispose(): void;
  64794. private _gatherRenderTargets;
  64795. }
  64796. }
  64797. declare module BABYLON {
  64798. /**
  64799. * A point light is a light defined by an unique point in world space.
  64800. * The light is emitted in every direction from this point.
  64801. * A good example of a point light is a standard light bulb.
  64802. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64803. */
  64804. export class PointLight extends ShadowLight {
  64805. private _shadowAngle;
  64806. /**
  64807. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64808. * This specifies what angle the shadow will use to be created.
  64809. *
  64810. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64811. */
  64812. get shadowAngle(): number;
  64813. /**
  64814. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64815. * This specifies what angle the shadow will use to be created.
  64816. *
  64817. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64818. */
  64819. set shadowAngle(value: number);
  64820. /**
  64821. * Gets the direction if it has been set.
  64822. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64823. */
  64824. get direction(): Vector3;
  64825. /**
  64826. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64827. */
  64828. set direction(value: Vector3);
  64829. /**
  64830. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64831. * A PointLight emits the light in every direction.
  64832. * It can cast shadows.
  64833. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64834. * ```javascript
  64835. * var pointLight = new PointLight("pl", camera.position, scene);
  64836. * ```
  64837. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64838. * @param name The light friendly name
  64839. * @param position The position of the point light in the scene
  64840. * @param scene The scene the lights belongs to
  64841. */
  64842. constructor(name: string, position: Vector3, scene: Scene);
  64843. /**
  64844. * Returns the string "PointLight"
  64845. * @returns the class name
  64846. */
  64847. getClassName(): string;
  64848. /**
  64849. * Returns the integer 0.
  64850. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64851. */
  64852. getTypeID(): number;
  64853. /**
  64854. * Specifies whether or not the shadowmap should be a cube texture.
  64855. * @returns true if the shadowmap needs to be a cube texture.
  64856. */
  64857. needCube(): boolean;
  64858. /**
  64859. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64860. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64861. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64862. */
  64863. getShadowDirection(faceIndex?: number): Vector3;
  64864. /**
  64865. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64866. * - fov = PI / 2
  64867. * - aspect ratio : 1.0
  64868. * - z-near and far equal to the active camera minZ and maxZ.
  64869. * Returns the PointLight.
  64870. */
  64871. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64872. protected _buildUniformLayout(): void;
  64873. /**
  64874. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64875. * @param effect The effect to update
  64876. * @param lightIndex The index of the light in the effect to update
  64877. * @returns The point light
  64878. */
  64879. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64880. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64881. /**
  64882. * Prepares the list of defines specific to the light type.
  64883. * @param defines the list of defines
  64884. * @param lightIndex defines the index of the light for the effect
  64885. */
  64886. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64887. }
  64888. }
  64889. declare module BABYLON {
  64890. /**
  64891. * Header information of HDR texture files.
  64892. */
  64893. export interface HDRInfo {
  64894. /**
  64895. * The height of the texture in pixels.
  64896. */
  64897. height: number;
  64898. /**
  64899. * The width of the texture in pixels.
  64900. */
  64901. width: number;
  64902. /**
  64903. * The index of the beginning of the data in the binary file.
  64904. */
  64905. dataPosition: number;
  64906. }
  64907. /**
  64908. * This groups tools to convert HDR texture to native colors array.
  64909. */
  64910. export class HDRTools {
  64911. private static Ldexp;
  64912. private static Rgbe2float;
  64913. private static readStringLine;
  64914. /**
  64915. * Reads header information from an RGBE texture stored in a native array.
  64916. * More information on this format are available here:
  64917. * https://en.wikipedia.org/wiki/RGBE_image_format
  64918. *
  64919. * @param uint8array The binary file stored in native array.
  64920. * @return The header information.
  64921. */
  64922. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64923. /**
  64924. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64925. * This RGBE texture needs to store the information as a panorama.
  64926. *
  64927. * More information on this format are available here:
  64928. * https://en.wikipedia.org/wiki/RGBE_image_format
  64929. *
  64930. * @param buffer The binary file stored in an array buffer.
  64931. * @param size The expected size of the extracted cubemap.
  64932. * @return The Cube Map information.
  64933. */
  64934. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64935. /**
  64936. * Returns the pixels data extracted from an RGBE texture.
  64937. * This pixels will be stored left to right up to down in the R G B order in one array.
  64938. *
  64939. * More information on this format are available here:
  64940. * https://en.wikipedia.org/wiki/RGBE_image_format
  64941. *
  64942. * @param uint8array The binary file stored in an array buffer.
  64943. * @param hdrInfo The header information of the file.
  64944. * @return The pixels data in RGB right to left up to down order.
  64945. */
  64946. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64947. private static RGBE_ReadPixels_RLE;
  64948. private static RGBE_ReadPixels_NOT_RLE;
  64949. }
  64950. }
  64951. declare module BABYLON {
  64952. /**
  64953. * Effect Render Options
  64954. */
  64955. export interface IEffectRendererOptions {
  64956. /**
  64957. * Defines the vertices positions.
  64958. */
  64959. positions?: number[];
  64960. /**
  64961. * Defines the indices.
  64962. */
  64963. indices?: number[];
  64964. }
  64965. /**
  64966. * Helper class to render one or more effects.
  64967. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64968. */
  64969. export class EffectRenderer {
  64970. private engine;
  64971. private static _DefaultOptions;
  64972. private _vertexBuffers;
  64973. private _indexBuffer;
  64974. private _fullscreenViewport;
  64975. /**
  64976. * Creates an effect renderer
  64977. * @param engine the engine to use for rendering
  64978. * @param options defines the options of the effect renderer
  64979. */
  64980. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64981. /**
  64982. * Sets the current viewport in normalized coordinates 0-1
  64983. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64984. */
  64985. setViewport(viewport?: Viewport): void;
  64986. /**
  64987. * Binds the embedded attributes buffer to the effect.
  64988. * @param effect Defines the effect to bind the attributes for
  64989. */
  64990. bindBuffers(effect: Effect): void;
  64991. /**
  64992. * Sets the current effect wrapper to use during draw.
  64993. * The effect needs to be ready before calling this api.
  64994. * This also sets the default full screen position attribute.
  64995. * @param effectWrapper Defines the effect to draw with
  64996. */
  64997. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64998. /**
  64999. * Restores engine states
  65000. */
  65001. restoreStates(): void;
  65002. /**
  65003. * Draws a full screen quad.
  65004. */
  65005. draw(): void;
  65006. private isRenderTargetTexture;
  65007. /**
  65008. * renders one or more effects to a specified texture
  65009. * @param effectWrapper the effect to renderer
  65010. * @param outputTexture texture to draw to, if null it will render to the screen.
  65011. */
  65012. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65013. /**
  65014. * Disposes of the effect renderer
  65015. */
  65016. dispose(): void;
  65017. }
  65018. /**
  65019. * Options to create an EffectWrapper
  65020. */
  65021. interface EffectWrapperCreationOptions {
  65022. /**
  65023. * Engine to use to create the effect
  65024. */
  65025. engine: ThinEngine;
  65026. /**
  65027. * Fragment shader for the effect
  65028. */
  65029. fragmentShader: string;
  65030. /**
  65031. * Use the shader store instead of direct source code
  65032. */
  65033. useShaderStore?: boolean;
  65034. /**
  65035. * Vertex shader for the effect
  65036. */
  65037. vertexShader?: string;
  65038. /**
  65039. * Attributes to use in the shader
  65040. */
  65041. attributeNames?: Array<string>;
  65042. /**
  65043. * Uniforms to use in the shader
  65044. */
  65045. uniformNames?: Array<string>;
  65046. /**
  65047. * Texture sampler names to use in the shader
  65048. */
  65049. samplerNames?: Array<string>;
  65050. /**
  65051. * Defines to use in the shader
  65052. */
  65053. defines?: Array<string>;
  65054. /**
  65055. * Callback when effect is compiled
  65056. */
  65057. onCompiled?: Nullable<(effect: Effect) => void>;
  65058. /**
  65059. * The friendly name of the effect displayed in Spector.
  65060. */
  65061. name?: string;
  65062. }
  65063. /**
  65064. * Wraps an effect to be used for rendering
  65065. */
  65066. export class EffectWrapper {
  65067. /**
  65068. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65069. */
  65070. onApplyObservable: Observable<{}>;
  65071. /**
  65072. * The underlying effect
  65073. */
  65074. effect: Effect;
  65075. /**
  65076. * Creates an effect to be renderer
  65077. * @param creationOptions options to create the effect
  65078. */
  65079. constructor(creationOptions: EffectWrapperCreationOptions);
  65080. /**
  65081. * Disposes of the effect wrapper
  65082. */
  65083. dispose(): void;
  65084. }
  65085. }
  65086. declare module BABYLON {
  65087. /** @hidden */
  65088. export var hdrFilteringVertexShader: {
  65089. name: string;
  65090. shader: string;
  65091. };
  65092. }
  65093. declare module BABYLON {
  65094. /** @hidden */
  65095. export var hdrFilteringPixelShader: {
  65096. name: string;
  65097. shader: string;
  65098. };
  65099. }
  65100. declare module BABYLON {
  65101. /**
  65102. * Options for texture filtering
  65103. */
  65104. interface IHDRFilteringOptions {
  65105. /**
  65106. * Scales pixel intensity for the input HDR map.
  65107. */
  65108. hdrScale?: number;
  65109. /**
  65110. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  65111. */
  65112. quality?: number;
  65113. }
  65114. /**
  65115. * Filters HDR maps to get correct renderings of PBR reflections
  65116. */
  65117. export class HDRFiltering {
  65118. private _engine;
  65119. private _effectRenderer;
  65120. private _effectWrapper;
  65121. private _lodGenerationOffset;
  65122. private _lodGenerationScale;
  65123. /**
  65124. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  65125. * you care about baking speed.
  65126. */
  65127. quality: number;
  65128. /**
  65129. * Scales pixel intensity for the input HDR map.
  65130. */
  65131. hdrScale: number;
  65132. /**
  65133. * Instantiates HDR filter for reflection maps
  65134. *
  65135. * @param engine Thin engine
  65136. * @param options Options
  65137. */
  65138. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  65139. private _createRenderTarget;
  65140. private _prefilterInternal;
  65141. private _createEffect;
  65142. /**
  65143. * Get a value indicating if the filter is ready to be used
  65144. * @param texture Texture to filter
  65145. * @returns true if the filter is ready
  65146. */
  65147. isReady(texture: BaseTexture): boolean;
  65148. /**
  65149. * Prefilters a cube texture to have mipmap levels representing roughness values.
  65150. * Prefiltering will be invoked at the end of next rendering pass.
  65151. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  65152. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  65153. * @param texture Texture to filter
  65154. * @param onFinished Callback when filtering is done
  65155. * @return Promise called when prefiltering is done
  65156. */
  65157. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  65158. }
  65159. }
  65160. declare module BABYLON {
  65161. /**
  65162. * This represents a texture coming from an HDR input.
  65163. *
  65164. * The only supported format is currently panorama picture stored in RGBE format.
  65165. * Example of such files can be found on HDRLib: http://hdrlib.com/
  65166. */
  65167. export class HDRCubeTexture extends BaseTexture {
  65168. private static _facesMapping;
  65169. private _generateHarmonics;
  65170. private _noMipmap;
  65171. private _prefilterOnLoad;
  65172. private _textureMatrix;
  65173. private _size;
  65174. private _onLoad;
  65175. private _onError;
  65176. /**
  65177. * The texture URL.
  65178. */
  65179. url: string;
  65180. protected _isBlocking: boolean;
  65181. /**
  65182. * Sets whether or not the texture is blocking during loading.
  65183. */
  65184. set isBlocking(value: boolean);
  65185. /**
  65186. * Gets whether or not the texture is blocking during loading.
  65187. */
  65188. get isBlocking(): boolean;
  65189. protected _rotationY: number;
  65190. /**
  65191. * Sets texture matrix rotation angle around Y axis in radians.
  65192. */
  65193. set rotationY(value: number);
  65194. /**
  65195. * Gets texture matrix rotation angle around Y axis radians.
  65196. */
  65197. get rotationY(): number;
  65198. /**
  65199. * Gets or sets the center of the bounding box associated with the cube texture
  65200. * It must define where the camera used to render the texture was set
  65201. */
  65202. boundingBoxPosition: Vector3;
  65203. private _boundingBoxSize;
  65204. /**
  65205. * Gets or sets the size of the bounding box associated with the cube texture
  65206. * When defined, the cubemap will switch to local mode
  65207. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65208. * @example https://www.babylonjs-playground.com/#RNASML
  65209. */
  65210. set boundingBoxSize(value: Vector3);
  65211. get boundingBoxSize(): Vector3;
  65212. /**
  65213. * Instantiates an HDRTexture from the following parameters.
  65214. *
  65215. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  65216. * @param sceneOrEngine The scene or engine the texture will be used in
  65217. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65218. * @param noMipmap Forces to not generate the mipmap if true
  65219. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  65220. * @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)
  65221. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  65222. */
  65223. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65224. /**
  65225. * Get the current class name of the texture useful for serialization or dynamic coding.
  65226. * @returns "HDRCubeTexture"
  65227. */
  65228. getClassName(): string;
  65229. /**
  65230. * Occurs when the file is raw .hdr file.
  65231. */
  65232. private loadTexture;
  65233. clone(): HDRCubeTexture;
  65234. delayLoad(): void;
  65235. /**
  65236. * Get the texture reflection matrix used to rotate/transform the reflection.
  65237. * @returns the reflection matrix
  65238. */
  65239. getReflectionTextureMatrix(): Matrix;
  65240. /**
  65241. * Set the texture reflection matrix used to rotate/transform the reflection.
  65242. * @param value Define the reflection matrix to set
  65243. */
  65244. setReflectionTextureMatrix(value: Matrix): void;
  65245. /**
  65246. * Parses a JSON representation of an HDR Texture in order to create the texture
  65247. * @param parsedTexture Define the JSON representation
  65248. * @param scene Define the scene the texture should be created in
  65249. * @param rootUrl Define the root url in case we need to load relative dependencies
  65250. * @returns the newly created texture after parsing
  65251. */
  65252. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  65253. serialize(): any;
  65254. }
  65255. }
  65256. declare module BABYLON {
  65257. /**
  65258. * Class used to control physics engine
  65259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65260. */
  65261. export class PhysicsEngine implements IPhysicsEngine {
  65262. private _physicsPlugin;
  65263. /**
  65264. * Global value used to control the smallest number supported by the simulation
  65265. */
  65266. static Epsilon: number;
  65267. private _impostors;
  65268. private _joints;
  65269. private _subTimeStep;
  65270. /**
  65271. * Gets the gravity vector used by the simulation
  65272. */
  65273. gravity: Vector3;
  65274. /**
  65275. * Factory used to create the default physics plugin.
  65276. * @returns The default physics plugin
  65277. */
  65278. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  65279. /**
  65280. * Creates a new Physics Engine
  65281. * @param gravity defines the gravity vector used by the simulation
  65282. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  65283. */
  65284. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  65285. /**
  65286. * Sets the gravity vector used by the simulation
  65287. * @param gravity defines the gravity vector to use
  65288. */
  65289. setGravity(gravity: Vector3): void;
  65290. /**
  65291. * Set the time step of the physics engine.
  65292. * Default is 1/60.
  65293. * To slow it down, enter 1/600 for example.
  65294. * To speed it up, 1/30
  65295. * @param newTimeStep defines the new timestep to apply to this world.
  65296. */
  65297. setTimeStep(newTimeStep?: number): void;
  65298. /**
  65299. * Get the time step of the physics engine.
  65300. * @returns the current time step
  65301. */
  65302. getTimeStep(): number;
  65303. /**
  65304. * Set the sub time step of the physics engine.
  65305. * Default is 0 meaning there is no sub steps
  65306. * To increase physics resolution precision, set a small value (like 1 ms)
  65307. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65308. */
  65309. setSubTimeStep(subTimeStep?: number): void;
  65310. /**
  65311. * Get the sub time step of the physics engine.
  65312. * @returns the current sub time step
  65313. */
  65314. getSubTimeStep(): number;
  65315. /**
  65316. * Release all resources
  65317. */
  65318. dispose(): void;
  65319. /**
  65320. * Gets the name of the current physics plugin
  65321. * @returns the name of the plugin
  65322. */
  65323. getPhysicsPluginName(): string;
  65324. /**
  65325. * Adding a new impostor for the impostor tracking.
  65326. * This will be done by the impostor itself.
  65327. * @param impostor the impostor to add
  65328. */
  65329. addImpostor(impostor: PhysicsImpostor): void;
  65330. /**
  65331. * Remove an impostor from the engine.
  65332. * This impostor and its mesh will not longer be updated by the physics engine.
  65333. * @param impostor the impostor to remove
  65334. */
  65335. removeImpostor(impostor: PhysicsImpostor): void;
  65336. /**
  65337. * Add a joint to the physics engine
  65338. * @param mainImpostor defines the main impostor to which the joint is added.
  65339. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65340. * @param joint defines the joint that will connect both impostors.
  65341. */
  65342. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65343. /**
  65344. * Removes a joint from the simulation
  65345. * @param mainImpostor defines the impostor used with the joint
  65346. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65347. * @param joint defines the joint to remove
  65348. */
  65349. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65350. /**
  65351. * Called by the scene. No need to call it.
  65352. * @param delta defines the timespan between frames
  65353. */
  65354. _step(delta: number): void;
  65355. /**
  65356. * Gets the current plugin used to run the simulation
  65357. * @returns current plugin
  65358. */
  65359. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65360. /**
  65361. * Gets the list of physic impostors
  65362. * @returns an array of PhysicsImpostor
  65363. */
  65364. getImpostors(): Array<PhysicsImpostor>;
  65365. /**
  65366. * Gets the impostor for a physics enabled object
  65367. * @param object defines the object impersonated by the impostor
  65368. * @returns the PhysicsImpostor or null if not found
  65369. */
  65370. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65371. /**
  65372. * Gets the impostor for a physics body object
  65373. * @param body defines physics body used by the impostor
  65374. * @returns the PhysicsImpostor or null if not found
  65375. */
  65376. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65377. /**
  65378. * Does a raycast in the physics world
  65379. * @param from when should the ray start?
  65380. * @param to when should the ray end?
  65381. * @returns PhysicsRaycastResult
  65382. */
  65383. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65384. }
  65385. }
  65386. declare module BABYLON {
  65387. /** @hidden */
  65388. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65389. private _useDeltaForWorldStep;
  65390. world: any;
  65391. name: string;
  65392. private _physicsMaterials;
  65393. private _fixedTimeStep;
  65394. private _cannonRaycastResult;
  65395. private _raycastResult;
  65396. private _physicsBodysToRemoveAfterStep;
  65397. private _firstFrame;
  65398. BJSCANNON: any;
  65399. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65400. setGravity(gravity: Vector3): void;
  65401. setTimeStep(timeStep: number): void;
  65402. getTimeStep(): number;
  65403. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65404. private _removeMarkedPhysicsBodiesFromWorld;
  65405. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65406. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65407. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65408. private _processChildMeshes;
  65409. removePhysicsBody(impostor: PhysicsImpostor): void;
  65410. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65411. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65412. private _addMaterial;
  65413. private _checkWithEpsilon;
  65414. private _createShape;
  65415. private _createHeightmap;
  65416. private _minus90X;
  65417. private _plus90X;
  65418. private _tmpPosition;
  65419. private _tmpDeltaPosition;
  65420. private _tmpUnityRotation;
  65421. private _updatePhysicsBodyTransformation;
  65422. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65423. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65424. isSupported(): boolean;
  65425. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65426. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65427. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65428. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65429. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65430. getBodyMass(impostor: PhysicsImpostor): number;
  65431. getBodyFriction(impostor: PhysicsImpostor): number;
  65432. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65433. getBodyRestitution(impostor: PhysicsImpostor): number;
  65434. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65435. sleepBody(impostor: PhysicsImpostor): void;
  65436. wakeUpBody(impostor: PhysicsImpostor): void;
  65437. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65438. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65439. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65440. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65441. getRadius(impostor: PhysicsImpostor): number;
  65442. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65443. dispose(): void;
  65444. private _extendNamespace;
  65445. /**
  65446. * Does a raycast in the physics world
  65447. * @param from when should the ray start?
  65448. * @param to when should the ray end?
  65449. * @returns PhysicsRaycastResult
  65450. */
  65451. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65452. }
  65453. }
  65454. declare module BABYLON {
  65455. /** @hidden */
  65456. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65457. private _useDeltaForWorldStep;
  65458. world: any;
  65459. name: string;
  65460. BJSOIMO: any;
  65461. private _raycastResult;
  65462. private _fixedTimeStep;
  65463. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65464. setGravity(gravity: Vector3): void;
  65465. setTimeStep(timeStep: number): void;
  65466. getTimeStep(): number;
  65467. private _tmpImpostorsArray;
  65468. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65469. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65470. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65471. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65472. private _tmpPositionVector;
  65473. removePhysicsBody(impostor: PhysicsImpostor): void;
  65474. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65475. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65476. isSupported(): boolean;
  65477. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65478. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65479. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65480. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65481. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65482. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65483. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65484. getBodyMass(impostor: PhysicsImpostor): number;
  65485. getBodyFriction(impostor: PhysicsImpostor): number;
  65486. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65487. getBodyRestitution(impostor: PhysicsImpostor): number;
  65488. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65489. sleepBody(impostor: PhysicsImpostor): void;
  65490. wakeUpBody(impostor: PhysicsImpostor): void;
  65491. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65492. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65493. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65494. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65495. getRadius(impostor: PhysicsImpostor): number;
  65496. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65497. dispose(): void;
  65498. /**
  65499. * Does a raycast in the physics world
  65500. * @param from when should the ray start?
  65501. * @param to when should the ray end?
  65502. * @returns PhysicsRaycastResult
  65503. */
  65504. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65505. }
  65506. }
  65507. declare module BABYLON {
  65508. /**
  65509. * AmmoJS Physics plugin
  65510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65511. * @see https://github.com/kripken/ammo.js/
  65512. */
  65513. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65514. private _useDeltaForWorldStep;
  65515. /**
  65516. * Reference to the Ammo library
  65517. */
  65518. bjsAMMO: any;
  65519. /**
  65520. * Created ammoJS world which physics bodies are added to
  65521. */
  65522. world: any;
  65523. /**
  65524. * Name of the plugin
  65525. */
  65526. name: string;
  65527. private _timeStep;
  65528. private _fixedTimeStep;
  65529. private _maxSteps;
  65530. private _tmpQuaternion;
  65531. private _tmpAmmoTransform;
  65532. private _tmpAmmoQuaternion;
  65533. private _tmpAmmoConcreteContactResultCallback;
  65534. private _collisionConfiguration;
  65535. private _dispatcher;
  65536. private _overlappingPairCache;
  65537. private _solver;
  65538. private _softBodySolver;
  65539. private _tmpAmmoVectorA;
  65540. private _tmpAmmoVectorB;
  65541. private _tmpAmmoVectorC;
  65542. private _tmpAmmoVectorD;
  65543. private _tmpContactCallbackResult;
  65544. private _tmpAmmoVectorRCA;
  65545. private _tmpAmmoVectorRCB;
  65546. private _raycastResult;
  65547. private _tmpContactPoint;
  65548. private static readonly DISABLE_COLLISION_FLAG;
  65549. private static readonly KINEMATIC_FLAG;
  65550. private static readonly DISABLE_DEACTIVATION_FLAG;
  65551. /**
  65552. * Initializes the ammoJS plugin
  65553. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65554. * @param ammoInjection can be used to inject your own ammo reference
  65555. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65556. */
  65557. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65558. /**
  65559. * Sets the gravity of the physics world (m/(s^2))
  65560. * @param gravity Gravity to set
  65561. */
  65562. setGravity(gravity: Vector3): void;
  65563. /**
  65564. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65565. * @param timeStep timestep to use in seconds
  65566. */
  65567. setTimeStep(timeStep: number): void;
  65568. /**
  65569. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  65570. * @param fixedTimeStep fixedTimeStep to use in seconds
  65571. */
  65572. setFixedTimeStep(fixedTimeStep: number): void;
  65573. /**
  65574. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65575. * @param maxSteps the maximum number of steps by the physics engine per frame
  65576. */
  65577. setMaxSteps(maxSteps: number): void;
  65578. /**
  65579. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65580. * @returns the current timestep in seconds
  65581. */
  65582. getTimeStep(): number;
  65583. /**
  65584. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65585. */
  65586. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65587. private _isImpostorInContact;
  65588. private _isImpostorPairInContact;
  65589. private _stepSimulation;
  65590. /**
  65591. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65592. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65593. * After the step the babylon meshes are set to the position of the physics imposters
  65594. * @param delta amount of time to step forward
  65595. * @param impostors array of imposters to update before/after the step
  65596. */
  65597. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65598. /**
  65599. * Update babylon mesh to match physics world object
  65600. * @param impostor imposter to match
  65601. */
  65602. private _afterSoftStep;
  65603. /**
  65604. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65605. * @param impostor imposter to match
  65606. */
  65607. private _ropeStep;
  65608. /**
  65609. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65610. * @param impostor imposter to match
  65611. */
  65612. private _softbodyOrClothStep;
  65613. private _tmpMatrix;
  65614. /**
  65615. * Applies an impulse on the imposter
  65616. * @param impostor imposter to apply impulse to
  65617. * @param force amount of force to be applied to the imposter
  65618. * @param contactPoint the location to apply the impulse on the imposter
  65619. */
  65620. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65621. /**
  65622. * Applies a force on the imposter
  65623. * @param impostor imposter to apply force
  65624. * @param force amount of force to be applied to the imposter
  65625. * @param contactPoint the location to apply the force on the imposter
  65626. */
  65627. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65628. /**
  65629. * Creates a physics body using the plugin
  65630. * @param impostor the imposter to create the physics body on
  65631. */
  65632. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65633. /**
  65634. * Removes the physics body from the imposter and disposes of the body's memory
  65635. * @param impostor imposter to remove the physics body from
  65636. */
  65637. removePhysicsBody(impostor: PhysicsImpostor): void;
  65638. /**
  65639. * Generates a joint
  65640. * @param impostorJoint the imposter joint to create the joint with
  65641. */
  65642. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65643. /**
  65644. * Removes a joint
  65645. * @param impostorJoint the imposter joint to remove the joint from
  65646. */
  65647. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65648. private _addMeshVerts;
  65649. /**
  65650. * Initialise the soft body vertices to match its object's (mesh) vertices
  65651. * Softbody vertices (nodes) are in world space and to match this
  65652. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65653. * @param impostor to create the softbody for
  65654. */
  65655. private _softVertexData;
  65656. /**
  65657. * Create an impostor's soft body
  65658. * @param impostor to create the softbody for
  65659. */
  65660. private _createSoftbody;
  65661. /**
  65662. * Create cloth for an impostor
  65663. * @param impostor to create the softbody for
  65664. */
  65665. private _createCloth;
  65666. /**
  65667. * Create rope for an impostor
  65668. * @param impostor to create the softbody for
  65669. */
  65670. private _createRope;
  65671. /**
  65672. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65673. * @param impostor to create the custom physics shape for
  65674. */
  65675. private _createCustom;
  65676. private _addHullVerts;
  65677. private _createShape;
  65678. /**
  65679. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65680. * @param impostor imposter containing the physics body and babylon object
  65681. */
  65682. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65683. /**
  65684. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65685. * @param impostor imposter containing the physics body and babylon object
  65686. * @param newPosition new position
  65687. * @param newRotation new rotation
  65688. */
  65689. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65690. /**
  65691. * If this plugin is supported
  65692. * @returns true if its supported
  65693. */
  65694. isSupported(): boolean;
  65695. /**
  65696. * Sets the linear velocity of the physics body
  65697. * @param impostor imposter to set the velocity on
  65698. * @param velocity velocity to set
  65699. */
  65700. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65701. /**
  65702. * Sets the angular velocity of the physics body
  65703. * @param impostor imposter to set the velocity on
  65704. * @param velocity velocity to set
  65705. */
  65706. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65707. /**
  65708. * gets the linear velocity
  65709. * @param impostor imposter to get linear velocity from
  65710. * @returns linear velocity
  65711. */
  65712. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65713. /**
  65714. * gets the angular velocity
  65715. * @param impostor imposter to get angular velocity from
  65716. * @returns angular velocity
  65717. */
  65718. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65719. /**
  65720. * Sets the mass of physics body
  65721. * @param impostor imposter to set the mass on
  65722. * @param mass mass to set
  65723. */
  65724. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65725. /**
  65726. * Gets the mass of the physics body
  65727. * @param impostor imposter to get the mass from
  65728. * @returns mass
  65729. */
  65730. getBodyMass(impostor: PhysicsImpostor): number;
  65731. /**
  65732. * Gets friction of the impostor
  65733. * @param impostor impostor to get friction from
  65734. * @returns friction value
  65735. */
  65736. getBodyFriction(impostor: PhysicsImpostor): number;
  65737. /**
  65738. * Sets friction of the impostor
  65739. * @param impostor impostor to set friction on
  65740. * @param friction friction value
  65741. */
  65742. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65743. /**
  65744. * Gets restitution of the impostor
  65745. * @param impostor impostor to get restitution from
  65746. * @returns restitution value
  65747. */
  65748. getBodyRestitution(impostor: PhysicsImpostor): number;
  65749. /**
  65750. * Sets restitution of the impostor
  65751. * @param impostor impostor to set resitution on
  65752. * @param restitution resitution value
  65753. */
  65754. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65755. /**
  65756. * Gets pressure inside the impostor
  65757. * @param impostor impostor to get pressure from
  65758. * @returns pressure value
  65759. */
  65760. getBodyPressure(impostor: PhysicsImpostor): number;
  65761. /**
  65762. * Sets pressure inside a soft body impostor
  65763. * Cloth and rope must remain 0 pressure
  65764. * @param impostor impostor to set pressure on
  65765. * @param pressure pressure value
  65766. */
  65767. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65768. /**
  65769. * Gets stiffness of the impostor
  65770. * @param impostor impostor to get stiffness from
  65771. * @returns pressure value
  65772. */
  65773. getBodyStiffness(impostor: PhysicsImpostor): number;
  65774. /**
  65775. * Sets stiffness of the impostor
  65776. * @param impostor impostor to set stiffness on
  65777. * @param stiffness stiffness value from 0 to 1
  65778. */
  65779. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65780. /**
  65781. * Gets velocityIterations of the impostor
  65782. * @param impostor impostor to get velocity iterations from
  65783. * @returns velocityIterations value
  65784. */
  65785. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65786. /**
  65787. * Sets velocityIterations of the impostor
  65788. * @param impostor impostor to set velocity iterations on
  65789. * @param velocityIterations velocityIterations value
  65790. */
  65791. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65792. /**
  65793. * Gets positionIterations of the impostor
  65794. * @param impostor impostor to get position iterations from
  65795. * @returns positionIterations value
  65796. */
  65797. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65798. /**
  65799. * Sets positionIterations of the impostor
  65800. * @param impostor impostor to set position on
  65801. * @param positionIterations positionIterations value
  65802. */
  65803. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65804. /**
  65805. * Append an anchor to a cloth object
  65806. * @param impostor is the cloth impostor to add anchor to
  65807. * @param otherImpostor is the rigid impostor to anchor to
  65808. * @param width ratio across width from 0 to 1
  65809. * @param height ratio up height from 0 to 1
  65810. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  65811. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65812. */
  65813. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65814. /**
  65815. * Append an hook to a rope object
  65816. * @param impostor is the rope impostor to add hook to
  65817. * @param otherImpostor is the rigid impostor to hook to
  65818. * @param length ratio along the rope from 0 to 1
  65819. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little stretch
  65820. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65821. */
  65822. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65823. /**
  65824. * Sleeps the physics body and stops it from being active
  65825. * @param impostor impostor to sleep
  65826. */
  65827. sleepBody(impostor: PhysicsImpostor): void;
  65828. /**
  65829. * Activates the physics body
  65830. * @param impostor impostor to activate
  65831. */
  65832. wakeUpBody(impostor: PhysicsImpostor): void;
  65833. /**
  65834. * Updates the distance parameters of the joint
  65835. * @param joint joint to update
  65836. * @param maxDistance maximum distance of the joint
  65837. * @param minDistance minimum distance of the joint
  65838. */
  65839. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65840. /**
  65841. * Sets a motor on the joint
  65842. * @param joint joint to set motor on
  65843. * @param speed speed of the motor
  65844. * @param maxForce maximum force of the motor
  65845. * @param motorIndex index of the motor
  65846. */
  65847. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65848. /**
  65849. * Sets the motors limit
  65850. * @param joint joint to set limit on
  65851. * @param upperLimit upper limit
  65852. * @param lowerLimit lower limit
  65853. */
  65854. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65855. /**
  65856. * Syncs the position and rotation of a mesh with the impostor
  65857. * @param mesh mesh to sync
  65858. * @param impostor impostor to update the mesh with
  65859. */
  65860. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65861. /**
  65862. * Gets the radius of the impostor
  65863. * @param impostor impostor to get radius from
  65864. * @returns the radius
  65865. */
  65866. getRadius(impostor: PhysicsImpostor): number;
  65867. /**
  65868. * Gets the box size of the impostor
  65869. * @param impostor impostor to get box size from
  65870. * @param result the resulting box size
  65871. */
  65872. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65873. /**
  65874. * Disposes of the impostor
  65875. */
  65876. dispose(): void;
  65877. /**
  65878. * Does a raycast in the physics world
  65879. * @param from when should the ray start?
  65880. * @param to when should the ray end?
  65881. * @returns PhysicsRaycastResult
  65882. */
  65883. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65884. }
  65885. }
  65886. declare module BABYLON {
  65887. interface AbstractScene {
  65888. /**
  65889. * The list of reflection probes added to the scene
  65890. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65891. */
  65892. reflectionProbes: Array<ReflectionProbe>;
  65893. /**
  65894. * Removes the given reflection probe from this scene.
  65895. * @param toRemove The reflection probe to remove
  65896. * @returns The index of the removed reflection probe
  65897. */
  65898. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65899. /**
  65900. * Adds the given reflection probe to this scene.
  65901. * @param newReflectionProbe The reflection probe to add
  65902. */
  65903. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65904. }
  65905. /**
  65906. * Class used to generate realtime reflection / refraction cube textures
  65907. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65908. */
  65909. export class ReflectionProbe {
  65910. /** defines the name of the probe */
  65911. name: string;
  65912. private _scene;
  65913. private _renderTargetTexture;
  65914. private _projectionMatrix;
  65915. private _viewMatrix;
  65916. private _target;
  65917. private _add;
  65918. private _attachedMesh;
  65919. private _invertYAxis;
  65920. /** Gets or sets probe position (center of the cube map) */
  65921. position: Vector3;
  65922. /**
  65923. * Creates a new reflection probe
  65924. * @param name defines the name of the probe
  65925. * @param size defines the texture resolution (for each face)
  65926. * @param scene defines the hosting scene
  65927. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65928. * @param useFloat defines if HDR data (float data) should be used to store colors (false by default)
  65929. */
  65930. constructor(
  65931. /** defines the name of the probe */
  65932. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65933. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65934. get samples(): number;
  65935. set samples(value: number);
  65936. /** Gets or sets the refresh rate to use (on every frame by default) */
  65937. get refreshRate(): number;
  65938. set refreshRate(value: number);
  65939. /**
  65940. * Gets the hosting scene
  65941. * @returns a Scene
  65942. */
  65943. getScene(): Scene;
  65944. /** Gets the internal CubeTexture used to render to */
  65945. get cubeTexture(): RenderTargetTexture;
  65946. /** Gets the list of meshes to render */
  65947. get renderList(): Nullable<AbstractMesh[]>;
  65948. /**
  65949. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65950. * @param mesh defines the mesh to attach to
  65951. */
  65952. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65953. /**
  65954. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65955. * @param renderingGroupId The rendering group id corresponding to its index
  65956. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65957. */
  65958. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65959. /**
  65960. * Clean all associated resources
  65961. */
  65962. dispose(): void;
  65963. /**
  65964. * Converts the reflection probe information to a readable string for debug purpose.
  65965. * @param fullDetails Supports for multiple levels of logging within scene loading
  65966. * @returns the human readable reflection probe info
  65967. */
  65968. toString(fullDetails?: boolean): string;
  65969. /**
  65970. * Get the class name of the refection probe.
  65971. * @returns "ReflectionProbe"
  65972. */
  65973. getClassName(): string;
  65974. /**
  65975. * Serialize the reflection probe to a JSON representation we can easily use in the respective Parse function.
  65976. * @returns The JSON representation of the texture
  65977. */
  65978. serialize(): any;
  65979. /**
  65980. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65981. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65982. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65983. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65984. * @returns The parsed reflection probe if successful
  65985. */
  65986. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65987. }
  65988. }
  65989. declare module BABYLON {
  65990. /** @hidden */
  65991. export var _BabylonLoaderRegistered: boolean;
  65992. /**
  65993. * Helps setting up some configuration for the babylon file loader.
  65994. */
  65995. export class BabylonFileLoaderConfiguration {
  65996. /**
  65997. * The loader does not allow injecting custom physics engine into the plugins.
  65998. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65999. * So you could set this variable to your engine import to make it work.
  66000. */
  66001. static LoaderInjectedPhysicsEngine: any;
  66002. }
  66003. }
  66004. declare module BABYLON {
  66005. /**
  66006. * A material to use for fast depth-only rendering.
  66007. */
  66008. export class OcclusionMaterial extends ShaderMaterial {
  66009. constructor(name: string, scene: Scene);
  66010. }
  66011. }
  66012. declare module BABYLON {
  66013. /**
  66014. * The Physically based simple base material of BJS.
  66015. *
  66016. * This enables better naming and convention enforcements on top of the pbrMaterial.
  66017. * It is used as the base class for both the specGloss and metalRough conventions.
  66018. */
  66019. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  66020. /**
  66021. * Number of Simultaneous lights allowed on the material.
  66022. */
  66023. maxSimultaneousLights: number;
  66024. /**
  66025. * If sets to true, disables all the lights affecting the material.
  66026. */
  66027. disableLighting: boolean;
  66028. /**
  66029. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  66030. */
  66031. environmentTexture: BaseTexture;
  66032. /**
  66033. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  66034. */
  66035. invertNormalMapX: boolean;
  66036. /**
  66037. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  66038. */
  66039. invertNormalMapY: boolean;
  66040. /**
  66041. * Normal map used in the model.
  66042. */
  66043. normalTexture: BaseTexture;
  66044. /**
  66045. * Emissivie color used to self-illuminate the model.
  66046. */
  66047. emissiveColor: Color3;
  66048. /**
  66049. * Emissivie texture used to self-illuminate the model.
  66050. */
  66051. emissiveTexture: BaseTexture;
  66052. /**
  66053. * Occlusion Channel Strength.
  66054. */
  66055. occlusionStrength: number;
  66056. /**
  66057. * Occlusion Texture of the material (adding extra occlusion effects).
  66058. */
  66059. occlusionTexture: BaseTexture;
  66060. /**
  66061. * Defines the alpha limits in alpha test mode.
  66062. */
  66063. alphaCutOff: number;
  66064. /**
  66065. * Gets the current double sided mode.
  66066. */
  66067. get doubleSided(): boolean;
  66068. /**
  66069. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  66070. */
  66071. set doubleSided(value: boolean);
  66072. /**
  66073. * Stores the pre-calculated light information of a mesh in a texture.
  66074. */
  66075. lightmapTexture: BaseTexture;
  66076. /**
  66077. * If true, the light map contains occlusion information instead of lighting info.
  66078. */
  66079. useLightmapAsShadowmap: boolean;
  66080. /**
  66081. * Instantiates a new PBRMaterial instance.
  66082. *
  66083. * @param name The material name
  66084. * @param scene The scene the material will be use in.
  66085. */
  66086. constructor(name: string, scene: Scene);
  66087. getClassName(): string;
  66088. }
  66089. }
  66090. declare module BABYLON {
  66091. /**
  66092. * The PBR material of BJS following the metal roughness convention.
  66093. *
  66094. * This fits to the PBR convention in the GLTF definition:
  66095. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  66096. */
  66097. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  66098. /**
  66099. * The base color has two different interpretations depending on the value of metalness.
  66100. * When the material is a metal, the base color is the specific measured reflectance value
  66101. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  66102. * of the material.
  66103. */
  66104. baseColor: Color3;
  66105. /**
  66106. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  66107. * well as opacity information in the alpha channel.
  66108. */
  66109. baseTexture: BaseTexture;
  66110. /**
  66111. * Specifies the metallic scalar value of the material.
  66112. * Can also be used to scale the metalness values of the metallic texture.
  66113. */
  66114. metallic: number;
  66115. /**
  66116. * Specifies the roughness scalar value of the material.
  66117. * Can also be used to scale the roughness values of the metallic texture.
  66118. */
  66119. roughness: number;
  66120. /**
  66121. * Texture containing both the metallic value in the B channel and the
  66122. * roughness value in the G channel to keep better precision.
  66123. */
  66124. metallicRoughnessTexture: BaseTexture;
  66125. /**
  66126. * Instantiates a new PBRMetalRoughnessMaterial instance.
  66127. *
  66128. * @param name The material name
  66129. * @param scene The scene the material will be use in.
  66130. */
  66131. constructor(name: string, scene: Scene);
  66132. /**
  66133. * Return the current class name of the material.
  66134. */
  66135. getClassName(): string;
  66136. /**
  66137. * Makes a duplicate of the current material.
  66138. * @param name - name to use for the new material.
  66139. */
  66140. clone(name: string): PBRMetallicRoughnessMaterial;
  66141. /**
  66142. * Serialize the material to a parsable JSON object.
  66143. */
  66144. serialize(): any;
  66145. /**
  66146. * Parses a JSON object corresponding to the serialize function.
  66147. */
  66148. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  66149. }
  66150. }
  66151. declare module BABYLON {
  66152. /**
  66153. * The PBR material of BJS following the specular glossiness convention.
  66154. *
  66155. * This fits to the PBR convention in the GLTF definition:
  66156. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  66157. */
  66158. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  66159. /**
  66160. * Specifies the diffuse color of the material.
  66161. */
  66162. diffuseColor: Color3;
  66163. /**
  66164. * Specifies the diffuse texture of the material. This can also contains the opacity value in its alpha
  66165. * channel.
  66166. */
  66167. diffuseTexture: BaseTexture;
  66168. /**
  66169. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  66170. */
  66171. specularColor: Color3;
  66172. /**
  66173. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  66174. */
  66175. glossiness: number;
  66176. /**
  66177. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  66178. */
  66179. specularGlossinessTexture: BaseTexture;
  66180. /**
  66181. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  66182. */
  66183. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  66184. /**
  66185. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  66186. *
  66187. * @param name The material name
  66188. * @param scene The scene the material will be use in.
  66189. */
  66190. constructor(name: string, scene: Scene);
  66191. /**
  66192. * Return the current class name of the material.
  66193. */
  66194. getClassName(): string;
  66195. /**
  66196. * Makes a duplicate of the current material.
  66197. * @param name - name to use for the new material.
  66198. */
  66199. clone(name: string): PBRSpecularGlossinessMaterial;
  66200. /**
  66201. * Serialize the material to a parsable JSON object.
  66202. */
  66203. serialize(): any;
  66204. /**
  66205. * Parses a JSON object corresponding to the serialize function.
  66206. */
  66207. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  66208. }
  66209. }
  66210. declare module BABYLON {
  66211. /**
  66212. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  66213. * It can help converting any input color in a desired output one. This can then be used to create effects
  66214. * from sepia, black and white to sixties or futuristic rendering...
  66215. *
  66216. * The only supported format is currently 3dl.
  66217. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  66218. */
  66219. export class ColorGradingTexture extends BaseTexture {
  66220. /**
  66221. * The texture URL.
  66222. */
  66223. url: string;
  66224. /**
  66225. * Empty line regex stored for GC.
  66226. */
  66227. private static _noneEmptyLineRegex;
  66228. private _textureMatrix;
  66229. private _onLoad;
  66230. /**
  66231. * Instantiates a ColorGradingTexture from the following parameters.
  66232. *
  66233. * @param url The location of the color grading data (currently only supporting 3dl)
  66234. * @param sceneOrEngine The scene or engine the texture will be used in
  66235. * @param onLoad defines a callback triggered when the texture has been loaded
  66236. */
  66237. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  66238. /**
  66239. * Fires the onload event from the constructor if requested.
  66240. */
  66241. private _triggerOnLoad;
  66242. /**
  66243. * Returns the texture matrix used in most of the material.
  66244. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  66245. */
  66246. getTextureMatrix(): Matrix;
  66247. /**
  66248. * Occurs when the file being loaded is a .3dl LUT file.
  66249. */
  66250. private load3dlTexture;
  66251. /**
  66252. * Starts the loading process of the texture.
  66253. */
  66254. private loadTexture;
  66255. /**
  66256. * Clones the color grading texture.
  66257. */
  66258. clone(): ColorGradingTexture;
  66259. /**
  66260. * Called during delayed load for textures.
  66261. */
  66262. delayLoad(): void;
  66263. /**
  66264. * Parses a color grading texture serialized by Babylon.
  66265. * @param parsedTexture The texture information being parsedTexture
  66266. * @param scene The scene to load the texture in
  66267. * @param rootUrl The root url of the data assets to load
  66268. * @return A color grading texture
  66269. */
  66270. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66271. /**
  66272. * Serializes the LUT texture to json format.
  66273. */
  66274. serialize(): any;
  66275. }
  66276. }
  66277. declare module BABYLON {
  66278. /**
  66279. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66280. */
  66281. export class EquiRectangularCubeTexture extends BaseTexture {
  66282. /** The six faces of the cube. */
  66283. private static _FacesMapping;
  66284. private _noMipmap;
  66285. private _onLoad;
  66286. private _onError;
  66287. /** The size of the cubemap. */
  66288. private _size;
  66289. /** The buffer of the image. */
  66290. private _buffer;
  66291. /** The width of the input image. */
  66292. private _width;
  66293. /** The height of the input image. */
  66294. private _height;
  66295. /** The URL to the image. */
  66296. url: string;
  66297. /**
  66298. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66299. * @param url The location of the image
  66300. * @param scene The scene the texture will be used in
  66301. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66302. * @param noMipmap Forces to not generate the mipmap if true
  66303. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66304. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66305. * @param onLoad — defines a callback called when texture is loaded
  66306. * @param onError — defines a callback called if there is an error
  66307. */
  66308. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66309. /**
  66310. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66311. */
  66312. private loadImage;
  66313. /**
  66314. * Convert the image buffer into a cubemap and create a CubeTexture.
  66315. */
  66316. private loadTexture;
  66317. /**
  66318. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66319. * @param buffer The ArrayBuffer that should be converted.
  66320. * @returns The buffer as Float32Array.
  66321. */
  66322. private getFloat32ArrayFromArrayBuffer;
  66323. /**
  66324. * Get the current class name of the texture useful for serialization or dynamic coding.
  66325. * @returns "EquiRectangularCubeTexture"
  66326. */
  66327. getClassName(): string;
  66328. /**
  66329. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66330. * @returns A clone of the current EquiRectangularCubeTexture.
  66331. */
  66332. clone(): EquiRectangularCubeTexture;
  66333. }
  66334. }
  66335. declare module BABYLON {
  66336. /**
  66337. * Defines the options related to the creation of an HtmlElementTexture
  66338. */
  66339. export interface IHtmlElementTextureOptions {
  66340. /**
  66341. * Defines whether mip maps should be created or not.
  66342. */
  66343. generateMipMaps?: boolean;
  66344. /**
  66345. * Defines the sampling mode of the texture.
  66346. */
  66347. samplingMode?: number;
  66348. /**
  66349. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66350. */
  66351. engine: Nullable<ThinEngine>;
  66352. /**
  66353. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66354. */
  66355. scene: Nullable<Scene>;
  66356. }
  66357. /**
  66358. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66359. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66360. * is automatically managed.
  66361. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66362. * in your application.
  66363. *
  66364. * As the update is not automatic, you need to call them manually.
  66365. */
  66366. export class HtmlElementTexture extends BaseTexture {
  66367. /**
  66368. * The texture URL.
  66369. */
  66370. element: HTMLVideoElement | HTMLCanvasElement;
  66371. private static readonly DefaultOptions;
  66372. private _textureMatrix;
  66373. private _isVideo;
  66374. private _generateMipMaps;
  66375. private _samplingMode;
  66376. /**
  66377. * Instantiates a HtmlElementTexture from the following parameters.
  66378. *
  66379. * @param name Defines the name of the texture
  66380. * @param element Defines the video or canvas the texture is filled with
  66381. * @param options Defines the other none mandatory texture creation options
  66382. */
  66383. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66384. private _createInternalTexture;
  66385. /**
  66386. * Returns the texture matrix used in most of the material.
  66387. */
  66388. getTextureMatrix(): Matrix;
  66389. /**
  66390. * Updates the content of the texture.
  66391. * @param invertY Defines whether the texture should be inverted on Y (false by default on video and true on canvas)
  66392. */
  66393. update(invertY?: Nullable<boolean>): void;
  66394. }
  66395. }
  66396. declare module BABYLON {
  66397. /**
  66398. * Based on jsTGALoader - Javascript loader for TGA file
  66399. * By Vincent Thibault
  66400. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66401. */
  66402. export class TGATools {
  66403. private static _TYPE_INDEXED;
  66404. private static _TYPE_RGB;
  66405. private static _TYPE_GREY;
  66406. private static _TYPE_RLE_INDEXED;
  66407. private static _TYPE_RLE_RGB;
  66408. private static _TYPE_RLE_GREY;
  66409. private static _ORIGIN_MASK;
  66410. private static _ORIGIN_SHIFT;
  66411. private static _ORIGIN_BL;
  66412. private static _ORIGIN_BR;
  66413. private static _ORIGIN_UL;
  66414. private static _ORIGIN_UR;
  66415. /**
  66416. * Gets the header of a TGA file
  66417. * @param data defines the TGA data
  66418. * @returns the header
  66419. */
  66420. static GetTGAHeader(data: Uint8Array): any;
  66421. /**
  66422. * Uploads TGA content to a Babylon Texture
  66423. * @hidden
  66424. */
  66425. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66426. /** @hidden */
  66427. 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;
  66428. /** @hidden */
  66429. 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;
  66430. /** @hidden */
  66431. 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;
  66432. /** @hidden */
  66433. 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;
  66434. /** @hidden */
  66435. 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;
  66436. /** @hidden */
  66437. 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;
  66438. }
  66439. }
  66440. declare module BABYLON {
  66441. /**
  66442. * Implementation of the TGA Texture Loader.
  66443. * @hidden
  66444. */
  66445. export class _TGATextureLoader implements IInternalTextureLoader {
  66446. /**
  66447. * Defines whether the loader supports cascade loading the different faces.
  66448. */
  66449. readonly supportCascades: boolean;
  66450. /**
  66451. * This returns if the loader support the current file information.
  66452. * @param extension defines the file extension of the file being loaded
  66453. * @returns true if the loader can load the specified file
  66454. */
  66455. canLoad(extension: string): boolean;
  66456. /**
  66457. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66458. * @param data contains the texture data
  66459. * @param texture defines the BabylonJS internal texture
  66460. * @param createPolynomials will be true if polynomials have been requested
  66461. * @param onLoad defines the callback to trigger once the texture is ready
  66462. * @param onError defines the callback to trigger in case of error
  66463. */
  66464. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66465. /**
  66466. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66467. * @param data contains the texture data
  66468. * @param texture defines the BabylonJS internal texture
  66469. * @param callback defines the method to call once ready to upload
  66470. */
  66471. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66472. }
  66473. }
  66474. declare module BABYLON {
  66475. /**
  66476. * Implementation of the HDR Texture Loader.
  66477. * @hidden
  66478. */
  66479. export class _HDRTextureLoader implements IInternalTextureLoader {
  66480. /**
  66481. * Defines whether the loader supports cascade loading the different faces.
  66482. */
  66483. readonly supportCascades: boolean;
  66484. /**
  66485. * This returns if the loader support the current file information.
  66486. * @param extension defines the file extension of the file being loaded
  66487. * @returns true if the loader can load the specified file
  66488. */
  66489. canLoad(extension: string): boolean;
  66490. /**
  66491. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66492. * @param data contains the texture data
  66493. * @param texture defines the BabylonJS internal texture
  66494. * @param createPolynomials will be true if polynomials have been requested
  66495. * @param onLoad defines the callback to trigger once the texture is ready
  66496. * @param onError defines the callback to trigger in case of error
  66497. */
  66498. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66499. /**
  66500. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66501. * @param data contains the texture data
  66502. * @param texture defines the BabylonJS internal texture
  66503. * @param callback defines the method to call once ready to upload
  66504. */
  66505. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66506. }
  66507. }
  66508. declare module BABYLON {
  66509. /**
  66510. * Info about the .basis files
  66511. */
  66512. class BasisFileInfo {
  66513. /**
  66514. * If the file has alpha
  66515. */
  66516. hasAlpha: boolean;
  66517. /**
  66518. * Info about each image of the basis file
  66519. */
  66520. images: Array<{
  66521. levels: Array<{
  66522. width: number;
  66523. height: number;
  66524. transcodedPixels: ArrayBufferView;
  66525. }>;
  66526. }>;
  66527. }
  66528. /**
  66529. * Result of transcoding a basis file
  66530. */
  66531. class TranscodeResult {
  66532. /**
  66533. * Info about the .basis file
  66534. */
  66535. fileInfo: BasisFileInfo;
  66536. /**
  66537. * Format to use when loading the file
  66538. */
  66539. format: number;
  66540. }
  66541. /**
  66542. * Configuration options for the Basis transcoder
  66543. */
  66544. export class BasisTranscodeConfiguration {
  66545. /**
  66546. * Supported compression formats used to determine the supported output format of the transcoder
  66547. */
  66548. supportedCompressionFormats?: {
  66549. /**
  66550. * etc1 compression format
  66551. */
  66552. etc1?: boolean;
  66553. /**
  66554. * s3tc compression format
  66555. */
  66556. s3tc?: boolean;
  66557. /**
  66558. * pvrtc compression format
  66559. */
  66560. pvrtc?: boolean;
  66561. /**
  66562. * etc2 compression format
  66563. */
  66564. etc2?: boolean;
  66565. };
  66566. /**
  66567. * If mipmap levels should be loaded for transcoded images (Default: true)
  66568. */
  66569. loadMipmapLevels?: boolean;
  66570. /**
  66571. * Index of a single image to load (Default: all images)
  66572. */
  66573. loadSingleImage?: number;
  66574. }
  66575. /**
  66576. * Used to load .Basis files
  66577. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66578. */
  66579. export class BasisTools {
  66580. private static _IgnoreSupportedFormats;
  66581. /**
  66582. * URL to use when loading the basis transcoder
  66583. */
  66584. static JSModuleURL: string;
  66585. /**
  66586. * URL to use when loading the wasm module for the transcoder
  66587. */
  66588. static WasmModuleURL: string;
  66589. /**
  66590. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66591. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66592. * @returns internal format corresponding to the Basis format
  66593. */
  66594. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66595. private static _WorkerPromise;
  66596. private static _Worker;
  66597. private static _actionId;
  66598. private static _CreateWorkerAsync;
  66599. /**
  66600. * Transcodes a loaded image file to compressed pixel data
  66601. * @param data image data to transcode
  66602. * @param config configuration options for the transcoding
  66603. * @returns a promise resulting in the transcoded image
  66604. */
  66605. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66606. /**
  66607. * Loads a texture from the transcode result
  66608. * @param texture texture load to
  66609. * @param transcodeResult the result of transcoding the basis file to load from
  66610. */
  66611. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66612. }
  66613. }
  66614. declare module BABYLON {
  66615. /**
  66616. * Loader for .basis file format
  66617. */
  66618. export class _BasisTextureLoader implements IInternalTextureLoader {
  66619. /**
  66620. * Defines whether the loader supports cascade loading the different faces.
  66621. */
  66622. readonly supportCascades: boolean;
  66623. /**
  66624. * This returns if the loader support the current file information.
  66625. * @param extension defines the file extension of the file being loaded
  66626. * @returns true if the loader can load the specified file
  66627. */
  66628. canLoad(extension: string): boolean;
  66629. /**
  66630. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66631. * @param data contains the texture data
  66632. * @param texture defines the BabylonJS internal texture
  66633. * @param createPolynomials will be true if polynomials have been requested
  66634. * @param onLoad defines the callback to trigger once the texture is ready
  66635. * @param onError defines the callback to trigger in case of error
  66636. */
  66637. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66638. /**
  66639. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66640. * @param data contains the texture data
  66641. * @param texture defines the BabylonJS internal texture
  66642. * @param callback defines the method to call once ready to upload
  66643. */
  66644. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66645. }
  66646. }
  66647. declare module BABYLON {
  66648. /**
  66649. * Defines the basic options interface of a TexturePacker Frame
  66650. */
  66651. export interface ITexturePackerFrame {
  66652. /**
  66653. * The frame ID
  66654. */
  66655. id: number;
  66656. /**
  66657. * The frames Scale
  66658. */
  66659. scale: Vector2;
  66660. /**
  66661. * The Frames offset
  66662. */
  66663. offset: Vector2;
  66664. }
  66665. /**
  66666. * This is a support class for frame Data on texture packer sets.
  66667. */
  66668. export class TexturePackerFrame implements ITexturePackerFrame {
  66669. /**
  66670. * The frame ID
  66671. */
  66672. id: number;
  66673. /**
  66674. * The frames Scale
  66675. */
  66676. scale: Vector2;
  66677. /**
  66678. * The Frames offset
  66679. */
  66680. offset: Vector2;
  66681. /**
  66682. * Initializes a texture package frame.
  66683. * @param id The numerical frame identifier
  66684. * @param scale Scalar Vector2 for UV frame
  66685. * @param offset Vector2 for the frame position in UV units.
  66686. * @returns TexturePackerFrame
  66687. */
  66688. constructor(id: number, scale: Vector2, offset: Vector2);
  66689. }
  66690. }
  66691. declare module BABYLON {
  66692. /**
  66693. * Defines the basic options interface of a TexturePacker
  66694. */
  66695. export interface ITexturePackerOptions {
  66696. /**
  66697. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66698. */
  66699. map?: string[];
  66700. /**
  66701. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66702. */
  66703. uvsIn?: string;
  66704. /**
  66705. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66706. */
  66707. uvsOut?: string;
  66708. /**
  66709. * number representing the layout style. Defaults to LAYOUT_STRIP
  66710. */
  66711. layout?: number;
  66712. /**
  66713. * number of columns if using custom column count layout(2). This defaults to 4.
  66714. */
  66715. colnum?: number;
  66716. /**
  66717. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66718. */
  66719. updateInputMeshes?: boolean;
  66720. /**
  66721. * boolean flag to dispose all the source textures. Defaults to true.
  66722. */
  66723. disposeSources?: boolean;
  66724. /**
  66725. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66726. */
  66727. fillBlanks?: boolean;
  66728. /**
  66729. * string value representing the context fill style color. Defaults to 'black'.
  66730. */
  66731. customFillColor?: string;
  66732. /**
  66733. * Width and Height Value of each Frame in the TexturePacker Sets
  66734. */
  66735. frameSize?: number;
  66736. /**
  66737. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66738. */
  66739. paddingRatio?: number;
  66740. /**
  66741. * Number that declares the fill method for the padding gutter.
  66742. */
  66743. paddingMode?: number;
  66744. /**
  66745. * If in SUBUV_COLOR padding mode what color to use.
  66746. */
  66747. paddingColor?: Color3 | Color4;
  66748. }
  66749. /**
  66750. * Defines the basic interface of a TexturePacker JSON File
  66751. */
  66752. export interface ITexturePackerJSON {
  66753. /**
  66754. * The frame ID
  66755. */
  66756. name: string;
  66757. /**
  66758. * The base64 channel data
  66759. */
  66760. sets: any;
  66761. /**
  66762. * The options of the Packer
  66763. */
  66764. options: ITexturePackerOptions;
  66765. /**
  66766. * The frame data of the Packer
  66767. */
  66768. frames: Array<number>;
  66769. }
  66770. /**
  66771. * This is a support class that generates a series of packed texture sets.
  66772. * @see https://doc.babylonjs.com/babylon101/materials
  66773. */
  66774. export class TexturePacker {
  66775. /** Packer Layout Constant 0 */
  66776. static readonly LAYOUT_STRIP: number;
  66777. /** Packer Layout Constant 1 */
  66778. static readonly LAYOUT_POWER2: number;
  66779. /** Packer Layout Constant 2 */
  66780. static readonly LAYOUT_COLNUM: number;
  66781. /** Packer Layout Constant 0 */
  66782. static readonly SUBUV_WRAP: number;
  66783. /** Packer Layout Constant 1 */
  66784. static readonly SUBUV_EXTEND: number;
  66785. /** Packer Layout Constant 2 */
  66786. static readonly SUBUV_COLOR: number;
  66787. /** The Name of the Texture Package */
  66788. name: string;
  66789. /** The scene scope of the TexturePacker */
  66790. scene: Scene;
  66791. /** The Meshes to target */
  66792. meshes: AbstractMesh[];
  66793. /** Arguments passed with the Constructor */
  66794. options: ITexturePackerOptions;
  66795. /** The promise that is started upon initialization */
  66796. promise: Nullable<Promise<TexturePacker | string>>;
  66797. /** The Container object for the channel sets that are generated */
  66798. sets: object;
  66799. /** The Container array for the frames that are generated */
  66800. frames: TexturePackerFrame[];
  66801. /** The expected number of textures the system is parsing. */
  66802. private _expecting;
  66803. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66804. private _paddingValue;
  66805. /**
  66806. * Initializes a texture package series from an array of meshes or a single mesh.
  66807. * @param name The name of the package
  66808. * @param meshes The target meshes to compose the package from
  66809. * @param options The arguments that texture packer should follow while building.
  66810. * @param scene The scene which the textures are scoped to.
  66811. * @returns TexturePacker
  66812. */
  66813. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66814. /**
  66815. * Starts the package process
  66816. * @param resolve The promises resolution function
  66817. * @returns TexturePacker
  66818. */
  66819. private _createFrames;
  66820. /**
  66821. * Calculates the Size of the Channel Sets
  66822. * @returns Vector2
  66823. */
  66824. private _calculateSize;
  66825. /**
  66826. * Calculates the UV data for the frames.
  66827. * @param baseSize the base frameSize
  66828. * @param padding the base frame padding
  66829. * @param dtSize size of the Dynamic Texture for that channel
  66830. * @param dtUnits is 1/dtSize
  66831. * @param update flag to update the input meshes
  66832. */
  66833. private _calculateMeshUVFrames;
  66834. /**
  66835. * Calculates the frames Offset.
  66836. * @param index of the frame
  66837. * @returns Vector2
  66838. */
  66839. private _getFrameOffset;
  66840. /**
  66841. * Updates a Mesh to the frame data
  66842. * @param mesh that is the target
  66843. * @param frameID or the frame index
  66844. */
  66845. private _updateMeshUV;
  66846. /**
  66847. * Updates a Meshes materials to use the texture packer channels
  66848. * @param m is the mesh to target
  66849. * @param force all channels on the packer to be set.
  66850. */
  66851. private _updateTextureReferences;
  66852. /**
  66853. * Public method to set a Mesh to a frame
  66854. * @param m that is the target
  66855. * @param frameID or the frame index
  66856. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66857. */
  66858. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66859. /**
  66860. * Starts the async promise to compile the texture packer.
  66861. * @returns Promise<void>
  66862. */
  66863. processAsync(): Promise<void>;
  66864. /**
  66865. * Disposes all textures associated with this packer
  66866. */
  66867. dispose(): void;
  66868. /**
  66869. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66870. * @param imageType is the image type to use.
  66871. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66872. */
  66873. download(imageType?: string, quality?: number): void;
  66874. /**
  66875. * Public method to load a texturePacker JSON file.
  66876. * @param data of the JSON file in string format.
  66877. */
  66878. updateFromJSON(data: string): void;
  66879. }
  66880. }
  66881. declare module BABYLON {
  66882. /**
  66883. * 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.
  66884. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66885. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66886. */
  66887. export class CustomProceduralTexture extends ProceduralTexture {
  66888. private _animate;
  66889. private _time;
  66890. private _config;
  66891. private _texturePath;
  66892. /**
  66893. * Instantiates a new Custom Procedural Texture.
  66894. * 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.
  66895. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66896. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66897. * @param name Define the name of the texture
  66898. * @param texturePath Define the folder path containing all the custom texture related files (config, shaders...)
  66899. * @param size Define the size of the texture to create
  66900. * @param scene Define the scene the texture belongs to
  66901. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66902. * @param generateMipMaps Define if the texture should creates mip maps or not
  66903. */
  66904. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66905. private _loadJson;
  66906. /**
  66907. * Is the texture ready to be used ? (rendered at least once)
  66908. * @returns true if ready, otherwise, false.
  66909. */
  66910. isReady(): boolean;
  66911. /**
  66912. * Render the texture to its associated render target.
  66913. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66914. */
  66915. render(useCameraPostProcess?: boolean): void;
  66916. /**
  66917. * Update the list of dependant textures samplers in the shader.
  66918. */
  66919. updateTextures(): void;
  66920. /**
  66921. * Update the uniform values of the procedural texture in the shader.
  66922. */
  66923. updateShaderUniforms(): void;
  66924. /**
  66925. * Define if the texture animates or not.
  66926. */
  66927. get animate(): boolean;
  66928. set animate(value: boolean);
  66929. }
  66930. }
  66931. declare module BABYLON {
  66932. /** @hidden */
  66933. export var noisePixelShader: {
  66934. name: string;
  66935. shader: string;
  66936. };
  66937. }
  66938. declare module BABYLON {
  66939. /**
  66940. * Class used to generate noise procedural textures
  66941. */
  66942. export class NoiseProceduralTexture extends ProceduralTexture {
  66943. /** Gets or sets the start time (default is 0) */
  66944. time: number;
  66945. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66946. brightness: number;
  66947. /** Defines the number of octaves to process */
  66948. octaves: number;
  66949. /** Defines the level of persistence (0.8 by default) */
  66950. persistence: number;
  66951. /** Gets or sets animation speed factor (default is 1) */
  66952. animationSpeedFactor: number;
  66953. /**
  66954. * Creates a new NoiseProceduralTexture
  66955. * @param name defines the name fo the texture
  66956. * @param size defines the size of the texture (default is 256)
  66957. * @param scene defines the hosting scene
  66958. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66959. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66960. */
  66961. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66962. private _updateShaderUniforms;
  66963. protected _getDefines(): string;
  66964. /** Generate the current state of the procedural texture */
  66965. render(useCameraPostProcess?: boolean): void;
  66966. /**
  66967. * Serializes this noise procedural texture
  66968. * @returns a serialized noise procedural texture object
  66969. */
  66970. serialize(): any;
  66971. /**
  66972. * Clone the texture.
  66973. * @returns the cloned texture
  66974. */
  66975. clone(): NoiseProceduralTexture;
  66976. /**
  66977. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66978. * @param parsedTexture defines parsed texture data
  66979. * @param scene defines the current scene
  66980. * @param rootUrl defines the root URL containing noise procedural texture information
  66981. * @returns a parsed NoiseProceduralTexture
  66982. */
  66983. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66984. }
  66985. }
  66986. declare module BABYLON {
  66987. /**
  66988. * Raw cube texture where the raw buffers are passed in
  66989. */
  66990. export class RawCubeTexture extends CubeTexture {
  66991. /**
  66992. * Creates a cube texture where the raw buffers are passed in.
  66993. * @param scene defines the scene the texture is attached to
  66994. * @param data defines the array of data to use to create each face
  66995. * @param size defines the size of the textures
  66996. * @param format defines the format of the data
  66997. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66998. * @param generateMipMaps defines if the engine should generate the mip levels
  66999. * @param invertY defines if data must be stored with Y axis inverted
  67000. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  67001. * @param compression defines the compression used (null by default)
  67002. */
  67003. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  67004. /**
  67005. * Updates the raw cube texture.
  67006. * @param data defines the data to store
  67007. * @param format defines the data format
  67008. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67009. * @param invertY defines if data must be stored with Y axis inverted
  67010. * @param compression defines the compression used (null by default)
  67011. * @param level defines which level of the texture to update
  67012. */
  67013. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  67014. /**
  67015. * Updates a raw cube texture with RGBD encoded data.
  67016. * @param data defines the array of data [mipmap][face] to use to create each face
  67017. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  67018. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67019. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67020. * @returns a promise that resolves when the operation is complete
  67021. */
  67022. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  67023. /**
  67024. * Clones the raw cube texture.
  67025. * @return a new cube texture
  67026. */
  67027. clone(): CubeTexture;
  67028. /** @hidden */
  67029. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  67030. }
  67031. }
  67032. declare module BABYLON {
  67033. /**
  67034. * Class used to store 2D array textures containing user data
  67035. */
  67036. export class RawTexture2DArray extends Texture {
  67037. /** Gets or sets the texture format to use */
  67038. format: number;
  67039. /**
  67040. * Create a new RawTexture2DArray
  67041. * @param data defines the data of the texture
  67042. * @param width defines the width of the texture
  67043. * @param height defines the height of the texture
  67044. * @param depth defines the number of layers of the texture
  67045. * @param format defines the texture format to use
  67046. * @param scene defines the hosting scene
  67047. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  67048. * @param invertY defines if texture must be stored with Y axis inverted
  67049. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67050. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  67051. */
  67052. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  67053. /** Gets or sets the texture format to use */
  67054. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  67055. /**
  67056. * Update the texture with new data
  67057. * @param data defines the data to store in the texture
  67058. */
  67059. update(data: ArrayBufferView): void;
  67060. }
  67061. }
  67062. declare module BABYLON {
  67063. /**
  67064. * Class used to store 3D textures containing user data
  67065. */
  67066. export class RawTexture3D extends Texture {
  67067. /** Gets or sets the texture format to use */
  67068. format: number;
  67069. /**
  67070. * Create a new RawTexture3D
  67071. * @param data defines the data of the texture
  67072. * @param width defines the width of the texture
  67073. * @param height defines the height of the texture
  67074. * @param depth defines the depth of the texture
  67075. * @param format defines the texture format to use
  67076. * @param scene defines the hosting scene
  67077. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  67078. * @param invertY defines if texture must be stored with Y axis inverted
  67079. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67080. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  67081. */
  67082. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  67083. /** Gets or sets the texture format to use */
  67084. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  67085. /**
  67086. * Update the texture with new data
  67087. * @param data defines the data to store in the texture
  67088. */
  67089. update(data: ArrayBufferView): void;
  67090. }
  67091. }
  67092. declare module BABYLON {
  67093. /**
  67094. * Creates a refraction texture used by refraction channel of the standard material.
  67095. * It is like a mirror but to see through a material.
  67096. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67097. */
  67098. export class RefractionTexture extends RenderTargetTexture {
  67099. /**
  67100. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  67101. * It is possible to directly set the refractionPlane by directly using a 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.
  67102. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67103. */
  67104. refractionPlane: Plane;
  67105. /**
  67106. * Define how deep under the surface we should see.
  67107. */
  67108. depth: number;
  67109. /**
  67110. * Creates a refraction texture used by refraction channel of the standard material.
  67111. * It is like a mirror but to see through a material.
  67112. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67113. * @param name Define the texture name
  67114. * @param size Define the size of the underlying texture
  67115. * @param scene Define the scene the refraction belongs to
  67116. * @param generateMipMaps Define if we need to generate mips level for the refraction
  67117. */
  67118. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  67119. /**
  67120. * Clone the refraction texture.
  67121. * @returns the cloned texture
  67122. */
  67123. clone(): RefractionTexture;
  67124. /**
  67125. * Serialize the texture to a JSON representation you could use in Parse later on
  67126. * @returns the serialized JSON representation
  67127. */
  67128. serialize(): any;
  67129. }
  67130. }
  67131. declare module BABYLON {
  67132. /**
  67133. * Block used to add support for vertex skinning (bones)
  67134. */
  67135. export class BonesBlock extends NodeMaterialBlock {
  67136. /**
  67137. * Creates a new BonesBlock
  67138. * @param name defines the block name
  67139. */
  67140. constructor(name: string);
  67141. /**
  67142. * Initialize the block and prepare the context for build
  67143. * @param state defines the state that will be used for the build
  67144. */
  67145. initialize(state: NodeMaterialBuildState): void;
  67146. /**
  67147. * Gets the current class name
  67148. * @returns the class name
  67149. */
  67150. getClassName(): string;
  67151. /**
  67152. * Gets the matrix indices input component
  67153. */
  67154. get matricesIndices(): NodeMaterialConnectionPoint;
  67155. /**
  67156. * Gets the matrix weights input component
  67157. */
  67158. get matricesWeights(): NodeMaterialConnectionPoint;
  67159. /**
  67160. * Gets the extra matrix indices input component
  67161. */
  67162. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  67163. /**
  67164. * Gets the extra matrix weights input component
  67165. */
  67166. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  67167. /**
  67168. * Gets the world input component
  67169. */
  67170. get world(): NodeMaterialConnectionPoint;
  67171. /**
  67172. * Gets the output component
  67173. */
  67174. get output(): NodeMaterialConnectionPoint;
  67175. autoConfigure(material: NodeMaterial): void;
  67176. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  67177. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67179. protected _buildBlock(state: NodeMaterialBuildState): this;
  67180. }
  67181. }
  67182. declare module BABYLON {
  67183. /**
  67184. * Block used to add support for instances
  67185. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  67186. */
  67187. export class InstancesBlock extends NodeMaterialBlock {
  67188. /**
  67189. * Creates a new InstancesBlock
  67190. * @param name defines the block name
  67191. */
  67192. constructor(name: string);
  67193. /**
  67194. * Gets the current class name
  67195. * @returns the class name
  67196. */
  67197. getClassName(): string;
  67198. /**
  67199. * Gets the first world row input component
  67200. */
  67201. get world0(): NodeMaterialConnectionPoint;
  67202. /**
  67203. * Gets the second world row input component
  67204. */
  67205. get world1(): NodeMaterialConnectionPoint;
  67206. /**
  67207. * Gets the third world row input component
  67208. */
  67209. get world2(): NodeMaterialConnectionPoint;
  67210. /**
  67211. * Gets the forth world row input component
  67212. */
  67213. get world3(): NodeMaterialConnectionPoint;
  67214. /**
  67215. * Gets the world input component
  67216. */
  67217. get world(): NodeMaterialConnectionPoint;
  67218. /**
  67219. * Gets the output component
  67220. */
  67221. get output(): NodeMaterialConnectionPoint;
  67222. /**
  67223. * Gets the instanceID component
  67224. */
  67225. get instanceID(): NodeMaterialConnectionPoint;
  67226. autoConfigure(material: NodeMaterial): void;
  67227. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67228. protected _buildBlock(state: NodeMaterialBuildState): this;
  67229. }
  67230. }
  67231. declare module BABYLON {
  67232. /**
  67233. * Block used to add morph targets support to vertex shader
  67234. */
  67235. export class MorphTargetsBlock extends NodeMaterialBlock {
  67236. private _repeatableContentAnchor;
  67237. /**
  67238. * Create a new MorphTargetsBlock
  67239. * @param name defines the block name
  67240. */
  67241. constructor(name: string);
  67242. /**
  67243. * Gets the current class name
  67244. * @returns the class name
  67245. */
  67246. getClassName(): string;
  67247. /**
  67248. * Gets the position input component
  67249. */
  67250. get position(): NodeMaterialConnectionPoint;
  67251. /**
  67252. * Gets the normal input component
  67253. */
  67254. get normal(): NodeMaterialConnectionPoint;
  67255. /**
  67256. * Gets the tangent input component
  67257. */
  67258. get tangent(): NodeMaterialConnectionPoint;
  67259. /**
  67260. * Gets the tangent input component
  67261. */
  67262. get uv(): NodeMaterialConnectionPoint;
  67263. /**
  67264. * Gets the position output component
  67265. */
  67266. get positionOutput(): NodeMaterialConnectionPoint;
  67267. /**
  67268. * Gets the normal output component
  67269. */
  67270. get normalOutput(): NodeMaterialConnectionPoint;
  67271. /**
  67272. * Gets the tangent output component
  67273. */
  67274. get tangentOutput(): NodeMaterialConnectionPoint;
  67275. /**
  67276. * Gets the tangent output component
  67277. */
  67278. get uvOutput(): NodeMaterialConnectionPoint;
  67279. initialize(state: NodeMaterialBuildState): void;
  67280. autoConfigure(material: NodeMaterial): void;
  67281. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67283. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67284. protected _buildBlock(state: NodeMaterialBuildState): this;
  67285. }
  67286. }
  67287. declare module BABYLON {
  67288. /**
  67289. * Block used to get data information from a light
  67290. */
  67291. export class LightInformationBlock extends NodeMaterialBlock {
  67292. private _lightDataUniformName;
  67293. private _lightColorUniformName;
  67294. private _lightTypeDefineName;
  67295. /**
  67296. * Gets or sets the light associated with this block
  67297. */
  67298. light: Nullable<Light>;
  67299. /**
  67300. * Creates a new LightInformationBlock
  67301. * @param name defines the block name
  67302. */
  67303. constructor(name: string);
  67304. /**
  67305. * Gets the current class name
  67306. * @returns the class name
  67307. */
  67308. getClassName(): string;
  67309. /**
  67310. * Gets the world position input component
  67311. */
  67312. get worldPosition(): NodeMaterialConnectionPoint;
  67313. /**
  67314. * Gets the direction output component
  67315. */
  67316. get direction(): NodeMaterialConnectionPoint;
  67317. /**
  67318. * Gets the direction output component
  67319. */
  67320. get color(): NodeMaterialConnectionPoint;
  67321. /**
  67322. * Gets the direction output component
  67323. */
  67324. get intensity(): NodeMaterialConnectionPoint;
  67325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67326. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67327. protected _buildBlock(state: NodeMaterialBuildState): this;
  67328. serialize(): any;
  67329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67330. }
  67331. }
  67332. declare module BABYLON {
  67333. /**
  67334. * Block used to add image processing support to fragment shader
  67335. */
  67336. export class ImageProcessingBlock extends NodeMaterialBlock {
  67337. /**
  67338. * Create a new ImageProcessingBlock
  67339. * @param name defines the block name
  67340. */
  67341. constructor(name: string);
  67342. /**
  67343. * Gets the current class name
  67344. * @returns the class name
  67345. */
  67346. getClassName(): string;
  67347. /**
  67348. * Gets the color input component
  67349. */
  67350. get color(): NodeMaterialConnectionPoint;
  67351. /**
  67352. * Gets the output component
  67353. */
  67354. get output(): NodeMaterialConnectionPoint;
  67355. /**
  67356. * Initialize the block and prepare the context for build
  67357. * @param state defines the state that will be used for the build
  67358. */
  67359. initialize(state: NodeMaterialBuildState): void;
  67360. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67361. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67362. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67363. protected _buildBlock(state: NodeMaterialBuildState): this;
  67364. }
  67365. }
  67366. declare module BABYLON {
  67367. /**
  67368. * Block used to perturb normals based on a normal map
  67369. */
  67370. export class PerturbNormalBlock extends NodeMaterialBlock {
  67371. private _tangentSpaceParameterName;
  67372. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67373. invertX: boolean;
  67374. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67375. invertY: boolean;
  67376. /**
  67377. * Create a new PerturbNormalBlock
  67378. * @param name defines the block name
  67379. */
  67380. constructor(name: string);
  67381. /**
  67382. * Gets the current class name
  67383. * @returns the class name
  67384. */
  67385. getClassName(): string;
  67386. /**
  67387. * Gets the world position input component
  67388. */
  67389. get worldPosition(): NodeMaterialConnectionPoint;
  67390. /**
  67391. * Gets the world normal input component
  67392. */
  67393. get worldNormal(): NodeMaterialConnectionPoint;
  67394. /**
  67395. * Gets the world tangent input component
  67396. */
  67397. get worldTangent(): NodeMaterialConnectionPoint;
  67398. /**
  67399. * Gets the uv input component
  67400. */
  67401. get uv(): NodeMaterialConnectionPoint;
  67402. /**
  67403. * Gets the normal map color input component
  67404. */
  67405. get normalMapColor(): NodeMaterialConnectionPoint;
  67406. /**
  67407. * Gets the strength input component
  67408. */
  67409. get strength(): NodeMaterialConnectionPoint;
  67410. /**
  67411. * Gets the output component
  67412. */
  67413. get output(): NodeMaterialConnectionPoint;
  67414. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67415. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67416. autoConfigure(material: NodeMaterial): void;
  67417. protected _buildBlock(state: NodeMaterialBuildState): this;
  67418. protected _dumpPropertiesCode(): string;
  67419. serialize(): any;
  67420. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67421. }
  67422. }
  67423. declare module BABYLON {
  67424. /**
  67425. * Block used to discard a pixel if a value is smaller than a cutoff
  67426. */
  67427. export class DiscardBlock extends NodeMaterialBlock {
  67428. /**
  67429. * Create a new DiscardBlock
  67430. * @param name defines the block name
  67431. */
  67432. constructor(name: string);
  67433. /**
  67434. * Gets the current class name
  67435. * @returns the class name
  67436. */
  67437. getClassName(): string;
  67438. /**
  67439. * Gets the color input component
  67440. */
  67441. get value(): NodeMaterialConnectionPoint;
  67442. /**
  67443. * Gets the cutoff input component
  67444. */
  67445. get cutoff(): NodeMaterialConnectionPoint;
  67446. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67447. }
  67448. }
  67449. declare module BABYLON {
  67450. /**
  67451. * Block used to test if the fragment shader is front facing
  67452. */
  67453. export class FrontFacingBlock extends NodeMaterialBlock {
  67454. /**
  67455. * Creates a new FrontFacingBlock
  67456. * @param name defines the block name
  67457. */
  67458. constructor(name: string);
  67459. /**
  67460. * Gets the current class name
  67461. * @returns the class name
  67462. */
  67463. getClassName(): string;
  67464. /**
  67465. * Gets the output component
  67466. */
  67467. get output(): NodeMaterialConnectionPoint;
  67468. protected _buildBlock(state: NodeMaterialBuildState): this;
  67469. }
  67470. }
  67471. declare module BABYLON {
  67472. /**
  67473. * Block used to get the derivative value on x and y of a given input
  67474. */
  67475. export class DerivativeBlock extends NodeMaterialBlock {
  67476. /**
  67477. * Create a new DerivativeBlock
  67478. * @param name defines the block name
  67479. */
  67480. constructor(name: string);
  67481. /**
  67482. * Gets the current class name
  67483. * @returns the class name
  67484. */
  67485. getClassName(): string;
  67486. /**
  67487. * Gets the input component
  67488. */
  67489. get input(): NodeMaterialConnectionPoint;
  67490. /**
  67491. * Gets the derivative output on x
  67492. */
  67493. get dx(): NodeMaterialConnectionPoint;
  67494. /**
  67495. * Gets the derivative output on y
  67496. */
  67497. get dy(): NodeMaterialConnectionPoint;
  67498. protected _buildBlock(state: NodeMaterialBuildState): this;
  67499. }
  67500. }
  67501. declare module BABYLON {
  67502. /**
  67503. * Block used to make gl_FragCoord available
  67504. */
  67505. export class FragCoordBlock extends NodeMaterialBlock {
  67506. /**
  67507. * Creates a new FragCoordBlock
  67508. * @param name defines the block name
  67509. */
  67510. constructor(name: string);
  67511. /**
  67512. * Gets the current class name
  67513. * @returns the class name
  67514. */
  67515. getClassName(): string;
  67516. /**
  67517. * Gets the xy component
  67518. */
  67519. get xy(): NodeMaterialConnectionPoint;
  67520. /**
  67521. * Gets the xyz component
  67522. */
  67523. get xyz(): NodeMaterialConnectionPoint;
  67524. /**
  67525. * Gets the xyzw component
  67526. */
  67527. get xyzw(): NodeMaterialConnectionPoint;
  67528. /**
  67529. * Gets the x component
  67530. */
  67531. get x(): NodeMaterialConnectionPoint;
  67532. /**
  67533. * Gets the y component
  67534. */
  67535. get y(): NodeMaterialConnectionPoint;
  67536. /**
  67537. * Gets the z component
  67538. */
  67539. get z(): NodeMaterialConnectionPoint;
  67540. /**
  67541. * Gets the w component
  67542. */
  67543. get output(): NodeMaterialConnectionPoint;
  67544. protected writeOutputs(state: NodeMaterialBuildState): string;
  67545. protected _buildBlock(state: NodeMaterialBuildState): this;
  67546. }
  67547. }
  67548. declare module BABYLON {
  67549. /**
  67550. * Block used to get the screen sizes
  67551. */
  67552. export class ScreenSizeBlock extends NodeMaterialBlock {
  67553. private _varName;
  67554. private _scene;
  67555. /**
  67556. * Creates a new ScreenSizeBlock
  67557. * @param name defines the block name
  67558. */
  67559. constructor(name: string);
  67560. /**
  67561. * Gets the current class name
  67562. * @returns the class name
  67563. */
  67564. getClassName(): string;
  67565. /**
  67566. * Gets the xy component
  67567. */
  67568. get xy(): NodeMaterialConnectionPoint;
  67569. /**
  67570. * Gets the x component
  67571. */
  67572. get x(): NodeMaterialConnectionPoint;
  67573. /**
  67574. * Gets the y component
  67575. */
  67576. get y(): NodeMaterialConnectionPoint;
  67577. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67578. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67579. protected _buildBlock(state: NodeMaterialBuildState): this;
  67580. }
  67581. }
  67582. declare module BABYLON {
  67583. /**
  67584. * Block used to add support for scene fog
  67585. */
  67586. export class FogBlock extends NodeMaterialBlock {
  67587. private _fogDistanceName;
  67588. private _fogParameters;
  67589. /**
  67590. * Create a new FogBlock
  67591. * @param name defines the block name
  67592. */
  67593. constructor(name: string);
  67594. /**
  67595. * Gets the current class name
  67596. * @returns the class name
  67597. */
  67598. getClassName(): string;
  67599. /**
  67600. * Gets the world position input component
  67601. */
  67602. get worldPosition(): NodeMaterialConnectionPoint;
  67603. /**
  67604. * Gets the view input component
  67605. */
  67606. get view(): NodeMaterialConnectionPoint;
  67607. /**
  67608. * Gets the color input component
  67609. */
  67610. get input(): NodeMaterialConnectionPoint;
  67611. /**
  67612. * Gets the fog color input component
  67613. */
  67614. get fogColor(): NodeMaterialConnectionPoint;
  67615. /**
  67616. * Gets the output component
  67617. */
  67618. get output(): NodeMaterialConnectionPoint;
  67619. autoConfigure(material: NodeMaterial): void;
  67620. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67621. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67622. protected _buildBlock(state: NodeMaterialBuildState): this;
  67623. }
  67624. }
  67625. declare module BABYLON {
  67626. /**
  67627. * Block used to add light in the fragment shader
  67628. */
  67629. export class LightBlock extends NodeMaterialBlock {
  67630. private _lightId;
  67631. /**
  67632. * Gets or sets the light associated with this block
  67633. */
  67634. light: Nullable<Light>;
  67635. /**
  67636. * Create a new LightBlock
  67637. * @param name defines the block name
  67638. */
  67639. constructor(name: string);
  67640. /**
  67641. * Gets the current class name
  67642. * @returns the class name
  67643. */
  67644. getClassName(): string;
  67645. /**
  67646. * Gets the world position input component
  67647. */
  67648. get worldPosition(): NodeMaterialConnectionPoint;
  67649. /**
  67650. * Gets the world normal input component
  67651. */
  67652. get worldNormal(): NodeMaterialConnectionPoint;
  67653. /**
  67654. * Gets the camera (or eye) position component
  67655. */
  67656. get cameraPosition(): NodeMaterialConnectionPoint;
  67657. /**
  67658. * Gets the glossiness component
  67659. */
  67660. get glossiness(): NodeMaterialConnectionPoint;
  67661. /**
  67662. * Gets the glossiness power component
  67663. */
  67664. get glossPower(): NodeMaterialConnectionPoint;
  67665. /**
  67666. * Gets the diffuse color component
  67667. */
  67668. get diffuseColor(): NodeMaterialConnectionPoint;
  67669. /**
  67670. * Gets the specular color component
  67671. */
  67672. get specularColor(): NodeMaterialConnectionPoint;
  67673. /**
  67674. * Gets the view matrix component
  67675. */
  67676. get view(): NodeMaterialConnectionPoint;
  67677. /**
  67678. * Gets the diffuse output component
  67679. */
  67680. get diffuseOutput(): NodeMaterialConnectionPoint;
  67681. /**
  67682. * Gets the specular output component
  67683. */
  67684. get specularOutput(): NodeMaterialConnectionPoint;
  67685. /**
  67686. * Gets the shadow output component
  67687. */
  67688. get shadow(): NodeMaterialConnectionPoint;
  67689. autoConfigure(material: NodeMaterial): void;
  67690. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67691. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67692. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67693. private _injectVertexCode;
  67694. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67695. serialize(): any;
  67696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67697. }
  67698. }
  67699. declare module BABYLON {
  67700. /**
  67701. * Block used to read a reflection texture from a sampler
  67702. */
  67703. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67704. /**
  67705. * Create a new ReflectionTextureBlock
  67706. * @param name defines the block name
  67707. */
  67708. constructor(name: string);
  67709. /**
  67710. * Gets the current class name
  67711. * @returns the class name
  67712. */
  67713. getClassName(): string;
  67714. /**
  67715. * Gets the world position input component
  67716. */
  67717. get position(): NodeMaterialConnectionPoint;
  67718. /**
  67719. * Gets the world position input component
  67720. */
  67721. get worldPosition(): NodeMaterialConnectionPoint;
  67722. /**
  67723. * Gets the world normal input component
  67724. */
  67725. get worldNormal(): NodeMaterialConnectionPoint;
  67726. /**
  67727. * Gets the world input component
  67728. */
  67729. get world(): NodeMaterialConnectionPoint;
  67730. /**
  67731. * Gets the camera (or eye) position component
  67732. */
  67733. get cameraPosition(): NodeMaterialConnectionPoint;
  67734. /**
  67735. * Gets the view input component
  67736. */
  67737. get view(): NodeMaterialConnectionPoint;
  67738. /**
  67739. * Gets the rgb output component
  67740. */
  67741. get rgb(): NodeMaterialConnectionPoint;
  67742. /**
  67743. * Gets the rgba output component
  67744. */
  67745. get rgba(): NodeMaterialConnectionPoint;
  67746. /**
  67747. * Gets the r output component
  67748. */
  67749. get r(): NodeMaterialConnectionPoint;
  67750. /**
  67751. * Gets the g output component
  67752. */
  67753. get g(): NodeMaterialConnectionPoint;
  67754. /**
  67755. * Gets the b output component
  67756. */
  67757. get b(): NodeMaterialConnectionPoint;
  67758. /**
  67759. * Gets the a output component
  67760. */
  67761. get a(): NodeMaterialConnectionPoint;
  67762. autoConfigure(material: NodeMaterial): void;
  67763. protected _buildBlock(state: NodeMaterialBuildState): this;
  67764. }
  67765. }
  67766. declare module BABYLON {
  67767. /**
  67768. * Block used to add 2 vectors
  67769. */
  67770. export class AddBlock extends NodeMaterialBlock {
  67771. /**
  67772. * Creates a new AddBlock
  67773. * @param name defines the block name
  67774. */
  67775. constructor(name: string);
  67776. /**
  67777. * Gets the current class name
  67778. * @returns the class name
  67779. */
  67780. getClassName(): string;
  67781. /**
  67782. * Gets the left operand input component
  67783. */
  67784. get left(): NodeMaterialConnectionPoint;
  67785. /**
  67786. * Gets the right operand input component
  67787. */
  67788. get right(): NodeMaterialConnectionPoint;
  67789. /**
  67790. * Gets the output component
  67791. */
  67792. get output(): NodeMaterialConnectionPoint;
  67793. protected _buildBlock(state: NodeMaterialBuildState): this;
  67794. }
  67795. }
  67796. declare module BABYLON {
  67797. /**
  67798. * Block used to scale a vector by a float
  67799. */
  67800. export class ScaleBlock extends NodeMaterialBlock {
  67801. /**
  67802. * Creates a new ScaleBlock
  67803. * @param name defines the block name
  67804. */
  67805. constructor(name: string);
  67806. /**
  67807. * Gets the current class name
  67808. * @returns the class name
  67809. */
  67810. getClassName(): string;
  67811. /**
  67812. * Gets the input component
  67813. */
  67814. get input(): NodeMaterialConnectionPoint;
  67815. /**
  67816. * Gets the factor input component
  67817. */
  67818. get factor(): NodeMaterialConnectionPoint;
  67819. /**
  67820. * Gets the output component
  67821. */
  67822. get output(): NodeMaterialConnectionPoint;
  67823. protected _buildBlock(state: NodeMaterialBuildState): this;
  67824. }
  67825. }
  67826. declare module BABYLON {
  67827. /**
  67828. * Block used to clamp a float
  67829. */
  67830. export class ClampBlock extends NodeMaterialBlock {
  67831. /** Gets or sets the minimum range */
  67832. minimum: number;
  67833. /** Gets or sets the maximum range */
  67834. maximum: number;
  67835. /**
  67836. * Creates a new ClampBlock
  67837. * @param name defines the block name
  67838. */
  67839. constructor(name: string);
  67840. /**
  67841. * Gets the current class name
  67842. * @returns the class name
  67843. */
  67844. getClassName(): string;
  67845. /**
  67846. * Gets the value input component
  67847. */
  67848. get value(): NodeMaterialConnectionPoint;
  67849. /**
  67850. * Gets the output component
  67851. */
  67852. get output(): NodeMaterialConnectionPoint;
  67853. protected _buildBlock(state: NodeMaterialBuildState): this;
  67854. protected _dumpPropertiesCode(): string;
  67855. serialize(): any;
  67856. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67857. }
  67858. }
  67859. declare module BABYLON {
  67860. /**
  67861. * Block used to apply a cross product between 2 vectors
  67862. */
  67863. export class CrossBlock extends NodeMaterialBlock {
  67864. /**
  67865. * Creates a new CrossBlock
  67866. * @param name defines the block name
  67867. */
  67868. constructor(name: string);
  67869. /**
  67870. * Gets the current class name
  67871. * @returns the class name
  67872. */
  67873. getClassName(): string;
  67874. /**
  67875. * Gets the left operand input component
  67876. */
  67877. get left(): NodeMaterialConnectionPoint;
  67878. /**
  67879. * Gets the right operand input component
  67880. */
  67881. get right(): NodeMaterialConnectionPoint;
  67882. /**
  67883. * Gets the output component
  67884. */
  67885. get output(): NodeMaterialConnectionPoint;
  67886. protected _buildBlock(state: NodeMaterialBuildState): this;
  67887. }
  67888. }
  67889. declare module BABYLON {
  67890. /**
  67891. * Block used to apply a dot product between 2 vectors
  67892. */
  67893. export class DotBlock extends NodeMaterialBlock {
  67894. /**
  67895. * Creates a new DotBlock
  67896. * @param name defines the block name
  67897. */
  67898. constructor(name: string);
  67899. /**
  67900. * Gets the current class name
  67901. * @returns the class name
  67902. */
  67903. getClassName(): string;
  67904. /**
  67905. * Gets the left operand input component
  67906. */
  67907. get left(): NodeMaterialConnectionPoint;
  67908. /**
  67909. * Gets the right operand input component
  67910. */
  67911. get right(): NodeMaterialConnectionPoint;
  67912. /**
  67913. * Gets the output component
  67914. */
  67915. get output(): NodeMaterialConnectionPoint;
  67916. protected _buildBlock(state: NodeMaterialBuildState): this;
  67917. }
  67918. }
  67919. declare module BABYLON {
  67920. /**
  67921. * Block used to normalize a vector
  67922. */
  67923. export class NormalizeBlock extends NodeMaterialBlock {
  67924. /**
  67925. * Creates a new NormalizeBlock
  67926. * @param name defines the block name
  67927. */
  67928. constructor(name: string);
  67929. /**
  67930. * Gets the current class name
  67931. * @returns the class name
  67932. */
  67933. getClassName(): string;
  67934. /**
  67935. * Gets the input component
  67936. */
  67937. get input(): NodeMaterialConnectionPoint;
  67938. /**
  67939. * Gets the output component
  67940. */
  67941. get output(): NodeMaterialConnectionPoint;
  67942. protected _buildBlock(state: NodeMaterialBuildState): this;
  67943. }
  67944. }
  67945. declare module BABYLON {
  67946. /**
  67947. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67948. */
  67949. export class ColorMergerBlock extends NodeMaterialBlock {
  67950. /**
  67951. * Create a new ColorMergerBlock
  67952. * @param name defines the block name
  67953. */
  67954. constructor(name: string);
  67955. /**
  67956. * Gets the current class name
  67957. * @returns the class name
  67958. */
  67959. getClassName(): string;
  67960. /**
  67961. * Gets the rgb component (input)
  67962. */
  67963. get rgbIn(): NodeMaterialConnectionPoint;
  67964. /**
  67965. * Gets the r component (input)
  67966. */
  67967. get r(): NodeMaterialConnectionPoint;
  67968. /**
  67969. * Gets the g component (input)
  67970. */
  67971. get g(): NodeMaterialConnectionPoint;
  67972. /**
  67973. * Gets the b component (input)
  67974. */
  67975. get b(): NodeMaterialConnectionPoint;
  67976. /**
  67977. * Gets the a component (input)
  67978. */
  67979. get a(): NodeMaterialConnectionPoint;
  67980. /**
  67981. * Gets the rgba component (output)
  67982. */
  67983. get rgba(): NodeMaterialConnectionPoint;
  67984. /**
  67985. * Gets the rgb component (output)
  67986. */
  67987. get rgbOut(): NodeMaterialConnectionPoint;
  67988. /**
  67989. * Gets the rgb component (output)
  67990. * @deprecated Please use rgbOut instead.
  67991. */
  67992. get rgb(): NodeMaterialConnectionPoint;
  67993. protected _buildBlock(state: NodeMaterialBuildState): this;
  67994. }
  67995. }
  67996. declare module BABYLON {
  67997. /**
  67998. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67999. */
  68000. export class VectorSplitterBlock extends NodeMaterialBlock {
  68001. /**
  68002. * Create a new VectorSplitterBlock
  68003. * @param name defines the block name
  68004. */
  68005. constructor(name: string);
  68006. /**
  68007. * Gets the current class name
  68008. * @returns the class name
  68009. */
  68010. getClassName(): string;
  68011. /**
  68012. * Gets the xyzw component (input)
  68013. */
  68014. get xyzw(): NodeMaterialConnectionPoint;
  68015. /**
  68016. * Gets the xyz component (input)
  68017. */
  68018. get xyzIn(): NodeMaterialConnectionPoint;
  68019. /**
  68020. * Gets the xy component (input)
  68021. */
  68022. get xyIn(): NodeMaterialConnectionPoint;
  68023. /**
  68024. * Gets the xyz component (output)
  68025. */
  68026. get xyzOut(): NodeMaterialConnectionPoint;
  68027. /**
  68028. * Gets the xy component (output)
  68029. */
  68030. get xyOut(): NodeMaterialConnectionPoint;
  68031. /**
  68032. * Gets the x component (output)
  68033. */
  68034. get x(): NodeMaterialConnectionPoint;
  68035. /**
  68036. * Gets the y component (output)
  68037. */
  68038. get y(): NodeMaterialConnectionPoint;
  68039. /**
  68040. * Gets the z component (output)
  68041. */
  68042. get z(): NodeMaterialConnectionPoint;
  68043. /**
  68044. * Gets the w component (output)
  68045. */
  68046. get w(): NodeMaterialConnectionPoint;
  68047. protected _inputRename(name: string): string;
  68048. protected _outputRename(name: string): string;
  68049. protected _buildBlock(state: NodeMaterialBuildState): this;
  68050. }
  68051. }
  68052. declare module BABYLON {
  68053. /**
  68054. * Block used to lerp between 2 values
  68055. */
  68056. export class LerpBlock extends NodeMaterialBlock {
  68057. /**
  68058. * Creates a new LerpBlock
  68059. * @param name defines the block name
  68060. */
  68061. constructor(name: string);
  68062. /**
  68063. * Gets the current class name
  68064. * @returns the class name
  68065. */
  68066. getClassName(): string;
  68067. /**
  68068. * Gets the left operand input component
  68069. */
  68070. get left(): NodeMaterialConnectionPoint;
  68071. /**
  68072. * Gets the right operand input component
  68073. */
  68074. get right(): NodeMaterialConnectionPoint;
  68075. /**
  68076. * Gets the gradient operand input component
  68077. */
  68078. get gradient(): NodeMaterialConnectionPoint;
  68079. /**
  68080. * Gets the output component
  68081. */
  68082. get output(): NodeMaterialConnectionPoint;
  68083. protected _buildBlock(state: NodeMaterialBuildState): this;
  68084. }
  68085. }
  68086. declare module BABYLON {
  68087. /**
  68088. * Block used to divide 2 vectors
  68089. */
  68090. export class DivideBlock extends NodeMaterialBlock {
  68091. /**
  68092. * Creates a new DivideBlock
  68093. * @param name defines the block name
  68094. */
  68095. constructor(name: string);
  68096. /**
  68097. * Gets the current class name
  68098. * @returns the class name
  68099. */
  68100. getClassName(): string;
  68101. /**
  68102. * Gets the left operand input component
  68103. */
  68104. get left(): NodeMaterialConnectionPoint;
  68105. /**
  68106. * Gets the right operand input component
  68107. */
  68108. get right(): NodeMaterialConnectionPoint;
  68109. /**
  68110. * Gets the output component
  68111. */
  68112. get output(): NodeMaterialConnectionPoint;
  68113. protected _buildBlock(state: NodeMaterialBuildState): this;
  68114. }
  68115. }
  68116. declare module BABYLON {
  68117. /**
  68118. * Block used to subtract 2 vectors
  68119. */
  68120. export class SubtractBlock extends NodeMaterialBlock {
  68121. /**
  68122. * Creates a new SubtractBlock
  68123. * @param name defines the block name
  68124. */
  68125. constructor(name: string);
  68126. /**
  68127. * Gets the current class name
  68128. * @returns the class name
  68129. */
  68130. getClassName(): string;
  68131. /**
  68132. * Gets the left operand input component
  68133. */
  68134. get left(): NodeMaterialConnectionPoint;
  68135. /**
  68136. * Gets the right operand input component
  68137. */
  68138. get right(): NodeMaterialConnectionPoint;
  68139. /**
  68140. * Gets the output component
  68141. */
  68142. get output(): NodeMaterialConnectionPoint;
  68143. protected _buildBlock(state: NodeMaterialBuildState): this;
  68144. }
  68145. }
  68146. declare module BABYLON {
  68147. /**
  68148. * Block used to step a value
  68149. */
  68150. export class StepBlock extends NodeMaterialBlock {
  68151. /**
  68152. * Creates a new StepBlock
  68153. * @param name defines the block name
  68154. */
  68155. constructor(name: string);
  68156. /**
  68157. * Gets the current class name
  68158. * @returns the class name
  68159. */
  68160. getClassName(): string;
  68161. /**
  68162. * Gets the value operand input component
  68163. */
  68164. get value(): NodeMaterialConnectionPoint;
  68165. /**
  68166. * Gets the edge operand input component
  68167. */
  68168. get edge(): NodeMaterialConnectionPoint;
  68169. /**
  68170. * Gets the output component
  68171. */
  68172. get output(): NodeMaterialConnectionPoint;
  68173. protected _buildBlock(state: NodeMaterialBuildState): this;
  68174. }
  68175. }
  68176. declare module BABYLON {
  68177. /**
  68178. * Block used to get the opposite (1 - x) of a value
  68179. */
  68180. export class OneMinusBlock extends NodeMaterialBlock {
  68181. /**
  68182. * Creates a new OneMinusBlock
  68183. * @param name defines the block name
  68184. */
  68185. constructor(name: string);
  68186. /**
  68187. * Gets the current class name
  68188. * @returns the class name
  68189. */
  68190. getClassName(): string;
  68191. /**
  68192. * Gets the input component
  68193. */
  68194. get input(): NodeMaterialConnectionPoint;
  68195. /**
  68196. * Gets the output component
  68197. */
  68198. get output(): NodeMaterialConnectionPoint;
  68199. protected _buildBlock(state: NodeMaterialBuildState): this;
  68200. }
  68201. }
  68202. declare module BABYLON {
  68203. /**
  68204. * Block used to get the view direction
  68205. */
  68206. export class ViewDirectionBlock extends NodeMaterialBlock {
  68207. /**
  68208. * Creates a new ViewDirectionBlock
  68209. * @param name defines the block name
  68210. */
  68211. constructor(name: string);
  68212. /**
  68213. * Gets the current class name
  68214. * @returns the class name
  68215. */
  68216. getClassName(): string;
  68217. /**
  68218. * Gets the world position component
  68219. */
  68220. get worldPosition(): NodeMaterialConnectionPoint;
  68221. /**
  68222. * Gets the camera position component
  68223. */
  68224. get cameraPosition(): NodeMaterialConnectionPoint;
  68225. /**
  68226. * Gets the output component
  68227. */
  68228. get output(): NodeMaterialConnectionPoint;
  68229. autoConfigure(material: NodeMaterial): void;
  68230. protected _buildBlock(state: NodeMaterialBuildState): this;
  68231. }
  68232. }
  68233. declare module BABYLON {
  68234. /**
  68235. * Block used to compute fresnel value
  68236. */
  68237. export class FresnelBlock extends NodeMaterialBlock {
  68238. /**
  68239. * Create a new FresnelBlock
  68240. * @param name defines the block name
  68241. */
  68242. constructor(name: string);
  68243. /**
  68244. * Gets the current class name
  68245. * @returns the class name
  68246. */
  68247. getClassName(): string;
  68248. /**
  68249. * Gets the world normal input component
  68250. */
  68251. get worldNormal(): NodeMaterialConnectionPoint;
  68252. /**
  68253. * Gets the view direction input component
  68254. */
  68255. get viewDirection(): NodeMaterialConnectionPoint;
  68256. /**
  68257. * Gets the bias input component
  68258. */
  68259. get bias(): NodeMaterialConnectionPoint;
  68260. /**
  68261. * Gets the camera (or eye) position component
  68262. */
  68263. get power(): NodeMaterialConnectionPoint;
  68264. /**
  68265. * Gets the fresnel output component
  68266. */
  68267. get fresnel(): NodeMaterialConnectionPoint;
  68268. autoConfigure(material: NodeMaterial): void;
  68269. protected _buildBlock(state: NodeMaterialBuildState): this;
  68270. }
  68271. }
  68272. declare module BABYLON {
  68273. /**
  68274. * Block used to get the max of 2 values
  68275. */
  68276. export class MaxBlock extends NodeMaterialBlock {
  68277. /**
  68278. * Creates a new MaxBlock
  68279. * @param name defines the block name
  68280. */
  68281. constructor(name: string);
  68282. /**
  68283. * Gets the current class name
  68284. * @returns the class name
  68285. */
  68286. getClassName(): string;
  68287. /**
  68288. * Gets the left operand input component
  68289. */
  68290. get left(): NodeMaterialConnectionPoint;
  68291. /**
  68292. * Gets the right operand input component
  68293. */
  68294. get right(): NodeMaterialConnectionPoint;
  68295. /**
  68296. * Gets the output component
  68297. */
  68298. get output(): NodeMaterialConnectionPoint;
  68299. protected _buildBlock(state: NodeMaterialBuildState): this;
  68300. }
  68301. }
  68302. declare module BABYLON {
  68303. /**
  68304. * Block used to get the min of 2 values
  68305. */
  68306. export class MinBlock extends NodeMaterialBlock {
  68307. /**
  68308. * Creates a new MinBlock
  68309. * @param name defines the block name
  68310. */
  68311. constructor(name: string);
  68312. /**
  68313. * Gets the current class name
  68314. * @returns the class name
  68315. */
  68316. getClassName(): string;
  68317. /**
  68318. * Gets the left operand input component
  68319. */
  68320. get left(): NodeMaterialConnectionPoint;
  68321. /**
  68322. * Gets the right operand input component
  68323. */
  68324. get right(): NodeMaterialConnectionPoint;
  68325. /**
  68326. * Gets the output component
  68327. */
  68328. get output(): NodeMaterialConnectionPoint;
  68329. protected _buildBlock(state: NodeMaterialBuildState): this;
  68330. }
  68331. }
  68332. declare module BABYLON {
  68333. /**
  68334. * Block used to get the distance between 2 values
  68335. */
  68336. export class DistanceBlock extends NodeMaterialBlock {
  68337. /**
  68338. * Creates a new DistanceBlock
  68339. * @param name defines the block name
  68340. */
  68341. constructor(name: string);
  68342. /**
  68343. * Gets the current class name
  68344. * @returns the class name
  68345. */
  68346. getClassName(): string;
  68347. /**
  68348. * Gets the left operand input component
  68349. */
  68350. get left(): NodeMaterialConnectionPoint;
  68351. /**
  68352. * Gets the right operand input component
  68353. */
  68354. get right(): NodeMaterialConnectionPoint;
  68355. /**
  68356. * Gets the output component
  68357. */
  68358. get output(): NodeMaterialConnectionPoint;
  68359. protected _buildBlock(state: NodeMaterialBuildState): this;
  68360. }
  68361. }
  68362. declare module BABYLON {
  68363. /**
  68364. * Block used to get the length of a vector
  68365. */
  68366. export class LengthBlock extends NodeMaterialBlock {
  68367. /**
  68368. * Creates a new LengthBlock
  68369. * @param name defines the block name
  68370. */
  68371. constructor(name: string);
  68372. /**
  68373. * Gets the current class name
  68374. * @returns the class name
  68375. */
  68376. getClassName(): string;
  68377. /**
  68378. * Gets the value input component
  68379. */
  68380. get value(): NodeMaterialConnectionPoint;
  68381. /**
  68382. * Gets the output component
  68383. */
  68384. get output(): NodeMaterialConnectionPoint;
  68385. protected _buildBlock(state: NodeMaterialBuildState): this;
  68386. }
  68387. }
  68388. declare module BABYLON {
  68389. /**
  68390. * Block used to get negative version of a value (i.e. x * -1)
  68391. */
  68392. export class NegateBlock extends NodeMaterialBlock {
  68393. /**
  68394. * Creates a new NegateBlock
  68395. * @param name defines the block name
  68396. */
  68397. constructor(name: string);
  68398. /**
  68399. * Gets the current class name
  68400. * @returns the class name
  68401. */
  68402. getClassName(): string;
  68403. /**
  68404. * Gets the value input component
  68405. */
  68406. get value(): NodeMaterialConnectionPoint;
  68407. /**
  68408. * Gets the output component
  68409. */
  68410. get output(): NodeMaterialConnectionPoint;
  68411. protected _buildBlock(state: NodeMaterialBuildState): this;
  68412. }
  68413. }
  68414. declare module BABYLON {
  68415. /**
  68416. * Block used to get the value of the first parameter raised to the power of the second
  68417. */
  68418. export class PowBlock extends NodeMaterialBlock {
  68419. /**
  68420. * Creates a new PowBlock
  68421. * @param name defines the block name
  68422. */
  68423. constructor(name: string);
  68424. /**
  68425. * Gets the current class name
  68426. * @returns the class name
  68427. */
  68428. getClassName(): string;
  68429. /**
  68430. * Gets the value operand input component
  68431. */
  68432. get value(): NodeMaterialConnectionPoint;
  68433. /**
  68434. * Gets the power operand input component
  68435. */
  68436. get power(): NodeMaterialConnectionPoint;
  68437. /**
  68438. * Gets the output component
  68439. */
  68440. get output(): NodeMaterialConnectionPoint;
  68441. protected _buildBlock(state: NodeMaterialBuildState): this;
  68442. }
  68443. }
  68444. declare module BABYLON {
  68445. /**
  68446. * Block used to get a random number
  68447. */
  68448. export class RandomNumberBlock extends NodeMaterialBlock {
  68449. /**
  68450. * Creates a new RandomNumberBlock
  68451. * @param name defines the block name
  68452. */
  68453. constructor(name: string);
  68454. /**
  68455. * Gets the current class name
  68456. * @returns the class name
  68457. */
  68458. getClassName(): string;
  68459. /**
  68460. * Gets the seed input component
  68461. */
  68462. get seed(): NodeMaterialConnectionPoint;
  68463. /**
  68464. * Gets the output component
  68465. */
  68466. get output(): NodeMaterialConnectionPoint;
  68467. protected _buildBlock(state: NodeMaterialBuildState): this;
  68468. }
  68469. }
  68470. declare module BABYLON {
  68471. /**
  68472. * Block used to compute arc tangent of 2 values
  68473. */
  68474. export class ArcTan2Block extends NodeMaterialBlock {
  68475. /**
  68476. * Creates a new ArcTan2Block
  68477. * @param name defines the block name
  68478. */
  68479. constructor(name: string);
  68480. /**
  68481. * Gets the current class name
  68482. * @returns the class name
  68483. */
  68484. getClassName(): string;
  68485. /**
  68486. * Gets the x operand input component
  68487. */
  68488. get x(): NodeMaterialConnectionPoint;
  68489. /**
  68490. * Gets the y operand input component
  68491. */
  68492. get y(): NodeMaterialConnectionPoint;
  68493. /**
  68494. * Gets the output component
  68495. */
  68496. get output(): NodeMaterialConnectionPoint;
  68497. protected _buildBlock(state: NodeMaterialBuildState): this;
  68498. }
  68499. }
  68500. declare module BABYLON {
  68501. /**
  68502. * Block used to smooth step a value
  68503. */
  68504. export class SmoothStepBlock extends NodeMaterialBlock {
  68505. /**
  68506. * Creates a new SmoothStepBlock
  68507. * @param name defines the block name
  68508. */
  68509. constructor(name: string);
  68510. /**
  68511. * Gets the current class name
  68512. * @returns the class name
  68513. */
  68514. getClassName(): string;
  68515. /**
  68516. * Gets the value operand input component
  68517. */
  68518. get value(): NodeMaterialConnectionPoint;
  68519. /**
  68520. * Gets the first edge operand input component
  68521. */
  68522. get edge0(): NodeMaterialConnectionPoint;
  68523. /**
  68524. * Gets the second edge operand input component
  68525. */
  68526. get edge1(): NodeMaterialConnectionPoint;
  68527. /**
  68528. * Gets the output component
  68529. */
  68530. get output(): NodeMaterialConnectionPoint;
  68531. protected _buildBlock(state: NodeMaterialBuildState): this;
  68532. }
  68533. }
  68534. declare module BABYLON {
  68535. /**
  68536. * Block used to get the reciprocal (1 / x) of a value
  68537. */
  68538. export class ReciprocalBlock extends NodeMaterialBlock {
  68539. /**
  68540. * Creates a new ReciprocalBlock
  68541. * @param name defines the block name
  68542. */
  68543. constructor(name: string);
  68544. /**
  68545. * Gets the current class name
  68546. * @returns the class name
  68547. */
  68548. getClassName(): string;
  68549. /**
  68550. * Gets the input component
  68551. */
  68552. get input(): NodeMaterialConnectionPoint;
  68553. /**
  68554. * Gets the output component
  68555. */
  68556. get output(): NodeMaterialConnectionPoint;
  68557. protected _buildBlock(state: NodeMaterialBuildState): this;
  68558. }
  68559. }
  68560. declare module BABYLON {
  68561. /**
  68562. * Block used to replace a color by another one
  68563. */
  68564. export class ReplaceColorBlock extends NodeMaterialBlock {
  68565. /**
  68566. * Creates a new ReplaceColorBlock
  68567. * @param name defines the block name
  68568. */
  68569. constructor(name: string);
  68570. /**
  68571. * Gets the current class name
  68572. * @returns the class name
  68573. */
  68574. getClassName(): string;
  68575. /**
  68576. * Gets the value input component
  68577. */
  68578. get value(): NodeMaterialConnectionPoint;
  68579. /**
  68580. * Gets the reference input component
  68581. */
  68582. get reference(): NodeMaterialConnectionPoint;
  68583. /**
  68584. * Gets the distance input component
  68585. */
  68586. get distance(): NodeMaterialConnectionPoint;
  68587. /**
  68588. * Gets the replacement input component
  68589. */
  68590. get replacement(): NodeMaterialConnectionPoint;
  68591. /**
  68592. * Gets the output component
  68593. */
  68594. get output(): NodeMaterialConnectionPoint;
  68595. protected _buildBlock(state: NodeMaterialBuildState): this;
  68596. }
  68597. }
  68598. declare module BABYLON {
  68599. /**
  68600. * Block used to posterize a value
  68601. * @see https://en.wikipedia.org/wiki/Posterization
  68602. */
  68603. export class PosterizeBlock extends NodeMaterialBlock {
  68604. /**
  68605. * Creates a new PosterizeBlock
  68606. * @param name defines the block name
  68607. */
  68608. constructor(name: string);
  68609. /**
  68610. * Gets the current class name
  68611. * @returns the class name
  68612. */
  68613. getClassName(): string;
  68614. /**
  68615. * Gets the value input component
  68616. */
  68617. get value(): NodeMaterialConnectionPoint;
  68618. /**
  68619. * Gets the steps input component
  68620. */
  68621. get steps(): NodeMaterialConnectionPoint;
  68622. /**
  68623. * Gets the output component
  68624. */
  68625. get output(): NodeMaterialConnectionPoint;
  68626. protected _buildBlock(state: NodeMaterialBuildState): this;
  68627. }
  68628. }
  68629. declare module BABYLON {
  68630. /**
  68631. * Operations supported by the Wave block
  68632. */
  68633. export enum WaveBlockKind {
  68634. /** SawTooth */
  68635. SawTooth = 0,
  68636. /** Square */
  68637. Square = 1,
  68638. /** Triangle */
  68639. Triangle = 2
  68640. }
  68641. /**
  68642. * Block used to apply wave operation to floats
  68643. */
  68644. export class WaveBlock extends NodeMaterialBlock {
  68645. /**
  68646. * Gets or sets the kibnd of wave to be applied by the block
  68647. */
  68648. kind: WaveBlockKind;
  68649. /**
  68650. * Creates a new WaveBlock
  68651. * @param name defines the block name
  68652. */
  68653. constructor(name: string);
  68654. /**
  68655. * Gets the current class name
  68656. * @returns the class name
  68657. */
  68658. getClassName(): string;
  68659. /**
  68660. * Gets the input component
  68661. */
  68662. get input(): NodeMaterialConnectionPoint;
  68663. /**
  68664. * Gets the output component
  68665. */
  68666. get output(): NodeMaterialConnectionPoint;
  68667. protected _buildBlock(state: NodeMaterialBuildState): this;
  68668. serialize(): any;
  68669. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68670. }
  68671. }
  68672. declare module BABYLON {
  68673. /**
  68674. * Class used to store a color step for the GradientBlock
  68675. */
  68676. export class GradientBlockColorStep {
  68677. private _step;
  68678. /**
  68679. * Gets value indicating which step this color is associated with (between 0 and 1)
  68680. */
  68681. get step(): number;
  68682. /**
  68683. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68684. */
  68685. set step(val: number);
  68686. private _color;
  68687. /**
  68688. * Gets the color associated with this step
  68689. */
  68690. get color(): Color3;
  68691. /**
  68692. * Sets the color associated with this step
  68693. */
  68694. set color(val: Color3);
  68695. /**
  68696. * Creates a new GradientBlockColorStep
  68697. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68698. * @param color defines the color associated with this step
  68699. */
  68700. constructor(step: number, color: Color3);
  68701. }
  68702. /**
  68703. * Block used to return a color from a gradient based on an input value between 0 and 1
  68704. */
  68705. export class GradientBlock extends NodeMaterialBlock {
  68706. /**
  68707. * Gets or sets the list of color steps
  68708. */
  68709. colorSteps: GradientBlockColorStep[];
  68710. /** Gets an observable raised when the value is changed */
  68711. onValueChangedObservable: Observable<GradientBlock>;
  68712. /** calls observable when the value is changed*/
  68713. colorStepsUpdated(): void;
  68714. /**
  68715. * Creates a new GradientBlock
  68716. * @param name defines the block name
  68717. */
  68718. constructor(name: string);
  68719. /**
  68720. * Gets the current class name
  68721. * @returns the class name
  68722. */
  68723. getClassName(): string;
  68724. /**
  68725. * Gets the gradient input component
  68726. */
  68727. get gradient(): NodeMaterialConnectionPoint;
  68728. /**
  68729. * Gets the output component
  68730. */
  68731. get output(): NodeMaterialConnectionPoint;
  68732. private _writeColorConstant;
  68733. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68734. serialize(): any;
  68735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68736. protected _dumpPropertiesCode(): string;
  68737. }
  68738. }
  68739. declare module BABYLON {
  68740. /**
  68741. * Block used to normalize lerp between 2 values
  68742. */
  68743. export class NLerpBlock extends NodeMaterialBlock {
  68744. /**
  68745. * Creates a new NLerpBlock
  68746. * @param name defines the block name
  68747. */
  68748. constructor(name: string);
  68749. /**
  68750. * Gets the current class name
  68751. * @returns the class name
  68752. */
  68753. getClassName(): string;
  68754. /**
  68755. * Gets the left operand input component
  68756. */
  68757. get left(): NodeMaterialConnectionPoint;
  68758. /**
  68759. * Gets the right operand input component
  68760. */
  68761. get right(): NodeMaterialConnectionPoint;
  68762. /**
  68763. * Gets the gradient operand input component
  68764. */
  68765. get gradient(): NodeMaterialConnectionPoint;
  68766. /**
  68767. * Gets the output component
  68768. */
  68769. get output(): NodeMaterialConnectionPoint;
  68770. protected _buildBlock(state: NodeMaterialBuildState): this;
  68771. }
  68772. }
  68773. declare module BABYLON {
  68774. /**
  68775. * block used to Generate a Worley Noise 3D Noise Pattern
  68776. */
  68777. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68778. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68779. manhattanDistance: boolean;
  68780. /**
  68781. * Creates a new WorleyNoise3DBlock
  68782. * @param name defines the block name
  68783. */
  68784. constructor(name: string);
  68785. /**
  68786. * Gets the current class name
  68787. * @returns the class name
  68788. */
  68789. getClassName(): string;
  68790. /**
  68791. * Gets the seed input component
  68792. */
  68793. get seed(): NodeMaterialConnectionPoint;
  68794. /**
  68795. * Gets the jitter input component
  68796. */
  68797. get jitter(): NodeMaterialConnectionPoint;
  68798. /**
  68799. * Gets the output component
  68800. */
  68801. get output(): NodeMaterialConnectionPoint;
  68802. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68803. /**
  68804. * Exposes the properties to the UI?
  68805. */
  68806. protected _dumpPropertiesCode(): string;
  68807. /**
  68808. * Exposes the properties to the Serialize?
  68809. */
  68810. serialize(): any;
  68811. /**
  68812. * Exposes the properties to the deserialize?
  68813. */
  68814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68815. }
  68816. }
  68817. declare module BABYLON {
  68818. /**
  68819. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68820. */
  68821. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68822. /**
  68823. * Creates a new SimplexPerlin3DBlock
  68824. * @param name defines the block name
  68825. */
  68826. constructor(name: string);
  68827. /**
  68828. * Gets the current class name
  68829. * @returns the class name
  68830. */
  68831. getClassName(): string;
  68832. /**
  68833. * Gets the seed operand input component
  68834. */
  68835. get seed(): NodeMaterialConnectionPoint;
  68836. /**
  68837. * Gets the output component
  68838. */
  68839. get output(): NodeMaterialConnectionPoint;
  68840. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68841. }
  68842. }
  68843. declare module BABYLON {
  68844. /**
  68845. * Block used to blend normals
  68846. */
  68847. export class NormalBlendBlock extends NodeMaterialBlock {
  68848. /**
  68849. * Creates a new NormalBlendBlock
  68850. * @param name defines the block name
  68851. */
  68852. constructor(name: string);
  68853. /**
  68854. * Gets the current class name
  68855. * @returns the class name
  68856. */
  68857. getClassName(): string;
  68858. /**
  68859. * Gets the first input component
  68860. */
  68861. get normalMap0(): NodeMaterialConnectionPoint;
  68862. /**
  68863. * Gets the second input component
  68864. */
  68865. get normalMap1(): NodeMaterialConnectionPoint;
  68866. /**
  68867. * Gets the output component
  68868. */
  68869. get output(): NodeMaterialConnectionPoint;
  68870. protected _buildBlock(state: NodeMaterialBuildState): this;
  68871. }
  68872. }
  68873. declare module BABYLON {
  68874. /**
  68875. * Block used to rotate a 2d vector by a given angle
  68876. */
  68877. export class Rotate2dBlock extends NodeMaterialBlock {
  68878. /**
  68879. * Creates a new Rotate2dBlock
  68880. * @param name defines the block name
  68881. */
  68882. constructor(name: string);
  68883. /**
  68884. * Gets the current class name
  68885. * @returns the class name
  68886. */
  68887. getClassName(): string;
  68888. /**
  68889. * Gets the input vector
  68890. */
  68891. get input(): NodeMaterialConnectionPoint;
  68892. /**
  68893. * Gets the input angle
  68894. */
  68895. get angle(): NodeMaterialConnectionPoint;
  68896. /**
  68897. * Gets the output component
  68898. */
  68899. get output(): NodeMaterialConnectionPoint;
  68900. autoConfigure(material: NodeMaterial): void;
  68901. protected _buildBlock(state: NodeMaterialBuildState): this;
  68902. }
  68903. }
  68904. declare module BABYLON {
  68905. /**
  68906. * Block used to get the reflected vector from a direction and a normal
  68907. */
  68908. export class ReflectBlock extends NodeMaterialBlock {
  68909. /**
  68910. * Creates a new ReflectBlock
  68911. * @param name defines the block name
  68912. */
  68913. constructor(name: string);
  68914. /**
  68915. * Gets the current class name
  68916. * @returns the class name
  68917. */
  68918. getClassName(): string;
  68919. /**
  68920. * Gets the incident component
  68921. */
  68922. get incident(): NodeMaterialConnectionPoint;
  68923. /**
  68924. * Gets the normal component
  68925. */
  68926. get normal(): NodeMaterialConnectionPoint;
  68927. /**
  68928. * Gets the output component
  68929. */
  68930. get output(): NodeMaterialConnectionPoint;
  68931. protected _buildBlock(state: NodeMaterialBuildState): this;
  68932. }
  68933. }
  68934. declare module BABYLON {
  68935. /**
  68936. * Block used to get the refracted vector from a direction and a normal
  68937. */
  68938. export class RefractBlock extends NodeMaterialBlock {
  68939. /**
  68940. * Creates a new RefractBlock
  68941. * @param name defines the block name
  68942. */
  68943. constructor(name: string);
  68944. /**
  68945. * Gets the current class name
  68946. * @returns the class name
  68947. */
  68948. getClassName(): string;
  68949. /**
  68950. * Gets the incident component
  68951. */
  68952. get incident(): NodeMaterialConnectionPoint;
  68953. /**
  68954. * Gets the normal component
  68955. */
  68956. get normal(): NodeMaterialConnectionPoint;
  68957. /**
  68958. * Gets the index of refraction component
  68959. */
  68960. get ior(): NodeMaterialConnectionPoint;
  68961. /**
  68962. * Gets the output component
  68963. */
  68964. get output(): NodeMaterialConnectionPoint;
  68965. protected _buildBlock(state: NodeMaterialBuildState): this;
  68966. }
  68967. }
  68968. declare module BABYLON {
  68969. /**
  68970. * Block used to desaturate a color
  68971. */
  68972. export class DesaturateBlock extends NodeMaterialBlock {
  68973. /**
  68974. * Creates a new DesaturateBlock
  68975. * @param name defines the block name
  68976. */
  68977. constructor(name: string);
  68978. /**
  68979. * Gets the current class name
  68980. * @returns the class name
  68981. */
  68982. getClassName(): string;
  68983. /**
  68984. * Gets the color operand input component
  68985. */
  68986. get color(): NodeMaterialConnectionPoint;
  68987. /**
  68988. * Gets the level operand input component
  68989. */
  68990. get level(): NodeMaterialConnectionPoint;
  68991. /**
  68992. * Gets the output component
  68993. */
  68994. get output(): NodeMaterialConnectionPoint;
  68995. protected _buildBlock(state: NodeMaterialBuildState): this;
  68996. }
  68997. }
  68998. declare module BABYLON {
  68999. /**
  69000. * Block used to implement the reflection module of the PBR material
  69001. */
  69002. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69003. /** @hidden */
  69004. _defineLODReflectionAlpha: string;
  69005. /** @hidden */
  69006. _defineLinearSpecularReflection: string;
  69007. private _vEnvironmentIrradianceName;
  69008. /** @hidden */
  69009. _vReflectionMicrosurfaceInfosName: string;
  69010. /** @hidden */
  69011. _vReflectionInfosName: string;
  69012. /** @hidden */
  69013. _vReflectionFilteringInfoName: string;
  69014. private _scene;
  69015. /**
  69016. * The properties below are set by the main PBR block prior to calling methods of this class.
  69017. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69018. * It's less burden on the user side in the editor part.
  69019. */
  69020. /** @hidden */
  69021. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69022. /** @hidden */
  69023. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69024. /** @hidden */
  69025. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69026. /** @hidden */
  69027. viewConnectionPoint: NodeMaterialConnectionPoint;
  69028. /**
  69029. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69030. * diffuse part of the IBL.
  69031. */
  69032. useSphericalHarmonics: boolean;
  69033. /**
  69034. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69035. */
  69036. forceIrradianceInFragment: boolean;
  69037. /**
  69038. * Create a new ReflectionBlock
  69039. * @param name defines the block name
  69040. */
  69041. constructor(name: string);
  69042. /**
  69043. * Gets the current class name
  69044. * @returns the class name
  69045. */
  69046. getClassName(): string;
  69047. /**
  69048. * Gets the position input component
  69049. */
  69050. get position(): NodeMaterialConnectionPoint;
  69051. /**
  69052. * Gets the world position input component
  69053. */
  69054. get worldPosition(): NodeMaterialConnectionPoint;
  69055. /**
  69056. * Gets the world normal input component
  69057. */
  69058. get worldNormal(): NodeMaterialConnectionPoint;
  69059. /**
  69060. * Gets the world input component
  69061. */
  69062. get world(): NodeMaterialConnectionPoint;
  69063. /**
  69064. * Gets the camera (or eye) position component
  69065. */
  69066. get cameraPosition(): NodeMaterialConnectionPoint;
  69067. /**
  69068. * Gets the view input component
  69069. */
  69070. get view(): NodeMaterialConnectionPoint;
  69071. /**
  69072. * Gets the color input component
  69073. */
  69074. get color(): NodeMaterialConnectionPoint;
  69075. /**
  69076. * Gets the reflection object output component
  69077. */
  69078. get reflection(): NodeMaterialConnectionPoint;
  69079. /**
  69080. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69081. */
  69082. get hasTexture(): boolean;
  69083. /**
  69084. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69085. */
  69086. get reflectionColor(): string;
  69087. protected _getTexture(): Nullable<BaseTexture>;
  69088. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69090. /**
  69091. * Gets the code to inject in the vertex shader
  69092. * @param state current state of the node material building
  69093. * @returns the shader code
  69094. */
  69095. handleVertexSide(state: NodeMaterialBuildState): string;
  69096. /**
  69097. * Gets the main code of the block (fragment side)
  69098. * @param state current state of the node material building
  69099. * @param normalVarName name of the existing variable corresponding to the normal
  69100. * @returns the shader code
  69101. */
  69102. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69103. protected _buildBlock(state: NodeMaterialBuildState): this;
  69104. protected _dumpPropertiesCode(): string;
  69105. serialize(): any;
  69106. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69107. }
  69108. }
  69109. declare module BABYLON {
  69110. /**
  69111. * Block used to implement the sheen module of the PBR material
  69112. */
  69113. export class SheenBlock extends NodeMaterialBlock {
  69114. /**
  69115. * Create a new SheenBlock
  69116. * @param name defines the block name
  69117. */
  69118. constructor(name: string);
  69119. /**
  69120. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69121. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69122. * making it easier to setup and tweak the effect
  69123. */
  69124. albedoScaling: boolean;
  69125. /**
  69126. * Defines if the sheen is linked to the sheen color.
  69127. */
  69128. linkSheenWithAlbedo: boolean;
  69129. /**
  69130. * Initialize the block and prepare the context for build
  69131. * @param state defines the state that will be used for the build
  69132. */
  69133. initialize(state: NodeMaterialBuildState): void;
  69134. /**
  69135. * Gets the current class name
  69136. * @returns the class name
  69137. */
  69138. getClassName(): string;
  69139. /**
  69140. * Gets the intensity input component
  69141. */
  69142. get intensity(): NodeMaterialConnectionPoint;
  69143. /**
  69144. * Gets the color input component
  69145. */
  69146. get color(): NodeMaterialConnectionPoint;
  69147. /**
  69148. * Gets the roughness input component
  69149. */
  69150. get roughness(): NodeMaterialConnectionPoint;
  69151. /**
  69152. * Gets the sheen object output component
  69153. */
  69154. get sheen(): NodeMaterialConnectionPoint;
  69155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69156. /**
  69157. * Gets the main code of the block (fragment side)
  69158. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69159. * @returns the shader code
  69160. */
  69161. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69162. protected _buildBlock(state: NodeMaterialBuildState): this;
  69163. protected _dumpPropertiesCode(): string;
  69164. serialize(): any;
  69165. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69166. }
  69167. }
  69168. declare module BABYLON {
  69169. /**
  69170. * Block used to implement the anisotropy module of the PBR material
  69171. */
  69172. export class AnisotropyBlock extends NodeMaterialBlock {
  69173. /**
  69174. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69175. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69176. * It's less burden on the user side in the editor part.
  69177. */
  69178. /** @hidden */
  69179. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69180. /** @hidden */
  69181. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69182. /**
  69183. * Create a new AnisotropyBlock
  69184. * @param name defines the block name
  69185. */
  69186. constructor(name: string);
  69187. /**
  69188. * Initialize the block and prepare the context for build
  69189. * @param state defines the state that will be used for the build
  69190. */
  69191. initialize(state: NodeMaterialBuildState): void;
  69192. /**
  69193. * Gets the current class name
  69194. * @returns the class name
  69195. */
  69196. getClassName(): string;
  69197. /**
  69198. * Gets the intensity input component
  69199. */
  69200. get intensity(): NodeMaterialConnectionPoint;
  69201. /**
  69202. * Gets the direction input component
  69203. */
  69204. get direction(): NodeMaterialConnectionPoint;
  69205. /**
  69206. * Gets the uv input component
  69207. */
  69208. get uv(): NodeMaterialConnectionPoint;
  69209. /**
  69210. * Gets the worldTangent input component
  69211. */
  69212. get worldTangent(): NodeMaterialConnectionPoint;
  69213. /**
  69214. * Gets the anisotropy object output component
  69215. */
  69216. get anisotropy(): NodeMaterialConnectionPoint;
  69217. private _generateTBNSpace;
  69218. /**
  69219. * Gets the main code of the block (fragment side)
  69220. * @param state current state of the node material building
  69221. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69222. * @returns the shader code
  69223. */
  69224. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69225. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69226. protected _buildBlock(state: NodeMaterialBuildState): this;
  69227. }
  69228. }
  69229. declare module BABYLON {
  69230. /**
  69231. * Block used to implement the clear coat module of the PBR material
  69232. */
  69233. export class ClearCoatBlock extends NodeMaterialBlock {
  69234. private _scene;
  69235. /**
  69236. * Create a new ClearCoatBlock
  69237. * @param name defines the block name
  69238. */
  69239. constructor(name: string);
  69240. /**
  69241. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69242. */
  69243. remapF0OnInterfaceChange: boolean;
  69244. /**
  69245. * Initialize the block and prepare the context for build
  69246. * @param state defines the state that will be used for the build
  69247. */
  69248. initialize(state: NodeMaterialBuildState): void;
  69249. /**
  69250. * Gets the current class name
  69251. * @returns the class name
  69252. */
  69253. getClassName(): string;
  69254. /**
  69255. * Gets the intensity input component
  69256. */
  69257. get intensity(): NodeMaterialConnectionPoint;
  69258. /**
  69259. * Gets the roughness input component
  69260. */
  69261. get roughness(): NodeMaterialConnectionPoint;
  69262. /**
  69263. * Gets the ior input component
  69264. */
  69265. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69266. /**
  69267. * Gets the bump texture input component
  69268. */
  69269. get normalMapColor(): NodeMaterialConnectionPoint;
  69270. /**
  69271. * Gets the uv input component
  69272. */
  69273. get uv(): NodeMaterialConnectionPoint;
  69274. /**
  69275. * Gets the tint color input component
  69276. */
  69277. get tintColor(): NodeMaterialConnectionPoint;
  69278. /**
  69279. * Gets the tint "at distance" input component
  69280. */
  69281. get tintAtDistance(): NodeMaterialConnectionPoint;
  69282. /**
  69283. * Gets the tint thickness input component
  69284. */
  69285. get tintThickness(): NodeMaterialConnectionPoint;
  69286. /**
  69287. * Gets the world tangent input component
  69288. */
  69289. get worldTangent(): NodeMaterialConnectionPoint;
  69290. /**
  69291. * Gets the clear coat object output component
  69292. */
  69293. get clearcoat(): NodeMaterialConnectionPoint;
  69294. autoConfigure(material: NodeMaterial): void;
  69295. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69296. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69297. private _generateTBNSpace;
  69298. /**
  69299. * Gets the main code of the block (fragment side)
  69300. * @param state current state of the node material building
  69301. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69302. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69303. * @param worldPosVarName name of the variable holding the world position
  69304. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69305. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69306. * @param worldNormalVarName name of the variable holding the world normal
  69307. * @returns the shader code
  69308. */
  69309. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69310. protected _buildBlock(state: NodeMaterialBuildState): this;
  69311. protected _dumpPropertiesCode(): string;
  69312. serialize(): any;
  69313. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69314. }
  69315. }
  69316. declare module BABYLON {
  69317. /**
  69318. * Block used to implement the sub surface module of the PBR material
  69319. */
  69320. export class SubSurfaceBlock extends NodeMaterialBlock {
  69321. /**
  69322. * Create a new SubSurfaceBlock
  69323. * @param name defines the block name
  69324. */
  69325. constructor(name: string);
  69326. /**
  69327. * Initialize the block and prepare the context for build
  69328. * @param state defines the state that will be used for the build
  69329. */
  69330. initialize(state: NodeMaterialBuildState): void;
  69331. /**
  69332. * Gets the current class name
  69333. * @returns the class name
  69334. */
  69335. getClassName(): string;
  69336. /**
  69337. * Gets the thickness component
  69338. */
  69339. get thickness(): NodeMaterialConnectionPoint;
  69340. /**
  69341. * Gets the tint color input component
  69342. */
  69343. get tintColor(): NodeMaterialConnectionPoint;
  69344. /**
  69345. * Gets the translucency intensity input component
  69346. */
  69347. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69348. /**
  69349. * Gets the translucency diffusion distance input component
  69350. */
  69351. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69352. /**
  69353. * Gets the refraction object parameters
  69354. */
  69355. get refraction(): NodeMaterialConnectionPoint;
  69356. /**
  69357. * Gets the sub surface object output component
  69358. */
  69359. get subsurface(): NodeMaterialConnectionPoint;
  69360. autoConfigure(material: NodeMaterial): void;
  69361. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69362. /**
  69363. * Gets the main code of the block (fragment side)
  69364. * @param state current state of the node material building
  69365. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69366. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69367. * @param worldPosVarName name of the variable holding the world position
  69368. * @returns the shader code
  69369. */
  69370. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69371. protected _buildBlock(state: NodeMaterialBuildState): this;
  69372. }
  69373. }
  69374. declare module BABYLON {
  69375. /**
  69376. * Block used to implement the PBR metallic/roughness model
  69377. */
  69378. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69379. /**
  69380. * Gets or sets the light associated with this block
  69381. */
  69382. light: Nullable<Light>;
  69383. private _lightId;
  69384. private _scene;
  69385. private _environmentBRDFTexture;
  69386. private _environmentBrdfSamplerName;
  69387. private _vNormalWName;
  69388. private _invertNormalName;
  69389. private _metallicReflectanceColor;
  69390. private _metallicF0Factor;
  69391. private _vMetallicReflectanceFactorsName;
  69392. /**
  69393. * Create a new ReflectionBlock
  69394. * @param name defines the block name
  69395. */
  69396. constructor(name: string);
  69397. /**
  69398. * Intensity of the direct lights e.g. the four lights available in your scene.
  69399. * This impacts both the direct diffuse and specular highlights.
  69400. */
  69401. directIntensity: number;
  69402. /**
  69403. * Intensity of the environment e.g. how much the environment will light the object
  69404. * either through harmonics for rough material or through the reflection for shiny ones.
  69405. */
  69406. environmentIntensity: number;
  69407. /**
  69408. * This is a special control allowing the reduction of the specular highlights coming from the
  69409. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69410. */
  69411. specularIntensity: number;
  69412. /**
  69413. * Defines the falloff type used in this material.
  69414. * It by default is Physical.
  69415. */
  69416. lightFalloff: number;
  69417. /**
  69418. * Specifies that alpha test should be used
  69419. */
  69420. useAlphaTest: boolean;
  69421. /**
  69422. * Defines the alpha limits in alpha test mode.
  69423. */
  69424. alphaTestCutoff: number;
  69425. /**
  69426. * Specifies that alpha blending should be used
  69427. */
  69428. useAlphaBlending: boolean;
  69429. /**
  69430. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69431. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  69432. */
  69433. useRadianceOverAlpha: boolean;
  69434. /**
  69435. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69436. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  69437. */
  69438. useSpecularOverAlpha: boolean;
  69439. /**
  69440. * Enables specular anti aliasing in the PBR shader.
  69441. * It will both interacts on the Geometry for analytical and IBL lighting.
  69442. * It also prefilter the roughness map based on the bump values.
  69443. */
  69444. enableSpecularAntiAliasing: boolean;
  69445. /**
  69446. * Enables realtime filtering on the texture.
  69447. */
  69448. realTimeFiltering: boolean;
  69449. /**
  69450. * Quality switch for realtime filtering
  69451. */
  69452. realTimeFilteringQuality: number;
  69453. /**
  69454. * Defines if the material uses energy conservation.
  69455. */
  69456. useEnergyConservation: boolean;
  69457. /**
  69458. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69459. * too much the area relying on ambient texture to define their ambient occlusion.
  69460. */
  69461. useRadianceOcclusion: boolean;
  69462. /**
  69463. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69464. * makes the reflect vector face the model (under horizon).
  69465. */
  69466. useHorizonOcclusion: boolean;
  69467. /**
  69468. * If set to true, no lighting calculations will be applied.
  69469. */
  69470. unlit: boolean;
  69471. /**
  69472. * Force normal to face away from face.
  69473. */
  69474. forceNormalForward: boolean;
  69475. /**
  69476. * Defines the material debug mode.
  69477. * It helps seeing only some components of the material while troubleshooting.
  69478. */
  69479. debugMode: number;
  69480. /**
  69481. * Specify from where on screen the debug mode should start.
  69482. * The value goes from -1 (full screen) to 1 (not visible)
  69483. * It helps with side by side comparison against the final render
  69484. * This defaults to 0
  69485. */
  69486. debugLimit: number;
  69487. /**
  69488. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69489. * You can use the factor to better multiply the final value.
  69490. */
  69491. debugFactor: number;
  69492. /**
  69493. * Initialize the block and prepare the context for build
  69494. * @param state defines the state that will be used for the build
  69495. */
  69496. initialize(state: NodeMaterialBuildState): void;
  69497. /**
  69498. * Gets the current class name
  69499. * @returns the class name
  69500. */
  69501. getClassName(): string;
  69502. /**
  69503. * Gets the world position input component
  69504. */
  69505. get worldPosition(): NodeMaterialConnectionPoint;
  69506. /**
  69507. * Gets the world normal input component
  69508. */
  69509. get worldNormal(): NodeMaterialConnectionPoint;
  69510. /**
  69511. * Gets the view matrix parameter
  69512. */
  69513. get view(): NodeMaterialConnectionPoint;
  69514. /**
  69515. * Gets the camera position input component
  69516. */
  69517. get cameraPosition(): NodeMaterialConnectionPoint;
  69518. /**
  69519. * Gets the perturbed normal input component
  69520. */
  69521. get perturbedNormal(): NodeMaterialConnectionPoint;
  69522. /**
  69523. * Gets the base color input component
  69524. */
  69525. get baseColor(): NodeMaterialConnectionPoint;
  69526. /**
  69527. * Gets the metallic input component
  69528. */
  69529. get metallic(): NodeMaterialConnectionPoint;
  69530. /**
  69531. * Gets the roughness input component
  69532. */
  69533. get roughness(): NodeMaterialConnectionPoint;
  69534. /**
  69535. * Gets the ambient occlusion input component
  69536. */
  69537. get ambientOcc(): NodeMaterialConnectionPoint;
  69538. /**
  69539. * Gets the opacity input component
  69540. */
  69541. get opacity(): NodeMaterialConnectionPoint;
  69542. /**
  69543. * Gets the index of refraction input component
  69544. */
  69545. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69546. /**
  69547. * Gets the ambient color input component
  69548. */
  69549. get ambientColor(): NodeMaterialConnectionPoint;
  69550. /**
  69551. * Gets the reflection object parameters
  69552. */
  69553. get reflection(): NodeMaterialConnectionPoint;
  69554. /**
  69555. * Gets the clear coat object parameters
  69556. */
  69557. get clearcoat(): NodeMaterialConnectionPoint;
  69558. /**
  69559. * Gets the sheen object parameters
  69560. */
  69561. get sheen(): NodeMaterialConnectionPoint;
  69562. /**
  69563. * Gets the sub surface object parameters
  69564. */
  69565. get subsurface(): NodeMaterialConnectionPoint;
  69566. /**
  69567. * Gets the anisotropy object parameters
  69568. */
  69569. get anisotropy(): NodeMaterialConnectionPoint;
  69570. /**
  69571. * Gets the ambient output component
  69572. */
  69573. get ambientClr(): NodeMaterialConnectionPoint;
  69574. /**
  69575. * Gets the diffuse output component
  69576. */
  69577. get diffuseDir(): NodeMaterialConnectionPoint;
  69578. /**
  69579. * Gets the specular output component
  69580. */
  69581. get specularDir(): NodeMaterialConnectionPoint;
  69582. /**
  69583. * Gets the clear coat output component
  69584. */
  69585. get clearcoatDir(): NodeMaterialConnectionPoint;
  69586. /**
  69587. * Gets the sheen output component
  69588. */
  69589. get sheenDir(): NodeMaterialConnectionPoint;
  69590. /**
  69591. * Gets the indirect diffuse output component
  69592. */
  69593. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69594. /**
  69595. * Gets the indirect specular output component
  69596. */
  69597. get specularIndirect(): NodeMaterialConnectionPoint;
  69598. /**
  69599. * Gets the indirect clear coat output component
  69600. */
  69601. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69602. /**
  69603. * Gets the indirect sheen output component
  69604. */
  69605. get sheenIndirect(): NodeMaterialConnectionPoint;
  69606. /**
  69607. * Gets the refraction output component
  69608. */
  69609. get refraction(): NodeMaterialConnectionPoint;
  69610. /**
  69611. * Gets the global lighting output component
  69612. */
  69613. get lighting(): NodeMaterialConnectionPoint;
  69614. /**
  69615. * Gets the shadow output component
  69616. */
  69617. get shadow(): NodeMaterialConnectionPoint;
  69618. /**
  69619. * Gets the alpha output component
  69620. */
  69621. get alpha(): NodeMaterialConnectionPoint;
  69622. autoConfigure(material: NodeMaterial): void;
  69623. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69624. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69625. isReady(): boolean;
  69626. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69627. private _injectVertexCode;
  69628. private _getAlbedoOpacityCode;
  69629. private _getAmbientOcclusionCode;
  69630. private _getReflectivityCode;
  69631. protected _buildBlock(state: NodeMaterialBuildState): this;
  69632. protected _dumpPropertiesCode(): string;
  69633. serialize(): any;
  69634. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69635. }
  69636. }
  69637. declare module BABYLON {
  69638. /**
  69639. * Block used to compute value of one parameter modulo another
  69640. */
  69641. export class ModBlock extends NodeMaterialBlock {
  69642. /**
  69643. * Creates a new ModBlock
  69644. * @param name defines the block name
  69645. */
  69646. constructor(name: string);
  69647. /**
  69648. * Gets the current class name
  69649. * @returns the class name
  69650. */
  69651. getClassName(): string;
  69652. /**
  69653. * Gets the left operand input component
  69654. */
  69655. get left(): NodeMaterialConnectionPoint;
  69656. /**
  69657. * Gets the right operand input component
  69658. */
  69659. get right(): NodeMaterialConnectionPoint;
  69660. /**
  69661. * Gets the output component
  69662. */
  69663. get output(): NodeMaterialConnectionPoint;
  69664. protected _buildBlock(state: NodeMaterialBuildState): this;
  69665. }
  69666. }
  69667. declare module BABYLON {
  69668. /**
  69669. * Configuration for Draco compression
  69670. */
  69671. export interface IDracoCompressionConfiguration {
  69672. /**
  69673. * Configuration for the decoder.
  69674. */
  69675. decoder: {
  69676. /**
  69677. * The url to the WebAssembly module.
  69678. */
  69679. wasmUrl?: string;
  69680. /**
  69681. * The url to the WebAssembly binary.
  69682. */
  69683. wasmBinaryUrl?: string;
  69684. /**
  69685. * The url to the fallback JavaScript module.
  69686. */
  69687. fallbackUrl?: string;
  69688. };
  69689. }
  69690. /**
  69691. * Draco compression (https://google.github.io/draco/)
  69692. *
  69693. * This class wraps the Draco module.
  69694. *
  69695. * **Encoder**
  69696. *
  69697. * The encoder is not currently implemented.
  69698. *
  69699. * **Decoder**
  69700. *
  69701. * 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.
  69702. *
  69703. * To update the configuration, use the following code:
  69704. * ```javascript
  69705. * DracoCompression.Configuration = {
  69706. * decoder: {
  69707. * wasmUrl: "<url to the WebAssembly library>",
  69708. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69709. * fallbackUrl: "<url to the fallback JavaScript library>",
  69710. * }
  69711. * };
  69712. * ```
  69713. *
  69714. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support WebAssembly or only support the JavaScript version.
  69715. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69716. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69717. *
  69718. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69719. * ```javascript
  69720. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69721. * ```
  69722. *
  69723. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69724. */
  69725. export class DracoCompression implements IDisposable {
  69726. private _workerPoolPromise?;
  69727. private _decoderModulePromise?;
  69728. /**
  69729. * The configuration. Defaults to the following urls:
  69730. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69731. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69732. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69733. */
  69734. static Configuration: IDracoCompressionConfiguration;
  69735. /**
  69736. * Returns true if the decoder configuration is available.
  69737. */
  69738. static get DecoderAvailable(): boolean;
  69739. /**
  69740. * Default number of workers to create when creating the draco compression object.
  69741. */
  69742. static DefaultNumWorkers: number;
  69743. private static GetDefaultNumWorkers;
  69744. private static _Default;
  69745. /**
  69746. * Default instance for the draco compression object.
  69747. */
  69748. static get Default(): DracoCompression;
  69749. /**
  69750. * Constructor
  69751. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69752. */
  69753. constructor(numWorkers?: number);
  69754. /**
  69755. * Stop all async operations and release resources.
  69756. */
  69757. dispose(): void;
  69758. /**
  69759. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69760. * @returns a promise that resolves when ready
  69761. */
  69762. whenReadyAsync(): Promise<void>;
  69763. /**
  69764. * Decode Draco compressed mesh data to vertex data.
  69765. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69766. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69767. * @returns A promise that resolves with the decoded vertex data
  69768. */
  69769. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69770. [kind: string]: number;
  69771. }): Promise<VertexData>;
  69772. }
  69773. }
  69774. declare module BABYLON {
  69775. /**
  69776. * Class for building Constructive Solid Geometry
  69777. */
  69778. export class CSG {
  69779. private polygons;
  69780. /**
  69781. * The world matrix
  69782. */
  69783. matrix: Matrix;
  69784. /**
  69785. * Stores the position
  69786. */
  69787. position: Vector3;
  69788. /**
  69789. * Stores the rotation
  69790. */
  69791. rotation: Vector3;
  69792. /**
  69793. * Stores the rotation quaternion
  69794. */
  69795. rotationQuaternion: Nullable<Quaternion>;
  69796. /**
  69797. * Stores the scaling vector
  69798. */
  69799. scaling: Vector3;
  69800. /**
  69801. * Convert the Mesh to CSG
  69802. * @param mesh The Mesh to convert to CSG
  69803. * @returns A new CSG from the Mesh
  69804. */
  69805. static FromMesh(mesh: Mesh): CSG;
  69806. /**
  69807. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69808. * @param polygons Polygons used to construct a CSG solid
  69809. */
  69810. private static FromPolygons;
  69811. /**
  69812. * Clones, or makes a deep copy, of the CSG
  69813. * @returns A new CSG
  69814. */
  69815. clone(): CSG;
  69816. /**
  69817. * Unions this CSG with another CSG
  69818. * @param csg The CSG to union against this CSG
  69819. * @returns The unioned CSG
  69820. */
  69821. union(csg: CSG): CSG;
  69822. /**
  69823. * Unions this CSG with another CSG in place
  69824. * @param csg The CSG to union against this CSG
  69825. */
  69826. unionInPlace(csg: CSG): void;
  69827. /**
  69828. * Subtracts this CSG with another CSG
  69829. * @param csg The CSG to subtract against this CSG
  69830. * @returns A new CSG
  69831. */
  69832. subtract(csg: CSG): CSG;
  69833. /**
  69834. * Subtracts this CSG with another CSG in place
  69835. * @param csg The CSG to subtract against this CSG
  69836. */
  69837. subtractInPlace(csg: CSG): void;
  69838. /**
  69839. * Intersect this CSG with another CSG
  69840. * @param csg The CSG to intersect against this CSG
  69841. * @returns A new CSG
  69842. */
  69843. intersect(csg: CSG): CSG;
  69844. /**
  69845. * Intersects this CSG with another CSG in place
  69846. * @param csg The CSG to intersect against this CSG
  69847. */
  69848. intersectInPlace(csg: CSG): void;
  69849. /**
  69850. * Return a new CSG solid with solid and empty space switched. This solid is
  69851. * not modified.
  69852. * @returns A new CSG solid with solid and empty space switched
  69853. */
  69854. inverse(): CSG;
  69855. /**
  69856. * Inverses the CSG in place
  69857. */
  69858. inverseInPlace(): void;
  69859. /**
  69860. * This is used to keep meshes transformations so they can be restored
  69861. * when we build back a Babylon Mesh
  69862. * NB : All CSG operations are performed in world coordinates
  69863. * @param csg The CSG to copy the transform attributes from
  69864. * @returns This CSG
  69865. */
  69866. copyTransformAttributes(csg: CSG): CSG;
  69867. /**
  69868. * Build Raw mesh from CSG
  69869. * Coordinates here are in world space
  69870. * @param name The name of the mesh geometry
  69871. * @param scene The Scene
  69872. * @param keepSubMeshes Specifies if the submeshes should be kept
  69873. * @returns A new Mesh
  69874. */
  69875. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69876. /**
  69877. * Build Mesh from CSG taking material and transforms into account
  69878. * @param name The name of the Mesh
  69879. * @param material The material of the Mesh
  69880. * @param scene The Scene
  69881. * @param keepSubMeshes Specifies if submeshes should be kept
  69882. * @returns The new Mesh
  69883. */
  69884. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69885. }
  69886. }
  69887. declare module BABYLON {
  69888. /**
  69889. * Class used to create a trail following a mesh
  69890. */
  69891. export class TrailMesh extends Mesh {
  69892. private _generator;
  69893. private _autoStart;
  69894. private _running;
  69895. private _diameter;
  69896. private _length;
  69897. private _sectionPolygonPointsCount;
  69898. private _sectionVectors;
  69899. private _sectionNormalVectors;
  69900. private _beforeRenderObserver;
  69901. /**
  69902. * @constructor
  69903. * @param name The value used by scene.getMeshByName() to do a lookup.
  69904. * @param generator The mesh or transform node to generate a trail.
  69905. * @param scene The scene to add this mesh to.
  69906. * @param diameter Diameter of trailing mesh. Default is 1.
  69907. * @param length Length of trailing mesh. Default is 60.
  69908. * @param autoStart Automatically start trailing mesh. Default true.
  69909. */
  69910. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69911. /**
  69912. * "TrailMesh"
  69913. * @returns "TrailMesh"
  69914. */
  69915. getClassName(): string;
  69916. private _createMesh;
  69917. /**
  69918. * Start trailing mesh.
  69919. */
  69920. start(): void;
  69921. /**
  69922. * Stop trailing mesh.
  69923. */
  69924. stop(): void;
  69925. /**
  69926. * Update trailing mesh geometry.
  69927. */
  69928. update(): void;
  69929. /**
  69930. * Returns a new TrailMesh object.
  69931. * @param name is a string, the name given to the new mesh
  69932. * @param newGenerator use new generator object for cloned trail mesh
  69933. * @returns a new mesh
  69934. */
  69935. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69936. /**
  69937. * Serializes this trail mesh
  69938. * @param serializationObject object to write serialization to
  69939. */
  69940. serialize(serializationObject: any): void;
  69941. /**
  69942. * Parses a serialized trail mesh
  69943. * @param parsedMesh the serialized mesh
  69944. * @param scene the scene to create the trail mesh in
  69945. * @returns the created trail mesh
  69946. */
  69947. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69948. }
  69949. }
  69950. declare module BABYLON {
  69951. /**
  69952. * Class containing static functions to help procedurally build meshes
  69953. */
  69954. export class TiledBoxBuilder {
  69955. /**
  69956. * Creates a box mesh
  69957. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  69958. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69960. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69962. * @param name defines the name of the mesh
  69963. * @param options defines the options used to create the mesh
  69964. * @param scene defines the hosting scene
  69965. * @returns the box mesh
  69966. */
  69967. static CreateTiledBox(name: string, options: {
  69968. pattern?: number;
  69969. width?: number;
  69970. height?: number;
  69971. depth?: number;
  69972. tileSize?: number;
  69973. tileWidth?: number;
  69974. tileHeight?: number;
  69975. alignHorizontal?: number;
  69976. alignVertical?: number;
  69977. faceUV?: Vector4[];
  69978. faceColors?: Color4[];
  69979. sideOrientation?: number;
  69980. updatable?: boolean;
  69981. }, scene?: Nullable<Scene>): Mesh;
  69982. }
  69983. }
  69984. declare module BABYLON {
  69985. /**
  69986. * Class containing static functions to help procedurally build meshes
  69987. */
  69988. export class TorusKnotBuilder {
  69989. /**
  69990. * Creates a torus knot mesh
  69991. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69992. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69993. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69994. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69996. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69998. * @param name defines the name of the mesh
  69999. * @param options defines the options used to create the mesh
  70000. * @param scene defines the hosting scene
  70001. * @returns the torus knot mesh
  70002. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70003. */
  70004. static CreateTorusKnot(name: string, options: {
  70005. radius?: number;
  70006. tube?: number;
  70007. radialSegments?: number;
  70008. tubularSegments?: number;
  70009. p?: number;
  70010. q?: number;
  70011. updatable?: boolean;
  70012. sideOrientation?: number;
  70013. frontUVs?: Vector4;
  70014. backUVs?: Vector4;
  70015. }, scene: any): Mesh;
  70016. }
  70017. }
  70018. declare module BABYLON {
  70019. /**
  70020. * Polygon
  70021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70022. */
  70023. export class Polygon {
  70024. /**
  70025. * Creates a rectangle
  70026. * @param xmin bottom X coord
  70027. * @param ymin bottom Y coord
  70028. * @param xmax top X coord
  70029. * @param ymax top Y coord
  70030. * @returns points that make the resulting rectangle
  70031. */
  70032. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70033. /**
  70034. * Creates a circle
  70035. * @param radius radius of circle
  70036. * @param cx scale in x
  70037. * @param cy scale in y
  70038. * @param numberOfSides number of sides that make up the circle
  70039. * @returns points that make the resulting circle
  70040. */
  70041. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70042. /**
  70043. * Creates a polygon from input string
  70044. * @param input Input polygon data
  70045. * @returns the parsed points
  70046. */
  70047. static Parse(input: string): Vector2[];
  70048. /**
  70049. * Starts building a polygon from x and y coordinates
  70050. * @param x x coordinate
  70051. * @param y y coordinate
  70052. * @returns the started path2
  70053. */
  70054. static StartingAt(x: number, y: number): Path2;
  70055. }
  70056. /**
  70057. * Builds a polygon
  70058. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70059. */
  70060. export class PolygonMeshBuilder {
  70061. private _points;
  70062. private _outlinepoints;
  70063. private _holes;
  70064. private _name;
  70065. private _scene;
  70066. private _epoints;
  70067. private _eholes;
  70068. private _addToepoint;
  70069. /**
  70070. * Babylon reference to the earcut plugin.
  70071. */
  70072. bjsEarcut: any;
  70073. /**
  70074. * Creates a PolygonMeshBuilder
  70075. * @param name name of the builder
  70076. * @param contours Path of the polygon
  70077. * @param scene scene to add to when creating the mesh
  70078. * @param earcutInjection can be used to inject your own earcut reference
  70079. */
  70080. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70081. /**
  70082. * Adds a hole within the polygon
  70083. * @param hole Array of points defining the hole
  70084. * @returns this
  70085. */
  70086. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70087. /**
  70088. * Creates the polygon
  70089. * @param updatable If the mesh should be updatable
  70090. * @param depth The depth of the mesh created
  70091. * @param smoothingThreshold Dot product threshold for smoothed normals
  70092. * @returns the created mesh
  70093. */
  70094. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  70095. /**
  70096. * Creates the polygon
  70097. * @param depth The depth of the mesh created
  70098. * @param smoothingThreshold Dot product threshold for smoothed normals
  70099. * @returns the created VertexData
  70100. */
  70101. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  70102. /**
  70103. * Adds a side to the polygon
  70104. * @param positions points that make the polygon
  70105. * @param normals normals of the polygon
  70106. * @param uvs uvs of the polygon
  70107. * @param indices indices of the polygon
  70108. * @param bounds bounds of the polygon
  70109. * @param points points of the polygon
  70110. * @param depth depth of the polygon
  70111. * @param flip flip of the polygon
  70112. */
  70113. private addSide;
  70114. }
  70115. }
  70116. declare module BABYLON {
  70117. /**
  70118. * Class containing static functions to help procedurally build meshes
  70119. */
  70120. export class PolygonBuilder {
  70121. /**
  70122. * Creates a polygon mesh
  70123. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70124. * * 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
  70125. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70127. * * 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)
  70128. * * Remember you can only change the shape positions, not their number when updating a polygon
  70129. * @param name defines the name of the mesh
  70130. * @param options defines the options used to create the mesh
  70131. * @param scene defines the hosting scene
  70132. * @param earcutInjection can be used to inject your own earcut reference
  70133. * @returns the polygon mesh
  70134. */
  70135. static CreatePolygon(name: string, options: {
  70136. shape: Vector3[];
  70137. holes?: Vector3[][];
  70138. depth?: number;
  70139. smoothingThreshold?: number;
  70140. faceUV?: Vector4[];
  70141. faceColors?: Color4[];
  70142. updatable?: boolean;
  70143. sideOrientation?: number;
  70144. frontUVs?: Vector4;
  70145. backUVs?: Vector4;
  70146. wrap?: boolean;
  70147. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70148. /**
  70149. * Creates an extruded polygon mesh, with depth in the Y direction.
  70150. * * 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)
  70151. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70152. * @param name defines the name of the mesh
  70153. * @param options defines the options used to create the mesh
  70154. * @param scene defines the hosting scene
  70155. * @param earcutInjection can be used to inject your own earcut reference
  70156. * @returns the polygon mesh
  70157. */
  70158. static ExtrudePolygon(name: string, options: {
  70159. shape: Vector3[];
  70160. holes?: Vector3[][];
  70161. depth?: number;
  70162. faceUV?: Vector4[];
  70163. faceColors?: Color4[];
  70164. updatable?: boolean;
  70165. sideOrientation?: number;
  70166. frontUVs?: Vector4;
  70167. backUVs?: Vector4;
  70168. wrap?: boolean;
  70169. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70170. }
  70171. }
  70172. declare module BABYLON {
  70173. /**
  70174. * Class containing static functions to help procedurally build meshes
  70175. */
  70176. export class LatheBuilder {
  70177. /**
  70178. * Creates lathe mesh.
  70179. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70180. * * 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
  70181. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70182. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70183. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70184. * * 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
  70185. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70186. * * 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
  70187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70188. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70189. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70191. * @param name defines the name of the mesh
  70192. * @param options defines the options used to create the mesh
  70193. * @param scene defines the hosting scene
  70194. * @returns the lathe mesh
  70195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70196. */
  70197. static CreateLathe(name: string, options: {
  70198. shape: Vector3[];
  70199. radius?: number;
  70200. tessellation?: number;
  70201. clip?: number;
  70202. arc?: number;
  70203. closed?: boolean;
  70204. updatable?: boolean;
  70205. sideOrientation?: number;
  70206. frontUVs?: Vector4;
  70207. backUVs?: Vector4;
  70208. cap?: number;
  70209. invertUV?: boolean;
  70210. }, scene?: Nullable<Scene>): Mesh;
  70211. }
  70212. }
  70213. declare module BABYLON {
  70214. /**
  70215. * Class containing static functions to help procedurally build meshes
  70216. */
  70217. export class TiledPlaneBuilder {
  70218. /**
  70219. * Creates a tiled plane mesh
  70220. * * The parameter `pattern` will, depending on value, do nothing or
  70221. * * * flip (reflect about central vertical) alternate tiles across and up
  70222. * * * flip every tile on alternate rows
  70223. * * * rotate (180 degs) alternate tiles across and up
  70224. * * * rotate every tile on alternate rows
  70225. * * * flip and rotate alternate tiles across and up
  70226. * * * flip and rotate every tile on alternate rows
  70227. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70228. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70229. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70230. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70231. * * 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)
  70232. * * 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)
  70233. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70234. * @param name defines the name of the mesh
  70235. * @param options defines the options used to create the mesh
  70236. * @param scene defines the hosting scene
  70237. * @returns the box mesh
  70238. */
  70239. static CreateTiledPlane(name: string, options: {
  70240. pattern?: number;
  70241. tileSize?: number;
  70242. tileWidth?: number;
  70243. tileHeight?: number;
  70244. size?: number;
  70245. width?: number;
  70246. height?: number;
  70247. alignHorizontal?: number;
  70248. alignVertical?: number;
  70249. sideOrientation?: number;
  70250. frontUVs?: Vector4;
  70251. backUVs?: Vector4;
  70252. updatable?: boolean;
  70253. }, scene?: Nullable<Scene>): Mesh;
  70254. }
  70255. }
  70256. declare module BABYLON {
  70257. /**
  70258. * Class containing static functions to help procedurally build meshes
  70259. */
  70260. export class TubeBuilder {
  70261. /**
  70262. * Creates a tube mesh.
  70263. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70264. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70265. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70266. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70267. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  70268. * * 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)
  70269. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70270. * * 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
  70271. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  70272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70273. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70274. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70276. * @param name defines the name of the mesh
  70277. * @param options defines the options used to create the mesh
  70278. * @param scene defines the hosting scene
  70279. * @returns the tube mesh
  70280. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70281. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70282. */
  70283. static CreateTube(name: string, options: {
  70284. path: Vector3[];
  70285. radius?: number;
  70286. tessellation?: number;
  70287. radiusFunction?: {
  70288. (i: number, distance: number): number;
  70289. };
  70290. cap?: number;
  70291. arc?: number;
  70292. updatable?: boolean;
  70293. sideOrientation?: number;
  70294. frontUVs?: Vector4;
  70295. backUVs?: Vector4;
  70296. instance?: Mesh;
  70297. invertUV?: boolean;
  70298. }, scene?: Nullable<Scene>): Mesh;
  70299. }
  70300. }
  70301. declare module BABYLON {
  70302. /**
  70303. * Class containing static functions to help procedurally build meshes
  70304. */
  70305. export class IcoSphereBuilder {
  70306. /**
  70307. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70308. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70309. * * 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`)
  70310. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70311. * * 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
  70312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70313. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70315. * @param name defines the name of the mesh
  70316. * @param options defines the options used to create the mesh
  70317. * @param scene defines the hosting scene
  70318. * @returns the icosahedron mesh
  70319. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70320. */
  70321. static CreateIcoSphere(name: string, options: {
  70322. radius?: number;
  70323. radiusX?: number;
  70324. radiusY?: number;
  70325. radiusZ?: number;
  70326. flat?: boolean;
  70327. subdivisions?: number;
  70328. sideOrientation?: number;
  70329. frontUVs?: Vector4;
  70330. backUVs?: Vector4;
  70331. updatable?: boolean;
  70332. }, scene?: Nullable<Scene>): Mesh;
  70333. }
  70334. }
  70335. declare module BABYLON {
  70336. /**
  70337. * Class containing static functions to help procedurally build meshes
  70338. */
  70339. export class DecalBuilder {
  70340. /**
  70341. * Creates a decal mesh.
  70342. * 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
  70343. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70344. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70345. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70346. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70347. * @param name defines the name of the mesh
  70348. * @param sourceMesh defines the mesh where the decal must be applied
  70349. * @param options defines the options used to create the mesh
  70350. * @param scene defines the hosting scene
  70351. * @returns the decal mesh
  70352. * @see https://doc.babylonjs.com/how_to/decals
  70353. */
  70354. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70355. position?: Vector3;
  70356. normal?: Vector3;
  70357. size?: Vector3;
  70358. angle?: number;
  70359. }): Mesh;
  70360. }
  70361. }
  70362. declare module BABYLON {
  70363. /**
  70364. * Class containing static functions to help procedurally build meshes
  70365. */
  70366. export class MeshBuilder {
  70367. /**
  70368. * Creates a box mesh
  70369. * * The parameter `size` sets the size (float) of each box side (default 1)
  70370. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70371. * * 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)
  70372. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70374. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70376. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70377. * @param name defines the name of the mesh
  70378. * @param options defines the options used to create the mesh
  70379. * @param scene defines the hosting scene
  70380. * @returns the box mesh
  70381. */
  70382. static CreateBox(name: string, options: {
  70383. size?: number;
  70384. width?: number;
  70385. height?: number;
  70386. depth?: number;
  70387. faceUV?: Vector4[];
  70388. faceColors?: Color4[];
  70389. sideOrientation?: number;
  70390. frontUVs?: Vector4;
  70391. backUVs?: Vector4;
  70392. wrap?: boolean;
  70393. topBaseAt?: number;
  70394. bottomBaseAt?: number;
  70395. updatable?: boolean;
  70396. }, scene?: Nullable<Scene>): Mesh;
  70397. /**
  70398. * Creates a tiled box mesh
  70399. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70401. * @param name defines the name of the mesh
  70402. * @param options defines the options used to create the mesh
  70403. * @param scene defines the hosting scene
  70404. * @returns the tiled box mesh
  70405. */
  70406. static CreateTiledBox(name: string, options: {
  70407. pattern?: number;
  70408. size?: number;
  70409. width?: number;
  70410. height?: number;
  70411. depth: number;
  70412. tileSize?: number;
  70413. tileWidth?: number;
  70414. tileHeight?: number;
  70415. faceUV?: Vector4[];
  70416. faceColors?: Color4[];
  70417. alignHorizontal?: number;
  70418. alignVertical?: number;
  70419. sideOrientation?: number;
  70420. updatable?: boolean;
  70421. }, scene?: Nullable<Scene>): Mesh;
  70422. /**
  70423. * Creates a sphere mesh
  70424. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70425. * * 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`)
  70426. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70427. * * 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
  70428. * * 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)
  70429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70430. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70432. * @param name defines the name of the mesh
  70433. * @param options defines the options used to create the mesh
  70434. * @param scene defines the hosting scene
  70435. * @returns the sphere mesh
  70436. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70437. */
  70438. static CreateSphere(name: string, options: {
  70439. segments?: number;
  70440. diameter?: number;
  70441. diameterX?: number;
  70442. diameterY?: number;
  70443. diameterZ?: number;
  70444. arc?: number;
  70445. slice?: number;
  70446. sideOrientation?: number;
  70447. frontUVs?: Vector4;
  70448. backUVs?: Vector4;
  70449. updatable?: boolean;
  70450. }, scene?: Nullable<Scene>): Mesh;
  70451. /**
  70452. * Creates a plane polygonal mesh. By default, this is a disc
  70453. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70454. * * 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
  70455. * * 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
  70456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70457. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70459. * @param name defines the name of the mesh
  70460. * @param options defines the options used to create the mesh
  70461. * @param scene defines the hosting scene
  70462. * @returns the plane polygonal mesh
  70463. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70464. */
  70465. static CreateDisc(name: string, options: {
  70466. radius?: number;
  70467. tessellation?: number;
  70468. arc?: number;
  70469. updatable?: boolean;
  70470. sideOrientation?: number;
  70471. frontUVs?: Vector4;
  70472. backUVs?: Vector4;
  70473. }, scene?: Nullable<Scene>): Mesh;
  70474. /**
  70475. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70476. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70477. * * 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`)
  70478. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70479. * * 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
  70480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70481. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70483. * @param name defines the name of the mesh
  70484. * @param options defines the options used to create the mesh
  70485. * @param scene defines the hosting scene
  70486. * @returns the icosahedron mesh
  70487. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70488. */
  70489. static CreateIcoSphere(name: string, options: {
  70490. radius?: number;
  70491. radiusX?: number;
  70492. radiusY?: number;
  70493. radiusZ?: number;
  70494. flat?: boolean;
  70495. subdivisions?: number;
  70496. sideOrientation?: number;
  70497. frontUVs?: Vector4;
  70498. backUVs?: Vector4;
  70499. updatable?: boolean;
  70500. }, scene?: Nullable<Scene>): Mesh;
  70501. /**
  70502. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70503. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70504. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70505. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70506. * * 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
  70507. * * 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
  70508. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  70509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70510. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70511. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70512. * * 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
  70513. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70514. * * 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
  70515. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70517. * @param name defines the name of the mesh
  70518. * @param options defines the options used to create the mesh
  70519. * @param scene defines the hosting scene
  70520. * @returns the ribbon mesh
  70521. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70522. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70523. */
  70524. static CreateRibbon(name: string, options: {
  70525. pathArray: Vector3[][];
  70526. closeArray?: boolean;
  70527. closePath?: boolean;
  70528. offset?: number;
  70529. updatable?: boolean;
  70530. sideOrientation?: number;
  70531. frontUVs?: Vector4;
  70532. backUVs?: Vector4;
  70533. instance?: Mesh;
  70534. invertUV?: boolean;
  70535. uvs?: Vector2[];
  70536. colors?: Color4[];
  70537. }, scene?: Nullable<Scene>): Mesh;
  70538. /**
  70539. * Creates a cylinder or a cone mesh
  70540. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70541. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70542. * * 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.
  70543. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70544. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70545. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70546. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70547. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  70548. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70549. * * 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).
  70550. * * 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
  70551. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70552. * * 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
  70553. * * 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.
  70554. * * If `enclose` is false, a ring surface is one element.
  70555. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70556. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  70557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70558. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70560. * @param name defines the name of the mesh
  70561. * @param options defines the options used to create the mesh
  70562. * @param scene defines the hosting scene
  70563. * @returns the cylinder mesh
  70564. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70565. */
  70566. static CreateCylinder(name: string, options: {
  70567. height?: number;
  70568. diameterTop?: number;
  70569. diameterBottom?: number;
  70570. diameter?: number;
  70571. tessellation?: number;
  70572. subdivisions?: number;
  70573. arc?: number;
  70574. faceColors?: Color4[];
  70575. faceUV?: Vector4[];
  70576. updatable?: boolean;
  70577. hasRings?: boolean;
  70578. enclose?: boolean;
  70579. cap?: number;
  70580. sideOrientation?: number;
  70581. frontUVs?: Vector4;
  70582. backUVs?: Vector4;
  70583. }, scene?: Nullable<Scene>): Mesh;
  70584. /**
  70585. * Creates a torus mesh
  70586. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70587. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70588. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  70589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70590. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70592. * @param name defines the name of the mesh
  70593. * @param options defines the options used to create the mesh
  70594. * @param scene defines the hosting scene
  70595. * @returns the torus mesh
  70596. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70597. */
  70598. static CreateTorus(name: string, options: {
  70599. diameter?: number;
  70600. thickness?: number;
  70601. tessellation?: number;
  70602. updatable?: boolean;
  70603. sideOrientation?: number;
  70604. frontUVs?: Vector4;
  70605. backUVs?: Vector4;
  70606. }, scene?: Nullable<Scene>): Mesh;
  70607. /**
  70608. * Creates a torus knot mesh
  70609. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70610. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70611. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70612. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70614. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70616. * @param name defines the name of the mesh
  70617. * @param options defines the options used to create the mesh
  70618. * @param scene defines the hosting scene
  70619. * @returns the torus knot mesh
  70620. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70621. */
  70622. static CreateTorusKnot(name: string, options: {
  70623. radius?: number;
  70624. tube?: number;
  70625. radialSegments?: number;
  70626. tubularSegments?: number;
  70627. p?: number;
  70628. q?: number;
  70629. updatable?: boolean;
  70630. sideOrientation?: number;
  70631. frontUVs?: Vector4;
  70632. backUVs?: Vector4;
  70633. }, scene?: Nullable<Scene>): Mesh;
  70634. /**
  70635. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70636. * * 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
  70637. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70638. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70639. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70640. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70641. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70642. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  70643. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70646. * @param name defines the name of the new line system
  70647. * @param options defines the options used to create the line system
  70648. * @param scene defines the hosting scene
  70649. * @returns a new line system mesh
  70650. */
  70651. static CreateLineSystem(name: string, options: {
  70652. lines: Vector3[][];
  70653. updatable?: boolean;
  70654. instance?: Nullable<LinesMesh>;
  70655. colors?: Nullable<Color4[][]>;
  70656. useVertexAlpha?: boolean;
  70657. }, scene: Nullable<Scene>): LinesMesh;
  70658. /**
  70659. * Creates a line mesh
  70660. * 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
  70661. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70662. * * The parameter `points` is an array successive Vector3
  70663. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  70664. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70665. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70666. * * When updating an instance, remember that only point positions can change, not the number of points
  70667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70669. * @param name defines the name of the new line system
  70670. * @param options defines the options used to create the line system
  70671. * @param scene defines the hosting scene
  70672. * @returns a new line mesh
  70673. */
  70674. static CreateLines(name: string, options: {
  70675. points: Vector3[];
  70676. updatable?: boolean;
  70677. instance?: Nullable<LinesMesh>;
  70678. colors?: Color4[];
  70679. useVertexAlpha?: boolean;
  70680. }, scene?: Nullable<Scene>): LinesMesh;
  70681. /**
  70682. * Creates a dashed line mesh
  70683. * * 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
  70684. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70685. * * The parameter `points` is an array successive Vector3
  70686. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70687. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70688. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70689. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  70690. * * When updating an instance, remember that only point positions can change, not the number of points
  70691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70692. * @param name defines the name of the mesh
  70693. * @param options defines the options used to create the mesh
  70694. * @param scene defines the hosting scene
  70695. * @returns the dashed line mesh
  70696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70697. */
  70698. static CreateDashedLines(name: string, options: {
  70699. points: Vector3[];
  70700. dashSize?: number;
  70701. gapSize?: number;
  70702. dashNb?: number;
  70703. updatable?: boolean;
  70704. instance?: LinesMesh;
  70705. }, scene?: Nullable<Scene>): LinesMesh;
  70706. /**
  70707. * 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.
  70708. * * 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.
  70709. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70710. * * 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.
  70711. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70712. * * 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
  70713. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  70714. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70716. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70717. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70719. * @param name defines the name of the mesh
  70720. * @param options defines the options used to create the mesh
  70721. * @param scene defines the hosting scene
  70722. * @returns the extruded shape mesh
  70723. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70724. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70725. */
  70726. static ExtrudeShape(name: string, options: {
  70727. shape: Vector3[];
  70728. path: Vector3[];
  70729. scale?: number;
  70730. rotation?: number;
  70731. cap?: number;
  70732. updatable?: boolean;
  70733. sideOrientation?: number;
  70734. frontUVs?: Vector4;
  70735. backUVs?: Vector4;
  70736. instance?: Mesh;
  70737. invertUV?: boolean;
  70738. }, scene?: Nullable<Scene>): Mesh;
  70739. /**
  70740. * Creates an custom extruded shape mesh.
  70741. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70742. * * 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.
  70743. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70744. * * 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 beginning of the path
  70745. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70746. * * 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
  70747. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70748. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70749. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70750. * * 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
  70751. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  70752. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70754. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70755. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70757. * @param name defines the name of the mesh
  70758. * @param options defines the options used to create the mesh
  70759. * @param scene defines the hosting scene
  70760. * @returns the custom extruded shape mesh
  70761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70762. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70764. */
  70765. static ExtrudeShapeCustom(name: string, options: {
  70766. shape: Vector3[];
  70767. path: Vector3[];
  70768. scaleFunction?: any;
  70769. rotationFunction?: any;
  70770. ribbonCloseArray?: boolean;
  70771. ribbonClosePath?: boolean;
  70772. cap?: number;
  70773. updatable?: boolean;
  70774. sideOrientation?: number;
  70775. frontUVs?: Vector4;
  70776. backUVs?: Vector4;
  70777. instance?: Mesh;
  70778. invertUV?: boolean;
  70779. }, scene?: Nullable<Scene>): Mesh;
  70780. /**
  70781. * Creates lathe mesh.
  70782. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70783. * * 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
  70784. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70785. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70786. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70787. * * 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
  70788. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70789. * * 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
  70790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70791. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70792. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70794. * @param name defines the name of the mesh
  70795. * @param options defines the options used to create the mesh
  70796. * @param scene defines the hosting scene
  70797. * @returns the lathe mesh
  70798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70799. */
  70800. static CreateLathe(name: string, options: {
  70801. shape: Vector3[];
  70802. radius?: number;
  70803. tessellation?: number;
  70804. clip?: number;
  70805. arc?: number;
  70806. closed?: boolean;
  70807. updatable?: boolean;
  70808. sideOrientation?: number;
  70809. frontUVs?: Vector4;
  70810. backUVs?: Vector4;
  70811. cap?: number;
  70812. invertUV?: boolean;
  70813. }, scene?: Nullable<Scene>): Mesh;
  70814. /**
  70815. * Creates a tiled plane mesh
  70816. * * You can set a limited pattern arrangement with the tiles
  70817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70818. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70820. * @param name defines the name of the mesh
  70821. * @param options defines the options used to create the mesh
  70822. * @param scene defines the hosting scene
  70823. * @returns the plane mesh
  70824. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70825. */
  70826. static CreateTiledPlane(name: string, options: {
  70827. pattern?: number;
  70828. tileSize?: number;
  70829. tileWidth?: number;
  70830. tileHeight?: number;
  70831. size?: number;
  70832. width?: number;
  70833. height?: number;
  70834. alignHorizontal?: number;
  70835. alignVertical?: number;
  70836. sideOrientation?: number;
  70837. frontUVs?: Vector4;
  70838. backUVs?: Vector4;
  70839. updatable?: boolean;
  70840. }, scene?: Nullable<Scene>): Mesh;
  70841. /**
  70842. * Creates a plane mesh
  70843. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70844. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70845. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70847. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70849. * @param name defines the name of the mesh
  70850. * @param options defines the options used to create the mesh
  70851. * @param scene defines the hosting scene
  70852. * @returns the plane mesh
  70853. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70854. */
  70855. static CreatePlane(name: string, options: {
  70856. size?: number;
  70857. width?: number;
  70858. height?: number;
  70859. sideOrientation?: number;
  70860. frontUVs?: Vector4;
  70861. backUVs?: Vector4;
  70862. updatable?: boolean;
  70863. sourcePlane?: Plane;
  70864. }, scene?: Nullable<Scene>): Mesh;
  70865. /**
  70866. * Creates a ground mesh
  70867. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70868. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70870. * @param name defines the name of the mesh
  70871. * @param options defines the options used to create the mesh
  70872. * @param scene defines the hosting scene
  70873. * @returns the ground mesh
  70874. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70875. */
  70876. static CreateGround(name: string, options: {
  70877. width?: number;
  70878. height?: number;
  70879. subdivisions?: number;
  70880. subdivisionsX?: number;
  70881. subdivisionsY?: number;
  70882. updatable?: boolean;
  70883. }, scene?: Nullable<Scene>): Mesh;
  70884. /**
  70885. * Creates a tiled ground mesh
  70886. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70887. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70888. * * 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
  70889. * * 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
  70890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70891. * @param name defines the name of the mesh
  70892. * @param options defines the options used to create the mesh
  70893. * @param scene defines the hosting scene
  70894. * @returns the tiled ground mesh
  70895. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70896. */
  70897. static CreateTiledGround(name: string, options: {
  70898. xmin: number;
  70899. zmin: number;
  70900. xmax: number;
  70901. zmax: number;
  70902. subdivisions?: {
  70903. w: number;
  70904. h: number;
  70905. };
  70906. precision?: {
  70907. w: number;
  70908. h: number;
  70909. };
  70910. updatable?: boolean;
  70911. }, scene?: Nullable<Scene>): Mesh;
  70912. /**
  70913. * Creates a ground mesh from a height map
  70914. * * The parameter `url` sets the URL of the height map image resource.
  70915. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70916. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70917. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70918. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70919. * * 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.
  70920. * * 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).
  70921. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70923. * @param name defines the name of the mesh
  70924. * @param url defines the url to the height map
  70925. * @param options defines the options used to create the mesh
  70926. * @param scene defines the hosting scene
  70927. * @returns the ground mesh
  70928. * @see https://doc.babylonjs.com/babylon101/height_map
  70929. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70930. */
  70931. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70932. width?: number;
  70933. height?: number;
  70934. subdivisions?: number;
  70935. minHeight?: number;
  70936. maxHeight?: number;
  70937. colorFilter?: Color3;
  70938. alphaFilter?: number;
  70939. updatable?: boolean;
  70940. onReady?: (mesh: GroundMesh) => void;
  70941. }, scene?: Nullable<Scene>): GroundMesh;
  70942. /**
  70943. * Creates a polygon mesh
  70944. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70945. * * 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
  70946. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70948. * * 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)
  70949. * * Remember you can only change the shape positions, not their number when updating a polygon
  70950. * @param name defines the name of the mesh
  70951. * @param options defines the options used to create the mesh
  70952. * @param scene defines the hosting scene
  70953. * @param earcutInjection can be used to inject your own earcut reference
  70954. * @returns the polygon mesh
  70955. */
  70956. static CreatePolygon(name: string, options: {
  70957. shape: Vector3[];
  70958. holes?: Vector3[][];
  70959. depth?: number;
  70960. faceUV?: Vector4[];
  70961. faceColors?: Color4[];
  70962. updatable?: boolean;
  70963. sideOrientation?: number;
  70964. frontUVs?: Vector4;
  70965. backUVs?: Vector4;
  70966. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70967. /**
  70968. * Creates an extruded polygon mesh, with depth in the Y direction.
  70969. * * 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)
  70970. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70971. * @param name defines the name of the mesh
  70972. * @param options defines the options used to create the mesh
  70973. * @param scene defines the hosting scene
  70974. * @param earcutInjection can be used to inject your own earcut reference
  70975. * @returns the polygon mesh
  70976. */
  70977. static ExtrudePolygon(name: string, options: {
  70978. shape: Vector3[];
  70979. holes?: Vector3[][];
  70980. depth?: number;
  70981. faceUV?: Vector4[];
  70982. faceColors?: Color4[];
  70983. updatable?: boolean;
  70984. sideOrientation?: number;
  70985. frontUVs?: Vector4;
  70986. backUVs?: Vector4;
  70987. wrap?: boolean;
  70988. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70989. /**
  70990. * Creates a tube mesh.
  70991. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70992. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70993. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70994. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70995. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  70996. * * 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)
  70997. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70998. * * 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
  70999. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  71000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71001. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71002. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71004. * @param name defines the name of the mesh
  71005. * @param options defines the options used to create the mesh
  71006. * @param scene defines the hosting scene
  71007. * @returns the tube mesh
  71008. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71009. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71010. */
  71011. static CreateTube(name: string, options: {
  71012. path: Vector3[];
  71013. radius?: number;
  71014. tessellation?: number;
  71015. radiusFunction?: {
  71016. (i: number, distance: number): number;
  71017. };
  71018. cap?: number;
  71019. arc?: number;
  71020. updatable?: boolean;
  71021. sideOrientation?: number;
  71022. frontUVs?: Vector4;
  71023. backUVs?: Vector4;
  71024. instance?: Mesh;
  71025. invertUV?: boolean;
  71026. }, scene?: Nullable<Scene>): Mesh;
  71027. /**
  71028. * Creates a polyhedron mesh
  71029. * * 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
  71030. * * The parameter `size` (positive float, default 1) sets the polygon size
  71031. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71032. * * 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`
  71033. * * 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
  71034. * * 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)`)
  71035. * * 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 : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  71036. * * 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
  71037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71038. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71040. * @param name defines the name of the mesh
  71041. * @param options defines the options used to create the mesh
  71042. * @param scene defines the hosting scene
  71043. * @returns the polyhedron mesh
  71044. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71045. */
  71046. static CreatePolyhedron(name: string, options: {
  71047. type?: number;
  71048. size?: number;
  71049. sizeX?: number;
  71050. sizeY?: number;
  71051. sizeZ?: number;
  71052. custom?: any;
  71053. faceUV?: Vector4[];
  71054. faceColors?: Color4[];
  71055. flat?: boolean;
  71056. updatable?: boolean;
  71057. sideOrientation?: number;
  71058. frontUVs?: Vector4;
  71059. backUVs?: Vector4;
  71060. }, scene?: Nullable<Scene>): Mesh;
  71061. /**
  71062. * Creates a decal mesh.
  71063. * 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
  71064. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71065. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71066. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71067. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71068. * @param name defines the name of the mesh
  71069. * @param sourceMesh defines the mesh where the decal must be applied
  71070. * @param options defines the options used to create the mesh
  71071. * @param scene defines the hosting scene
  71072. * @returns the decal mesh
  71073. * @see https://doc.babylonjs.com/how_to/decals
  71074. */
  71075. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71076. position?: Vector3;
  71077. normal?: Vector3;
  71078. size?: Vector3;
  71079. angle?: number;
  71080. }): Mesh;
  71081. /**
  71082. * Creates a Capsule Mesh
  71083. * @param name defines the name of the mesh.
  71084. * @param options the constructors options used to shape the mesh.
  71085. * @param scene defines the scene the mesh is scoped to.
  71086. * @returns the capsule mesh
  71087. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71088. */
  71089. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71090. }
  71091. }
  71092. declare module BABYLON {
  71093. /**
  71094. * A simplifier interface for future simplification implementations
  71095. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71096. */
  71097. export interface ISimplifier {
  71098. /**
  71099. * Simplification of a given mesh according to the given settings.
  71100. * Since this requires computation, it is assumed that the function runs async.
  71101. * @param settings The settings of the simplification, including quality and distance
  71102. * @param successCallback A callback that will be called after the mesh was simplified.
  71103. * @param errorCallback in case of an error, this callback will be called. optional.
  71104. */
  71105. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71106. }
  71107. /**
  71108. * Expected simplification settings.
  71109. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71110. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71111. */
  71112. export interface ISimplificationSettings {
  71113. /**
  71114. * Gets or sets the expected quality
  71115. */
  71116. quality: number;
  71117. /**
  71118. * Gets or sets the distance when this optimized version should be used
  71119. */
  71120. distance: number;
  71121. /**
  71122. * Gets an already optimized mesh
  71123. */
  71124. optimizeMesh?: boolean;
  71125. }
  71126. /**
  71127. * Class used to specify simplification options
  71128. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71129. */
  71130. export class SimplificationSettings implements ISimplificationSettings {
  71131. /** expected quality */
  71132. quality: number;
  71133. /** distance when this optimized version should be used */
  71134. distance: number;
  71135. /** already optimized mesh */
  71136. optimizeMesh?: boolean | undefined;
  71137. /**
  71138. * Creates a SimplificationSettings
  71139. * @param quality expected quality
  71140. * @param distance distance when this optimized version should be used
  71141. * @param optimizeMesh already optimized mesh
  71142. */
  71143. constructor(
  71144. /** expected quality */
  71145. quality: number,
  71146. /** distance when this optimized version should be used */
  71147. distance: number,
  71148. /** already optimized mesh */
  71149. optimizeMesh?: boolean | undefined);
  71150. }
  71151. /**
  71152. * Interface used to define a simplification task
  71153. */
  71154. export interface ISimplificationTask {
  71155. /**
  71156. * Array of settings
  71157. */
  71158. settings: Array<ISimplificationSettings>;
  71159. /**
  71160. * Simplification type
  71161. */
  71162. simplificationType: SimplificationType;
  71163. /**
  71164. * Mesh to simplify
  71165. */
  71166. mesh: Mesh;
  71167. /**
  71168. * Callback called on success
  71169. */
  71170. successCallback?: () => void;
  71171. /**
  71172. * Defines if parallel processing can be used
  71173. */
  71174. parallelProcessing: boolean;
  71175. }
  71176. /**
  71177. * Queue used to order the simplification tasks
  71178. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71179. */
  71180. export class SimplificationQueue {
  71181. private _simplificationArray;
  71182. /**
  71183. * Gets a boolean indicating that the process is still running
  71184. */
  71185. running: boolean;
  71186. /**
  71187. * Creates a new queue
  71188. */
  71189. constructor();
  71190. /**
  71191. * Adds a new simplification task
  71192. * @param task defines a task to add
  71193. */
  71194. addTask(task: ISimplificationTask): void;
  71195. /**
  71196. * Execute next task
  71197. */
  71198. executeNext(): void;
  71199. /**
  71200. * Execute a simplification task
  71201. * @param task defines the task to run
  71202. */
  71203. runSimplification(task: ISimplificationTask): void;
  71204. private getSimplifier;
  71205. }
  71206. /**
  71207. * The implemented types of simplification
  71208. * At the moment only Quadratic Error Decimation is implemented
  71209. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71210. */
  71211. export enum SimplificationType {
  71212. /** Quadratic error decimation */
  71213. QUADRATIC = 0
  71214. }
  71215. /**
  71216. * An implementation of the Quadratic Error simplification algorithm.
  71217. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71218. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71219. * @author RaananW
  71220. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71221. */
  71222. export class QuadraticErrorSimplification implements ISimplifier {
  71223. private _mesh;
  71224. private triangles;
  71225. private vertices;
  71226. private references;
  71227. private _reconstructedMesh;
  71228. /** Gets or sets the number pf sync iterations */
  71229. syncIterations: number;
  71230. /** Gets or sets the aggressiveness of the simplifier */
  71231. aggressiveness: number;
  71232. /** Gets or sets the number of allowed iterations for decimation */
  71233. decimationIterations: number;
  71234. /** Gets or sets the espilon to use for bounding box computation */
  71235. boundingBoxEpsilon: number;
  71236. /**
  71237. * Creates a new QuadraticErrorSimplification
  71238. * @param _mesh defines the target mesh
  71239. */
  71240. constructor(_mesh: Mesh);
  71241. /**
  71242. * Simplification of a given mesh according to the given settings.
  71243. * Since this requires computation, it is assumed that the function runs async.
  71244. * @param settings The settings of the simplification, including quality and distance
  71245. * @param successCallback A callback that will be called after the mesh was simplified.
  71246. */
  71247. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71248. private runDecimation;
  71249. private initWithMesh;
  71250. private init;
  71251. private reconstructMesh;
  71252. private initDecimatedMesh;
  71253. private isFlipped;
  71254. private updateTriangles;
  71255. private identifyBorder;
  71256. private updateMesh;
  71257. private vertexError;
  71258. private calculateError;
  71259. }
  71260. }
  71261. declare module BABYLON {
  71262. interface Scene {
  71263. /** @hidden (Backing field) */
  71264. _simplificationQueue: SimplificationQueue;
  71265. /**
  71266. * Gets or sets the simplification queue attached to the scene
  71267. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71268. */
  71269. simplificationQueue: SimplificationQueue;
  71270. }
  71271. interface Mesh {
  71272. /**
  71273. * Simplify the mesh according to the given array of settings.
  71274. * Function will return immediately and will simplify async
  71275. * @param settings a collection of simplification settings
  71276. * @param parallelProcessing should all levels calculate parallel or one after the other
  71277. * @param simplificationType the type of simplification to run
  71278. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71279. * @returns the current mesh
  71280. */
  71281. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71282. }
  71283. /**
  71284. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71285. * created in a scene
  71286. */
  71287. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71288. /**
  71289. * The component name helpfull to identify the component in the list of scene components.
  71290. */
  71291. readonly name: string;
  71292. /**
  71293. * The scene the component belongs to.
  71294. */
  71295. scene: Scene;
  71296. /**
  71297. * Creates a new instance of the component for the given scene
  71298. * @param scene Defines the scene to register the component in
  71299. */
  71300. constructor(scene: Scene);
  71301. /**
  71302. * Registers the component in a given scene
  71303. */
  71304. register(): void;
  71305. /**
  71306. * Rebuilds the elements related to this component in case of
  71307. * context lost for instance.
  71308. */
  71309. rebuild(): void;
  71310. /**
  71311. * Disposes the component and the associated resources
  71312. */
  71313. dispose(): void;
  71314. private _beforeCameraUpdate;
  71315. }
  71316. }
  71317. declare module BABYLON {
  71318. interface Mesh {
  71319. /**
  71320. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71321. */
  71322. thinInstanceEnablePicking: boolean;
  71323. /**
  71324. * Creates a new thin instance
  71325. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71326. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  71327. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71328. */
  71329. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71330. /**
  71331. * Adds the transformation (matrix) of the current mesh as a thin instance
  71332. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  71333. * @returns the thin instance index number
  71334. */
  71335. thinInstanceAddSelf(refresh: boolean): number;
  71336. /**
  71337. * Registers a custom attribute to be used with thin instances
  71338. * @param kind name of the attribute
  71339. * @param stride size in floats of the attribute
  71340. */
  71341. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71342. /**
  71343. * Sets the matrix of a thin instance
  71344. * @param index index of the thin instance
  71345. * @param matrix matrix to set
  71346. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  71347. */
  71348. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71349. /**
  71350. * Sets the value of a custom attribute for a thin instance
  71351. * @param kind name of the attribute
  71352. * @param index index of the thin instance
  71353. * @param value value to set
  71354. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  71355. */
  71356. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71357. /**
  71358. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  71359. */
  71360. thinInstanceCount: number;
  71361. /**
  71362. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71363. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71364. * @param buffer buffer to set
  71365. * @param stride size in floats of each value of the buffer
  71366. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71367. */
  71368. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71369. /**
  71370. * Gets the list of world matrices
  71371. * @return an array containing all the world matrices from the thin instances
  71372. */
  71373. thinInstanceGetWorldMatrices(): Matrix[];
  71374. /**
  71375. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71376. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71377. */
  71378. thinInstanceBufferUpdated(kind: string): void;
  71379. /**
  71380. * Applies a partial update to a buffer directly on the GPU
  71381. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  71382. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71383. * @param data the data to set in the GPU buffer
  71384. * @param offset the offset in the GPU buffer where to update the data
  71385. */
  71386. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71387. /**
  71388. * Refreshes the bounding info, taking into account all the thin instances defined
  71389. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71390. */
  71391. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71392. /** @hidden */
  71393. _thinInstanceInitializeUserStorage(): void;
  71394. /** @hidden */
  71395. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71396. /** @hidden */
  71397. _userThinInstanceBuffersStorage: {
  71398. data: {
  71399. [key: string]: Float32Array;
  71400. };
  71401. sizes: {
  71402. [key: string]: number;
  71403. };
  71404. vertexBuffers: {
  71405. [key: string]: Nullable<VertexBuffer>;
  71406. };
  71407. strides: {
  71408. [key: string]: number;
  71409. };
  71410. };
  71411. }
  71412. }
  71413. declare module BABYLON {
  71414. /**
  71415. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71416. */
  71417. export interface INavigationEnginePlugin {
  71418. /**
  71419. * plugin name
  71420. */
  71421. name: string;
  71422. /**
  71423. * Creates a navigation mesh
  71424. * @param meshes array of all the geometry used to compute the navigation mesh
  71425. * @param parameters bunch of parameters used to filter geometry
  71426. */
  71427. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71428. /**
  71429. * Create a navigation mesh debug mesh
  71430. * @param scene is where the mesh will be added
  71431. * @returns debug display mesh
  71432. */
  71433. createDebugNavMesh(scene: Scene): Mesh;
  71434. /**
  71435. * Get a navigation mesh constrained position, closest to the parameter position
  71436. * @param position world position
  71437. * @returns the closest point to position constrained by the navigation mesh
  71438. */
  71439. getClosestPoint(position: Vector3): Vector3;
  71440. /**
  71441. * Get a navigation mesh constrained position, closest to the parameter position
  71442. * @param position world position
  71443. * @param result output the closest point to position constrained by the navigation mesh
  71444. */
  71445. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71446. /**
  71447. * Get a navigation mesh constrained position, within a particular radius
  71448. * @param position world position
  71449. * @param maxRadius the maximum distance to the constrained world position
  71450. * @returns the closest point to position constrained by the navigation mesh
  71451. */
  71452. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71453. /**
  71454. * Get a navigation mesh constrained position, within a particular radius
  71455. * @param position world position
  71456. * @param maxRadius the maximum distance to the constrained world position
  71457. * @param result output the closest point to position constrained by the navigation mesh
  71458. */
  71459. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71460. /**
  71461. * Compute the final position from a segment made of destination-position
  71462. * @param position world position
  71463. * @param destination world position
  71464. * @returns the resulting point along the navmesh
  71465. */
  71466. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71467. /**
  71468. * Compute the final position from a segment made of destination-position
  71469. * @param position world position
  71470. * @param destination world position
  71471. * @param result output the resulting point along the navmesh
  71472. */
  71473. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71474. /**
  71475. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71476. * @param start world position
  71477. * @param end world position
  71478. * @returns array containing world position composing the path
  71479. */
  71480. computePath(start: Vector3, end: Vector3): Vector3[];
  71481. /**
  71482. * If this plugin is supported
  71483. * @returns true if plugin is supported
  71484. */
  71485. isSupported(): boolean;
  71486. /**
  71487. * Create a new Crowd so you can add agents
  71488. * @param maxAgents the maximum agent count in the crowd
  71489. * @param maxAgentRadius the maximum radius an agent can have
  71490. * @param scene to attach the crowd to
  71491. * @returns the crowd you can add agents to
  71492. */
  71493. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71494. /**
  71495. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71496. * The queries will try to find a solution within those bounds
  71497. * default is (1,1,1)
  71498. * @param extent x,y,z value that define the extent around the queries point of reference
  71499. */
  71500. setDefaultQueryExtent(extent: Vector3): void;
  71501. /**
  71502. * Get the Bounding box extent specified by setDefaultQueryExtent
  71503. * @returns the box extent values
  71504. */
  71505. getDefaultQueryExtent(): Vector3;
  71506. /**
  71507. * build the navmesh from a previously saved state using getNavmeshData
  71508. * @param data the Uint8Array returned by getNavmeshData
  71509. */
  71510. buildFromNavmeshData(data: Uint8Array): void;
  71511. /**
  71512. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71513. * @returns data the Uint8Array that can be saved and reused
  71514. */
  71515. getNavmeshData(): Uint8Array;
  71516. /**
  71517. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71518. * @param result output the box extent values
  71519. */
  71520. getDefaultQueryExtentToRef(result: Vector3): void;
  71521. /**
  71522. * Set the time step of the navigation tick update.
  71523. * Default is 1/60.
  71524. * A value of 0 will disable fixed time update
  71525. * @param newTimeStep the new timestep to apply to this world.
  71526. */
  71527. setTimeStep(newTimeStep: number): void;
  71528. /**
  71529. * Get the time step of the navigation tick update.
  71530. * @returns the current time step
  71531. */
  71532. getTimeStep(): number;
  71533. /**
  71534. * If delta time in navigation tick update is greater than the time step
  71535. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71536. * they will be discarded.
  71537. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71538. * @param newStepCount the maximum number of iterations
  71539. */
  71540. setMaximumSubStepCount(newStepCount: number): void;
  71541. /**
  71542. * Get the maximum number of iterations per navigation tick update
  71543. * @returns the maximum number of iterations
  71544. */
  71545. getMaximumSubStepCount(): number;
  71546. /**
  71547. * Release all resources
  71548. */
  71549. dispose(): void;
  71550. }
  71551. /**
  71552. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71553. */
  71554. export interface ICrowd {
  71555. /**
  71556. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71557. * You can attach anything to that node. The node position is updated in the scene update tick.
  71558. * @param pos world position that will be constrained by the navigation mesh
  71559. * @param parameters agent parameters
  71560. * @param transform hooked to the agent that will be update by the scene
  71561. * @returns agent index
  71562. */
  71563. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71564. /**
  71565. * Returns the agent position in world space
  71566. * @param index agent index returned by addAgent
  71567. * @returns world space position
  71568. */
  71569. getAgentPosition(index: number): Vector3;
  71570. /**
  71571. * Gets the agent position result in world space
  71572. * @param index agent index returned by addAgent
  71573. * @param result output world space position
  71574. */
  71575. getAgentPositionToRef(index: number, result: Vector3): void;
  71576. /**
  71577. * Gets the agent velocity in world space
  71578. * @param index agent index returned by addAgent
  71579. * @returns world space velocity
  71580. */
  71581. getAgentVelocity(index: number): Vector3;
  71582. /**
  71583. * Gets the agent velocity result in world space
  71584. * @param index agent index returned by addAgent
  71585. * @param result output world space velocity
  71586. */
  71587. getAgentVelocityToRef(index: number, result: Vector3): void;
  71588. /**
  71589. * Gets the agent next target point on the path
  71590. * @param index agent index returned by addAgent
  71591. * @returns world space position
  71592. */
  71593. getAgentNextTargetPath(index: number): Vector3;
  71594. /**
  71595. * Gets the agent state
  71596. * @param index agent index returned by addAgent
  71597. * @returns agent state
  71598. */
  71599. getAgentState(index: number): number;
  71600. /**
  71601. * returns true if the agent in over an off mesh link connection
  71602. * @param index agent index returned by addAgent
  71603. * @returns true if over an off mesh link connection
  71604. */
  71605. overOffmeshConnection(index: number): boolean;
  71606. /**
  71607. * Gets the agent next target point on the path
  71608. * @param index agent index returned by addAgent
  71609. * @param result output world space position
  71610. */
  71611. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71612. /**
  71613. * remove a particular agent previously created
  71614. * @param index agent index returned by addAgent
  71615. */
  71616. removeAgent(index: number): void;
  71617. /**
  71618. * get the list of all agents attached to this crowd
  71619. * @returns list of agent indices
  71620. */
  71621. getAgents(): number[];
  71622. /**
  71623. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71624. * @param deltaTime in seconds
  71625. */
  71626. update(deltaTime: number): void;
  71627. /**
  71628. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71629. * @param index agent index returned by addAgent
  71630. * @param destination targeted world position
  71631. */
  71632. agentGoto(index: number, destination: Vector3): void;
  71633. /**
  71634. * Teleport the agent to a new position
  71635. * @param index agent index returned by addAgent
  71636. * @param destination targeted world position
  71637. */
  71638. agentTeleport(index: number, destination: Vector3): void;
  71639. /**
  71640. * Update agent parameters
  71641. * @param index agent index returned by addAgent
  71642. * @param parameters agent parameters
  71643. */
  71644. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71645. /**
  71646. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71647. * The queries will try to find a solution within those bounds
  71648. * default is (1,1,1)
  71649. * @param extent x,y,z value that define the extent around the queries point of reference
  71650. */
  71651. setDefaultQueryExtent(extent: Vector3): void;
  71652. /**
  71653. * Get the Bounding box extent specified by setDefaultQueryExtent
  71654. * @returns the box extent values
  71655. */
  71656. getDefaultQueryExtent(): Vector3;
  71657. /**
  71658. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71659. * @param result output the box extent values
  71660. */
  71661. getDefaultQueryExtentToRef(result: Vector3): void;
  71662. /**
  71663. * Release all resources
  71664. */
  71665. dispose(): void;
  71666. }
  71667. /**
  71668. * Configures an agent
  71669. */
  71670. export interface IAgentParameters {
  71671. /**
  71672. * Agent radius. [Limit: >= 0]
  71673. */
  71674. radius: number;
  71675. /**
  71676. * Agent height. [Limit: > 0]
  71677. */
  71678. height: number;
  71679. /**
  71680. * Maximum allowed acceleration. [Limit: >= 0]
  71681. */
  71682. maxAcceleration: number;
  71683. /**
  71684. * Maximum allowed speed. [Limit: >= 0]
  71685. */
  71686. maxSpeed: number;
  71687. /**
  71688. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71689. */
  71690. collisionQueryRange: number;
  71691. /**
  71692. * The path visibility optimization range. [Limit: > 0]
  71693. */
  71694. pathOptimizationRange: number;
  71695. /**
  71696. * How aggressive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71697. */
  71698. separationWeight: number;
  71699. }
  71700. /**
  71701. * Configures the navigation mesh creation
  71702. */
  71703. export interface INavMeshParameters {
  71704. /**
  71705. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71706. */
  71707. cs: number;
  71708. /**
  71709. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71710. */
  71711. ch: number;
  71712. /**
  71713. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71714. */
  71715. walkableSlopeAngle: number;
  71716. /**
  71717. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71718. * be considered walkable. [Limit: >= 3] [Units: vx]
  71719. */
  71720. walkableHeight: number;
  71721. /**
  71722. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71723. */
  71724. walkableClimb: number;
  71725. /**
  71726. * The distance to erode/shrink the walkable area of the heightfield away from
  71727. * obstructions. [Limit: >=0] [Units: vx]
  71728. */
  71729. walkableRadius: number;
  71730. /**
  71731. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71732. */
  71733. maxEdgeLen: number;
  71734. /**
  71735. * The maximum distance a simplified contour's border edges should deviate
  71736. * the original raw contour. [Limit: >=0] [Units: vx]
  71737. */
  71738. maxSimplificationError: number;
  71739. /**
  71740. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71741. */
  71742. minRegionArea: number;
  71743. /**
  71744. * Any regions with a span count smaller than this value will, if possible,
  71745. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71746. */
  71747. mergeRegionArea: number;
  71748. /**
  71749. * The maximum number of vertices allowed for polygons generated during the
  71750. * contour to polygon conversion process. [Limit: >= 3]
  71751. */
  71752. maxVertsPerPoly: number;
  71753. /**
  71754. * Sets the sampling distance to use when generating the detail mesh.
  71755. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71756. */
  71757. detailSampleDist: number;
  71758. /**
  71759. * The maximum distance the detail mesh surface should deviate from heightfield
  71760. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71761. */
  71762. detailSampleMaxError: number;
  71763. }
  71764. }
  71765. declare module BABYLON {
  71766. /**
  71767. * RecastJS navigation plugin
  71768. */
  71769. export class RecastJSPlugin implements INavigationEnginePlugin {
  71770. /**
  71771. * Reference to the Recast library
  71772. */
  71773. bjsRECAST: any;
  71774. /**
  71775. * plugin name
  71776. */
  71777. name: string;
  71778. /**
  71779. * the first navmesh created. We might extend this to support multiple navmeshes
  71780. */
  71781. navMesh: any;
  71782. private _maximumSubStepCount;
  71783. private _timeStep;
  71784. /**
  71785. * Initializes the recastJS plugin
  71786. * @param recastInjection can be used to inject your own recast reference
  71787. */
  71788. constructor(recastInjection?: any);
  71789. /**
  71790. * Set the time step of the navigation tick update.
  71791. * Default is 1/60.
  71792. * A value of 0 will disable fixed time update
  71793. * @param newTimeStep the new timestep to apply to this world.
  71794. */
  71795. setTimeStep(newTimeStep?: number): void;
  71796. /**
  71797. * Get the time step of the navigation tick update.
  71798. * @returns the current time step
  71799. */
  71800. getTimeStep(): number;
  71801. /**
  71802. * If delta time in navigation tick update is greater than the time step
  71803. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71804. * they will be discarded.
  71805. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71806. * @param newStepCount the maximum number of iterations
  71807. */
  71808. setMaximumSubStepCount(newStepCount?: number): void;
  71809. /**
  71810. * Get the maximum number of iterations per navigation tick update
  71811. * @returns the maximum number of iterations
  71812. */
  71813. getMaximumSubStepCount(): number;
  71814. /**
  71815. * Creates a navigation mesh
  71816. * @param meshes array of all the geometry used to compute the navigation mesh
  71817. * @param parameters bunch of parameters used to filter geometry
  71818. */
  71819. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71820. /**
  71821. * Create a navigation mesh debug mesh
  71822. * @param scene is where the mesh will be added
  71823. * @returns debug display mesh
  71824. */
  71825. createDebugNavMesh(scene: Scene): Mesh;
  71826. /**
  71827. * Get a navigation mesh constrained position, closest to the parameter position
  71828. * @param position world position
  71829. * @returns the closest point to position constrained by the navigation mesh
  71830. */
  71831. getClosestPoint(position: Vector3): Vector3;
  71832. /**
  71833. * Get a navigation mesh constrained position, closest to the parameter position
  71834. * @param position world position
  71835. * @param result output the closest point to position constrained by the navigation mesh
  71836. */
  71837. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71838. /**
  71839. * Get a navigation mesh constrained position, within a particular radius
  71840. * @param position world position
  71841. * @param maxRadius the maximum distance to the constrained world position
  71842. * @returns the closest point to position constrained by the navigation mesh
  71843. */
  71844. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71845. /**
  71846. * Get a navigation mesh constrained position, within a particular radius
  71847. * @param position world position
  71848. * @param maxRadius the maximum distance to the constrained world position
  71849. * @param result output the closest point to position constrained by the navigation mesh
  71850. */
  71851. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71852. /**
  71853. * Compute the final position from a segment made of destination-position
  71854. * @param position world position
  71855. * @param destination world position
  71856. * @returns the resulting point along the navmesh
  71857. */
  71858. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71859. /**
  71860. * Compute the final position from a segment made of destination-position
  71861. * @param position world position
  71862. * @param destination world position
  71863. * @param result output the resulting point along the navmesh
  71864. */
  71865. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71866. /**
  71867. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71868. * @param start world position
  71869. * @param end world position
  71870. * @returns array containing world position composing the path
  71871. */
  71872. computePath(start: Vector3, end: Vector3): Vector3[];
  71873. /**
  71874. * Create a new Crowd so you can add agents
  71875. * @param maxAgents the maximum agent count in the crowd
  71876. * @param maxAgentRadius the maximum radius an agent can have
  71877. * @param scene to attach the crowd to
  71878. * @returns the crowd you can add agents to
  71879. */
  71880. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71881. /**
  71882. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71883. * The queries will try to find a solution within those bounds
  71884. * default is (1,1,1)
  71885. * @param extent x,y,z value that define the extent around the queries point of reference
  71886. */
  71887. setDefaultQueryExtent(extent: Vector3): void;
  71888. /**
  71889. * Get the Bounding box extent specified by setDefaultQueryExtent
  71890. * @returns the box extent values
  71891. */
  71892. getDefaultQueryExtent(): Vector3;
  71893. /**
  71894. * build the navmesh from a previously saved state using getNavmeshData
  71895. * @param data the Uint8Array returned by getNavmeshData
  71896. */
  71897. buildFromNavmeshData(data: Uint8Array): void;
  71898. /**
  71899. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71900. * @returns data the Uint8Array that can be saved and reused
  71901. */
  71902. getNavmeshData(): Uint8Array;
  71903. /**
  71904. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71905. * @param result output the box extent values
  71906. */
  71907. getDefaultQueryExtentToRef(result: Vector3): void;
  71908. /**
  71909. * Disposes
  71910. */
  71911. dispose(): void;
  71912. /**
  71913. * If this plugin is supported
  71914. * @returns true if plugin is supported
  71915. */
  71916. isSupported(): boolean;
  71917. }
  71918. /**
  71919. * Recast detour crowd implementation
  71920. */
  71921. export class RecastJSCrowd implements ICrowd {
  71922. /**
  71923. * Recast/detour plugin
  71924. */
  71925. bjsRECASTPlugin: RecastJSPlugin;
  71926. /**
  71927. * Link to the detour crowd
  71928. */
  71929. recastCrowd: any;
  71930. /**
  71931. * One transform per agent
  71932. */
  71933. transforms: TransformNode[];
  71934. /**
  71935. * All agents created
  71936. */
  71937. agents: number[];
  71938. /**
  71939. * Link to the scene is kept to unregister the crowd from the scene
  71940. */
  71941. private _scene;
  71942. /**
  71943. * Observer for crowd updates
  71944. */
  71945. private _onBeforeAnimationsObserver;
  71946. /**
  71947. * Constructor
  71948. * @param plugin recastJS plugin
  71949. * @param maxAgents the maximum agent count in the crowd
  71950. * @param maxAgentRadius the maximum radius an agent can have
  71951. * @param scene to attach the crowd to
  71952. * @returns the crowd you can add agents to
  71953. */
  71954. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71955. /**
  71956. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71957. * You can attach anything to that node. The node position is updated in the scene update tick.
  71958. * @param pos world position that will be constrained by the navigation mesh
  71959. * @param parameters agent parameters
  71960. * @param transform hooked to the agent that will be update by the scene
  71961. * @returns agent index
  71962. */
  71963. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71964. /**
  71965. * Returns the agent position in world space
  71966. * @param index agent index returned by addAgent
  71967. * @returns world space position
  71968. */
  71969. getAgentPosition(index: number): Vector3;
  71970. /**
  71971. * Returns the agent position result in world space
  71972. * @param index agent index returned by addAgent
  71973. * @param result output world space position
  71974. */
  71975. getAgentPositionToRef(index: number, result: Vector3): void;
  71976. /**
  71977. * Returns the agent velocity in world space
  71978. * @param index agent index returned by addAgent
  71979. * @returns world space velocity
  71980. */
  71981. getAgentVelocity(index: number): Vector3;
  71982. /**
  71983. * Returns the agent velocity result in world space
  71984. * @param index agent index returned by addAgent
  71985. * @param result output world space velocity
  71986. */
  71987. getAgentVelocityToRef(index: number, result: Vector3): void;
  71988. /**
  71989. * Returns the agent next target point on the path
  71990. * @param index agent index returned by addAgent
  71991. * @returns world space position
  71992. */
  71993. getAgentNextTargetPath(index: number): Vector3;
  71994. /**
  71995. * Returns the agent next target point on the path
  71996. * @param index agent index returned by addAgent
  71997. * @param result output world space position
  71998. */
  71999. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72000. /**
  72001. * Gets the agent state
  72002. * @param index agent index returned by addAgent
  72003. * @returns agent state
  72004. */
  72005. getAgentState(index: number): number;
  72006. /**
  72007. * returns true if the agent in over an off mesh link connection
  72008. * @param index agent index returned by addAgent
  72009. * @returns true if over an off mesh link connection
  72010. */
  72011. overOffmeshConnection(index: number): boolean;
  72012. /**
  72013. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72014. * @param index agent index returned by addAgent
  72015. * @param destination targeted world position
  72016. */
  72017. agentGoto(index: number, destination: Vector3): void;
  72018. /**
  72019. * Teleport the agent to a new position
  72020. * @param index agent index returned by addAgent
  72021. * @param destination targeted world position
  72022. */
  72023. agentTeleport(index: number, destination: Vector3): void;
  72024. /**
  72025. * Update agent parameters
  72026. * @param index agent index returned by addAgent
  72027. * @param parameters agent parameters
  72028. */
  72029. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72030. /**
  72031. * remove a particular agent previously created
  72032. * @param index agent index returned by addAgent
  72033. */
  72034. removeAgent(index: number): void;
  72035. /**
  72036. * get the list of all agents attached to this crowd
  72037. * @returns list of agent indices
  72038. */
  72039. getAgents(): number[];
  72040. /**
  72041. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72042. * @param deltaTime in seconds
  72043. */
  72044. update(deltaTime: number): void;
  72045. /**
  72046. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72047. * The queries will try to find a solution within those bounds
  72048. * default is (1,1,1)
  72049. * @param extent x,y,z value that define the extent around the queries point of reference
  72050. */
  72051. setDefaultQueryExtent(extent: Vector3): void;
  72052. /**
  72053. * Get the Bounding box extent specified by setDefaultQueryExtent
  72054. * @returns the box extent values
  72055. */
  72056. getDefaultQueryExtent(): Vector3;
  72057. /**
  72058. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72059. * @param result output the box extent values
  72060. */
  72061. getDefaultQueryExtentToRef(result: Vector3): void;
  72062. /**
  72063. * Release all resources
  72064. */
  72065. dispose(): void;
  72066. }
  72067. }
  72068. declare module BABYLON {
  72069. /**
  72070. * Class used to enable access to IndexedDB
  72071. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72072. */
  72073. export class Database implements IOfflineProvider {
  72074. private _callbackManifestChecked;
  72075. private _currentSceneUrl;
  72076. private _db;
  72077. private _enableSceneOffline;
  72078. private _enableTexturesOffline;
  72079. private _manifestVersionFound;
  72080. private _mustUpdateRessources;
  72081. private _hasReachedQuota;
  72082. private _isSupported;
  72083. private _idbFactory;
  72084. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72085. private static IsUASupportingBlobStorage;
  72086. /**
  72087. * Gets a boolean indicating if Database storage is enabled (off by default)
  72088. */
  72089. static IDBStorageEnabled: boolean;
  72090. /**
  72091. * Gets a boolean indicating if scene must be saved in the database
  72092. */
  72093. get enableSceneOffline(): boolean;
  72094. /**
  72095. * Gets a boolean indicating if textures must be saved in the database
  72096. */
  72097. get enableTexturesOffline(): boolean;
  72098. /**
  72099. * Creates a new Database
  72100. * @param urlToScene defines the url to load the scene
  72101. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72102. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72103. */
  72104. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72105. private static _ParseURL;
  72106. private static _ReturnFullUrlLocation;
  72107. private _checkManifestFile;
  72108. /**
  72109. * Open the database and make it available
  72110. * @param successCallback defines the callback to call on success
  72111. * @param errorCallback defines the callback to call on error
  72112. */
  72113. open(successCallback: () => void, errorCallback: () => void): void;
  72114. /**
  72115. * Loads an image from the database
  72116. * @param url defines the url to load from
  72117. * @param image defines the target DOM image
  72118. */
  72119. loadImage(url: string, image: HTMLImageElement): void;
  72120. private _loadImageFromDBAsync;
  72121. private _saveImageIntoDBAsync;
  72122. private _checkVersionFromDB;
  72123. private _loadVersionFromDBAsync;
  72124. private _saveVersionIntoDBAsync;
  72125. /**
  72126. * Loads a file from database
  72127. * @param url defines the URL to load from
  72128. * @param sceneLoaded defines a callback to call on success
  72129. * @param progressCallBack defines a callback to call when progress changed
  72130. * @param errorCallback defines a callback to call on error
  72131. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72132. */
  72133. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72134. private _loadFileAsync;
  72135. private _saveFileAsync;
  72136. /**
  72137. * Validates if xhr data is correct
  72138. * @param xhr defines the request to validate
  72139. * @param dataType defines the expected data type
  72140. * @returns true if data is correct
  72141. */
  72142. private static _ValidateXHRData;
  72143. }
  72144. }
  72145. declare module BABYLON {
  72146. /** @hidden */
  72147. export var gpuUpdateParticlesPixelShader: {
  72148. name: string;
  72149. shader: string;
  72150. };
  72151. }
  72152. declare module BABYLON {
  72153. /** @hidden */
  72154. export var gpuUpdateParticlesVertexShader: {
  72155. name: string;
  72156. shader: string;
  72157. };
  72158. }
  72159. declare module BABYLON {
  72160. /** @hidden */
  72161. export var clipPlaneFragmentDeclaration2: {
  72162. name: string;
  72163. shader: string;
  72164. };
  72165. }
  72166. declare module BABYLON {
  72167. /** @hidden */
  72168. export var gpuRenderParticlesPixelShader: {
  72169. name: string;
  72170. shader: string;
  72171. };
  72172. }
  72173. declare module BABYLON {
  72174. /** @hidden */
  72175. export var clipPlaneVertexDeclaration2: {
  72176. name: string;
  72177. shader: string;
  72178. };
  72179. }
  72180. declare module BABYLON {
  72181. /** @hidden */
  72182. export var gpuRenderParticlesVertexShader: {
  72183. name: string;
  72184. shader: string;
  72185. };
  72186. }
  72187. declare module BABYLON {
  72188. /**
  72189. * This represents a GPU particle system in Babylon
  72190. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72191. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72192. */
  72193. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72194. /**
  72195. * The layer mask we are rendering the particles through.
  72196. */
  72197. layerMask: number;
  72198. private _capacity;
  72199. private _activeCount;
  72200. private _currentActiveCount;
  72201. private _accumulatedCount;
  72202. private _renderEffect;
  72203. private _updateEffect;
  72204. private _buffer0;
  72205. private _buffer1;
  72206. private _spriteBuffer;
  72207. private _updateVAO;
  72208. private _renderVAO;
  72209. private _targetIndex;
  72210. private _sourceBuffer;
  72211. private _targetBuffer;
  72212. private _currentRenderId;
  72213. private _started;
  72214. private _stopped;
  72215. private _timeDelta;
  72216. private _randomTexture;
  72217. private _randomTexture2;
  72218. private _attributesStrideSize;
  72219. private _updateEffectOptions;
  72220. private _randomTextureSize;
  72221. private _actualFrame;
  72222. private _customEffect;
  72223. private readonly _rawTextureWidth;
  72224. /**
  72225. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72226. */
  72227. static get IsSupported(): boolean;
  72228. /**
  72229. * An event triggered when the system is disposed.
  72230. */
  72231. onDisposeObservable: Observable<IParticleSystem>;
  72232. /**
  72233. * An event triggered when the system is stopped
  72234. */
  72235. onStoppedObservable: Observable<IParticleSystem>;
  72236. /**
  72237. * Gets the maximum number of particles active at the same time.
  72238. * @returns The max number of active particles.
  72239. */
  72240. getCapacity(): number;
  72241. /**
  72242. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72243. * to override the particles.
  72244. */
  72245. forceDepthWrite: boolean;
  72246. /**
  72247. * Gets or set the number of active particles
  72248. */
  72249. get activeParticleCount(): number;
  72250. set activeParticleCount(value: number);
  72251. private _preWarmDone;
  72252. /**
  72253. * Specifies if the particles are updated in emitter local space or world space.
  72254. */
  72255. isLocal: boolean;
  72256. /** Gets or sets a matrix to use to compute projection */
  72257. defaultProjectionMatrix: Matrix;
  72258. /**
  72259. * Is this system ready to be used/rendered
  72260. * @return true if the system is ready
  72261. */
  72262. isReady(): boolean;
  72263. /**
  72264. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72265. * @returns True if it has been started, otherwise false.
  72266. */
  72267. isStarted(): boolean;
  72268. /**
  72269. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72270. * @returns True if it has been stopped, otherwise false.
  72271. */
  72272. isStopped(): boolean;
  72273. /**
  72274. * Gets a boolean indicating that the system is stopping
  72275. * @returns true if the system is currently stopping
  72276. */
  72277. isStopping(): boolean;
  72278. /**
  72279. * Gets the number of particles active at the same time.
  72280. * @returns The number of active particles.
  72281. */
  72282. getActiveCount(): number;
  72283. /**
  72284. * Starts the particle system and begins to emit
  72285. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72286. */
  72287. start(delay?: number): void;
  72288. /**
  72289. * Stops the particle system.
  72290. */
  72291. stop(): void;
  72292. /**
  72293. * Remove all active particles
  72294. */
  72295. reset(): void;
  72296. /**
  72297. * Returns the string "GPUParticleSystem"
  72298. * @returns a string containing the class name
  72299. */
  72300. getClassName(): string;
  72301. /**
  72302. * Gets the custom effect used to render the particles
  72303. * @param blendMode Blend mode for which the effect should be retrieved
  72304. * @returns The effect
  72305. */
  72306. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72307. /**
  72308. * Sets the custom effect used to render the particles
  72309. * @param effect The effect to set
  72310. * @param blendMode Blend mode for which the effect should be set
  72311. */
  72312. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72313. /** @hidden */
  72314. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72315. /**
  72316. * Observable that will be called just before the particles are drawn
  72317. */
  72318. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72319. /**
  72320. * Gets the name of the particle vertex shader
  72321. */
  72322. get vertexShaderName(): string;
  72323. private _colorGradientsTexture;
  72324. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72325. /**
  72326. * Adds a new color gradient
  72327. * @param gradient defines the gradient to use (between 0 and 1)
  72328. * @param color1 defines the color to affect to the specified gradient
  72329. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72330. * @returns the current particle system
  72331. */
  72332. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72333. private _refreshColorGradient;
  72334. /** Force the system to rebuild all gradients that need to be resync */
  72335. forceRefreshGradients(): void;
  72336. /**
  72337. * Remove a specific color gradient
  72338. * @param gradient defines the gradient to remove
  72339. * @returns the current particle system
  72340. */
  72341. removeColorGradient(gradient: number): GPUParticleSystem;
  72342. private _angularSpeedGradientsTexture;
  72343. private _sizeGradientsTexture;
  72344. private _velocityGradientsTexture;
  72345. private _limitVelocityGradientsTexture;
  72346. private _dragGradientsTexture;
  72347. private _addFactorGradient;
  72348. /**
  72349. * Adds a new size gradient
  72350. * @param gradient defines the gradient to use (between 0 and 1)
  72351. * @param factor defines the size factor to affect to the specified gradient
  72352. * @returns the current particle system
  72353. */
  72354. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72355. /**
  72356. * Remove a specific size gradient
  72357. * @param gradient defines the gradient to remove
  72358. * @returns the current particle system
  72359. */
  72360. removeSizeGradient(gradient: number): GPUParticleSystem;
  72361. private _refreshFactorGradient;
  72362. /**
  72363. * Adds a new angular speed gradient
  72364. * @param gradient defines the gradient to use (between 0 and 1)
  72365. * @param factor defines the angular speed to affect to the specified gradient
  72366. * @returns the current particle system
  72367. */
  72368. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72369. /**
  72370. * Remove a specific angular speed gradient
  72371. * @param gradient defines the gradient to remove
  72372. * @returns the current particle system
  72373. */
  72374. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72375. /**
  72376. * Adds a new velocity gradient
  72377. * @param gradient defines the gradient to use (between 0 and 1)
  72378. * @param factor defines the velocity to affect to the specified gradient
  72379. * @returns the current particle system
  72380. */
  72381. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72382. /**
  72383. * Remove a specific velocity gradient
  72384. * @param gradient defines the gradient to remove
  72385. * @returns the current particle system
  72386. */
  72387. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72388. /**
  72389. * Adds a new limit velocity gradient
  72390. * @param gradient defines the gradient to use (between 0 and 1)
  72391. * @param factor defines the limit velocity value to affect to the specified gradient
  72392. * @returns the current particle system
  72393. */
  72394. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72395. /**
  72396. * Remove a specific limit velocity gradient
  72397. * @param gradient defines the gradient to remove
  72398. * @returns the current particle system
  72399. */
  72400. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72401. /**
  72402. * Adds a new drag gradient
  72403. * @param gradient defines the gradient to use (between 0 and 1)
  72404. * @param factor defines the drag value to affect to the specified gradient
  72405. * @returns the current particle system
  72406. */
  72407. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72408. /**
  72409. * Remove a specific drag gradient
  72410. * @param gradient defines the gradient to remove
  72411. * @returns the current particle system
  72412. */
  72413. removeDragGradient(gradient: number): GPUParticleSystem;
  72414. /**
  72415. * Not supported by GPUParticleSystem
  72416. * @param gradient defines the gradient to use (between 0 and 1)
  72417. * @param factor defines the emit rate value to affect to the specified gradient
  72418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72419. * @returns the current particle system
  72420. */
  72421. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72422. /**
  72423. * Not supported by GPUParticleSystem
  72424. * @param gradient defines the gradient to remove
  72425. * @returns the current particle system
  72426. */
  72427. removeEmitRateGradient(gradient: number): IParticleSystem;
  72428. /**
  72429. * Not supported by GPUParticleSystem
  72430. * @param gradient defines the gradient to use (between 0 and 1)
  72431. * @param factor defines the start size value to affect to the specified gradient
  72432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72433. * @returns the current particle system
  72434. */
  72435. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72436. /**
  72437. * Not supported by GPUParticleSystem
  72438. * @param gradient defines the gradient to remove
  72439. * @returns the current particle system
  72440. */
  72441. removeStartSizeGradient(gradient: number): IParticleSystem;
  72442. /**
  72443. * Not supported by GPUParticleSystem
  72444. * @param gradient defines the gradient to use (between 0 and 1)
  72445. * @param min defines the color remap minimal range
  72446. * @param max defines the color remap maximal range
  72447. * @returns the current particle system
  72448. */
  72449. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72450. /**
  72451. * Not supported by GPUParticleSystem
  72452. * @param gradient defines the gradient to remove
  72453. * @returns the current particle system
  72454. */
  72455. removeColorRemapGradient(): IParticleSystem;
  72456. /**
  72457. * Not supported by GPUParticleSystem
  72458. * @param gradient defines the gradient to use (between 0 and 1)
  72459. * @param min defines the alpha remap minimal range
  72460. * @param max defines the alpha remap maximal range
  72461. * @returns the current particle system
  72462. */
  72463. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72464. /**
  72465. * Not supported by GPUParticleSystem
  72466. * @param gradient defines the gradient to remove
  72467. * @returns the current particle system
  72468. */
  72469. removeAlphaRemapGradient(): IParticleSystem;
  72470. /**
  72471. * Not supported by GPUParticleSystem
  72472. * @param gradient defines the gradient to use (between 0 and 1)
  72473. * @param color defines the color to affect to the specified gradient
  72474. * @returns the current particle system
  72475. */
  72476. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72477. /**
  72478. * Not supported by GPUParticleSystem
  72479. * @param gradient defines the gradient to remove
  72480. * @returns the current particle system
  72481. */
  72482. removeRampGradient(): IParticleSystem;
  72483. /**
  72484. * Not supported by GPUParticleSystem
  72485. * @returns the list of ramp gradients
  72486. */
  72487. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72488. /**
  72489. * Not supported by GPUParticleSystem
  72490. * Gets or sets a boolean indicating that ramp gradients must be used
  72491. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72492. */
  72493. get useRampGradients(): boolean;
  72494. set useRampGradients(value: boolean);
  72495. /**
  72496. * Not supported by GPUParticleSystem
  72497. * @param gradient defines the gradient to use (between 0 and 1)
  72498. * @param factor defines the life time factor to affect to the specified gradient
  72499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72500. * @returns the current particle system
  72501. */
  72502. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72503. /**
  72504. * Not supported by GPUParticleSystem
  72505. * @param gradient defines the gradient to remove
  72506. * @returns the current particle system
  72507. */
  72508. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72509. /**
  72510. * Instantiates a GPU particle system.
  72511. * 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.
  72512. * @param name The name of the particle system
  72513. * @param options The options used to create the system
  72514. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72515. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72516. * @param customEffect a custom effect used to change the way particles are rendered by default
  72517. */
  72518. constructor(name: string, options: Partial<{
  72519. capacity: number;
  72520. randomTextureSize: number;
  72521. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72522. protected _reset(): void;
  72523. private _createUpdateVAO;
  72524. private _createRenderVAO;
  72525. private _initialize;
  72526. /** @hidden */
  72527. _recreateUpdateEffect(): void;
  72528. private _getEffect;
  72529. /**
  72530. * Fill the defines array according to the current settings of the particle system
  72531. * @param defines Array to be updated
  72532. * @param blendMode blend mode to take into account when updating the array
  72533. */
  72534. fillDefines(defines: Array<string>, blendMode?: number): void;
  72535. /**
  72536. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72537. * @param uniforms Uniforms array to fill
  72538. * @param attributes Attributes array to fill
  72539. * @param samplers Samplers array to fill
  72540. */
  72541. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72542. /** @hidden */
  72543. _recreateRenderEffect(): Effect;
  72544. /**
  72545. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72546. * @param preWarm defines if we are in the pre-warmimg phase
  72547. */
  72548. animate(preWarm?: boolean): void;
  72549. private _createFactorGradientTexture;
  72550. private _createSizeGradientTexture;
  72551. private _createAngularSpeedGradientTexture;
  72552. private _createVelocityGradientTexture;
  72553. private _createLimitVelocityGradientTexture;
  72554. private _createDragGradientTexture;
  72555. private _createColorGradientTexture;
  72556. /**
  72557. * Renders the particle system in its current state
  72558. * @param preWarm defines if the system should only update the particles but not render them
  72559. * @returns the current number of particles
  72560. */
  72561. render(preWarm?: boolean): number;
  72562. /**
  72563. * Rebuilds the particle system
  72564. */
  72565. rebuild(): void;
  72566. private _releaseBuffers;
  72567. private _releaseVAOs;
  72568. /**
  72569. * Disposes the particle system and free the associated resources
  72570. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72571. */
  72572. dispose(disposeTexture?: boolean): void;
  72573. /**
  72574. * Clones the particle system.
  72575. * @param name The name of the cloned object
  72576. * @param newEmitter The new emitter to use
  72577. * @returns the cloned particle system
  72578. */
  72579. clone(name: string, newEmitter: any): GPUParticleSystem;
  72580. /**
  72581. * Serializes the particle system to a JSON object
  72582. * @param serializeTexture defines if the texture must be serialized as well
  72583. * @returns the JSON object
  72584. */
  72585. serialize(serializeTexture?: boolean): any;
  72586. /**
  72587. * Parses a JSON object to create a GPU particle system.
  72588. * @param parsedParticleSystem The JSON object to parse
  72589. * @param sceneOrEngine The scene or the engine to create the particle system in
  72590. * @param rootUrl The root url to use to load external dependencies like texture
  72591. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72592. * @returns the parsed GPU particle system
  72593. */
  72594. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72595. }
  72596. }
  72597. declare module BABYLON {
  72598. /**
  72599. * Represents a set of particle systems working together to create a specific effect
  72600. */
  72601. export class ParticleSystemSet implements IDisposable {
  72602. /**
  72603. * Gets or sets base Assets URL
  72604. */
  72605. static BaseAssetsUrl: string;
  72606. private _emitterCreationOptions;
  72607. private _emitterNode;
  72608. /**
  72609. * Gets the particle system list
  72610. */
  72611. systems: IParticleSystem[];
  72612. /**
  72613. * Gets the emitter node used with this set
  72614. */
  72615. get emitterNode(): Nullable<TransformNode>;
  72616. /**
  72617. * Creates a new emitter mesh as a sphere
  72618. * @param options defines the options used to create the sphere
  72619. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72620. * @param scene defines the hosting scene
  72621. */
  72622. setEmitterAsSphere(options: {
  72623. diameter: number;
  72624. segments: number;
  72625. color: Color3;
  72626. }, renderingGroupId: number, scene: Scene): void;
  72627. /**
  72628. * Starts all particle systems of the set
  72629. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72630. */
  72631. start(emitter?: AbstractMesh): void;
  72632. /**
  72633. * Release all associated resources
  72634. */
  72635. dispose(): void;
  72636. /**
  72637. * Serialize the set into a JSON compatible object
  72638. * @param serializeTexture defines if the texture must be serialized as well
  72639. * @returns a JSON compatible representation of the set
  72640. */
  72641. serialize(serializeTexture?: boolean): any;
  72642. /**
  72643. * Parse a new ParticleSystemSet from a serialized source
  72644. * @param data defines a JSON compatible representation of the set
  72645. * @param scene defines the hosting scene
  72646. * @param gpu defines if we want GPU particles or CPU particles
  72647. * @returns a new ParticleSystemSet
  72648. */
  72649. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72650. }
  72651. }
  72652. declare module BABYLON {
  72653. /**
  72654. * This class is made for on one-liner static method to help creating particle system set.
  72655. */
  72656. export class ParticleHelper {
  72657. /**
  72658. * Gets or sets base Assets URL
  72659. */
  72660. static BaseAssetsUrl: string;
  72661. /** Define the Url to load snippets */
  72662. static SnippetUrl: string;
  72663. /**
  72664. * Create a default particle system that you can tweak
  72665. * @param emitter defines the emitter to use
  72666. * @param capacity defines the system capacity (default is 500 particles)
  72667. * @param scene defines the hosting scene
  72668. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72669. * @returns the new Particle system
  72670. */
  72671. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72672. /**
  72673. * This is the main static method (one-liner) of this helper to create different particle systems
  72674. * @param type This string represents the type to the particle system to create
  72675. * @param scene The scene where the particle system should live
  72676. * @param gpu If the system will use gpu
  72677. * @returns the ParticleSystemSet created
  72678. */
  72679. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72680. /**
  72681. * Static function used to export a particle system to a ParticleSystemSet variable.
  72682. * Please note that the emitter shape is not exported
  72683. * @param systems defines the particle systems to export
  72684. * @returns the created particle system set
  72685. */
  72686. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72687. /**
  72688. * Creates a particle system from a snippet saved in a remote file
  72689. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72690. * @param url defines the url to load from
  72691. * @param scene defines the hosting scene
  72692. * @param gpu If the system will use gpu
  72693. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72694. * @returns a promise that will resolve to the new particle system
  72695. */
  72696. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72697. /**
  72698. * Creates a particle system from a snippet saved by the particle system editor
  72699. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72700. * @param scene defines the hosting scene
  72701. * @param gpu If the system will use gpu
  72702. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72703. * @returns a promise that will resolve to the new particle system
  72704. */
  72705. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72706. }
  72707. }
  72708. declare module BABYLON {
  72709. interface Engine {
  72710. /**
  72711. * Create an effect to use with particle systems.
  72712. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72713. * the particle system for which you want to create a custom effect in the last parameter
  72714. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72715. * @param uniformsNames defines a list of attribute names
  72716. * @param samplers defines an array of string used to represent textures
  72717. * @param defines defines the string containing the defines to use to compile the shaders
  72718. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  72719. * @param onCompiled defines a function to call when the effect creation is successful
  72720. * @param onError defines a function to call when the effect creation has failed
  72721. * @param particleSystem the particle system you want to create the effect for
  72722. * @returns the new Effect
  72723. */
  72724. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72725. }
  72726. interface Mesh {
  72727. /**
  72728. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72729. * @returns an array of IParticleSystem
  72730. */
  72731. getEmittedParticleSystems(): IParticleSystem[];
  72732. /**
  72733. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72734. * @returns an array of IParticleSystem
  72735. */
  72736. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72737. }
  72738. }
  72739. declare module BABYLON {
  72740. /** Defines the 4 color options */
  72741. export enum PointColor {
  72742. /** color value */
  72743. Color = 2,
  72744. /** uv value */
  72745. UV = 1,
  72746. /** random value */
  72747. Random = 0,
  72748. /** stated value */
  72749. Stated = 3
  72750. }
  72751. /**
  72752. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72753. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  72754. * The PointCloudSystem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72755. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72756. *
  72757. * Full documentation here : TO BE ENTERED
  72758. */
  72759. export class PointsCloudSystem implements IDisposable {
  72760. /**
  72761. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72762. * Example : var p = SPS.particles[i];
  72763. */
  72764. particles: CloudPoint[];
  72765. /**
  72766. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72767. */
  72768. nbParticles: number;
  72769. /**
  72770. * This a counter for your own usage. It's not set by any SPS functions.
  72771. */
  72772. counter: number;
  72773. /**
  72774. * The PCS name. This name is also given to the underlying mesh.
  72775. */
  72776. name: string;
  72777. /**
  72778. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  72779. */
  72780. mesh: Mesh;
  72781. /**
  72782. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72783. * Please read :
  72784. */
  72785. vars: any;
  72786. /**
  72787. * @hidden
  72788. */
  72789. _size: number;
  72790. private _scene;
  72791. private _promises;
  72792. private _positions;
  72793. private _indices;
  72794. private _normals;
  72795. private _colors;
  72796. private _uvs;
  72797. private _indices32;
  72798. private _positions32;
  72799. private _colors32;
  72800. private _uvs32;
  72801. private _updatable;
  72802. private _isVisibilityBoxLocked;
  72803. private _alwaysVisible;
  72804. private _groups;
  72805. private _groupCounter;
  72806. private _computeParticleColor;
  72807. private _computeParticleTexture;
  72808. private _computeParticleRotation;
  72809. private _computeBoundingBox;
  72810. private _isReady;
  72811. /**
  72812. * Creates a PCS (Points Cloud System) object
  72813. * @param name (String) is the PCS name, this will be the underlying mesh name
  72814. * @param pointSize (number) is the size for each point
  72815. * @param scene (Scene) is the scene in which the PCS is added
  72816. * @param options defines the options of the PCS e.g.
  72817. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72818. */
  72819. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72820. updatable?: boolean;
  72821. });
  72822. /**
  72823. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72824. * If no points were added to the PCS, the returned mesh is just a single point.
  72825. * @returns a promise for the created mesh
  72826. */
  72827. buildMeshAsync(): Promise<Mesh>;
  72828. /**
  72829. * @hidden
  72830. */
  72831. private _buildMesh;
  72832. private _addParticle;
  72833. private _randomUnitVector;
  72834. private _getColorIndicesForCoord;
  72835. private _setPointsColorOrUV;
  72836. private _colorFromTexture;
  72837. private _calculateDensity;
  72838. /**
  72839. * Adds points to the PCS in random positions within a unit sphere
  72840. * @param nb (positive integer) the number of particles to be created from this model
  72841. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72842. * @returns the number of groups in the system
  72843. */
  72844. addPoints(nb: number, pointFunction?: any): number;
  72845. /**
  72846. * Adds points to the PCS from the surface of the model shape
  72847. * @param mesh is any Mesh object that will be used as a surface model for the points
  72848. * @param nb (positive integer) the number of particles to be created from this model
  72849. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72850. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72851. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72852. * @returns the number of groups in the system
  72853. */
  72854. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72855. /**
  72856. * Adds points to the PCS inside the model shape
  72857. * @param mesh is any Mesh object that will be used as a surface model for the points
  72858. * @param nb (positive integer) the number of particles to be created from this model
  72859. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72860. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72861. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72862. * @returns the number of groups in the system
  72863. */
  72864. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72865. /**
  72866. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72867. * This method calls `updateParticle()` for each particle of the SPS.
  72868. * For an animated SPS, it is usually called within the render loop.
  72869. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72870. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72871. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72872. * @returns the PCS.
  72873. */
  72874. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72875. /**
  72876. * Disposes the PCS.
  72877. */
  72878. dispose(): void;
  72879. /**
  72880. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  72881. * doc :
  72882. * @returns the PCS.
  72883. */
  72884. refreshVisibleSize(): PointsCloudSystem;
  72885. /**
  72886. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72887. * @param size the size (float) of the visibility box
  72888. * note : this doesn't lock the PCS mesh bounding box.
  72889. * doc :
  72890. */
  72891. setVisibilityBox(size: number): void;
  72892. /**
  72893. * Gets whether the PCS is always visible or not
  72894. * doc :
  72895. */
  72896. get isAlwaysVisible(): boolean;
  72897. /**
  72898. * Sets the PCS as always visible or not
  72899. * doc :
  72900. */
  72901. set isAlwaysVisible(val: boolean);
  72902. /**
  72903. * Tells to `setParticles()` to compute the particle rotations or not
  72904. * Default value : false. The PCS is faster when it's set to false
  72905. * Note : particle rotations are only applied to parent particles
  72906. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72907. */
  72908. set computeParticleRotation(val: boolean);
  72909. /**
  72910. * Tells to `setParticles()` to compute the particle colors or not.
  72911. * Default value : true. The PCS is faster when it's set to false.
  72912. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72913. */
  72914. set computeParticleColor(val: boolean);
  72915. set computeParticleTexture(val: boolean);
  72916. /**
  72917. * Gets if `setParticles()` computes the particle colors or not.
  72918. * Default value : false. The PCS is faster when it's set to false.
  72919. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72920. */
  72921. get computeParticleColor(): boolean;
  72922. /**
  72923. * Gets if `setParticles()` computes the particle textures or not.
  72924. * Default value : false. The PCS is faster when it's set to false.
  72925. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72926. */
  72927. get computeParticleTexture(): boolean;
  72928. /**
  72929. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72930. */
  72931. set computeBoundingBox(val: boolean);
  72932. /**
  72933. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72934. */
  72935. get computeBoundingBox(): boolean;
  72936. /**
  72937. * This function does nothing. It may be overwritten to set all the particle first values.
  72938. * The PCS doesn't call this function, you may have to call it by your own.
  72939. * doc :
  72940. */
  72941. initParticles(): void;
  72942. /**
  72943. * This function does nothing. It may be overwritten to recycle a particle
  72944. * The PCS doesn't call this function, you can to call it
  72945. * doc :
  72946. * @param particle The particle to recycle
  72947. * @returns the recycled particle
  72948. */
  72949. recycleParticle(particle: CloudPoint): CloudPoint;
  72950. /**
  72951. * Updates a particle : this function should be overwritten by the user.
  72952. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72953. * doc :
  72954. * @example : just set a particle position or velocity and recycle conditions
  72955. * @param particle The particle to update
  72956. * @returns the updated particle
  72957. */
  72958. updateParticle(particle: CloudPoint): CloudPoint;
  72959. /**
  72960. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72961. * This does nothing and may be overwritten by the user.
  72962. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72963. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72964. * @param update the boolean update value actually passed to setParticles()
  72965. */
  72966. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72967. /**
  72968. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72969. * This will be passed three parameters.
  72970. * This does nothing and may be overwritten by the user.
  72971. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72972. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72973. * @param update the boolean update value actually passed to setParticles()
  72974. */
  72975. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72976. }
  72977. }
  72978. declare module BABYLON {
  72979. /**
  72980. * Represents one particle of a points cloud system.
  72981. */
  72982. export class CloudPoint {
  72983. /**
  72984. * particle global index
  72985. */
  72986. idx: number;
  72987. /**
  72988. * The color of the particle
  72989. */
  72990. color: Nullable<Color4>;
  72991. /**
  72992. * The world space position of the particle.
  72993. */
  72994. position: Vector3;
  72995. /**
  72996. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72997. */
  72998. rotation: Vector3;
  72999. /**
  73000. * The world space rotation quaternion of the particle.
  73001. */
  73002. rotationQuaternion: Nullable<Quaternion>;
  73003. /**
  73004. * The uv of the particle.
  73005. */
  73006. uv: Nullable<Vector2>;
  73007. /**
  73008. * The current speed of the particle.
  73009. */
  73010. velocity: Vector3;
  73011. /**
  73012. * The pivot point in the particle local space.
  73013. */
  73014. pivot: Vector3;
  73015. /**
  73016. * Must the particle be translated from its pivot point in its local space ?
  73017. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73018. * Default : false
  73019. */
  73020. translateFromPivot: boolean;
  73021. /**
  73022. * Index of this particle in the global "positions" array (Internal use)
  73023. * @hidden
  73024. */
  73025. _pos: number;
  73026. /**
  73027. * @hidden Index of this particle in the global "indices" array (Internal use)
  73028. */
  73029. _ind: number;
  73030. /**
  73031. * Group this particle belongs to
  73032. */
  73033. _group: PointsGroup;
  73034. /**
  73035. * Group id of this particle
  73036. */
  73037. groupId: number;
  73038. /**
  73039. * Index of the particle in its group id (Internal use)
  73040. */
  73041. idxInGroup: number;
  73042. /**
  73043. * @hidden Particle BoundingInfo object (Internal use)
  73044. */
  73045. _boundingInfo: BoundingInfo;
  73046. /**
  73047. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73048. */
  73049. _pcs: PointsCloudSystem;
  73050. /**
  73051. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73052. */
  73053. _stillInvisible: boolean;
  73054. /**
  73055. * @hidden Last computed particle rotation matrix
  73056. */
  73057. _rotationMatrix: number[];
  73058. /**
  73059. * Parent particle Id, if any.
  73060. * Default null.
  73061. */
  73062. parentId: Nullable<number>;
  73063. /**
  73064. * @hidden Internal global position in the PCS.
  73065. */
  73066. _globalPosition: Vector3;
  73067. /**
  73068. * Creates a Point Cloud object.
  73069. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73070. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73071. * @param group (PointsGroup) is the group the particle belongs to
  73072. * @param groupId (integer) is the group identifier in the PCS.
  73073. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73074. * @param pcs defines the PCS it is associated to
  73075. */
  73076. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73077. /**
  73078. * get point size
  73079. */
  73080. get size(): Vector3;
  73081. /**
  73082. * Set point size
  73083. */
  73084. set size(scale: Vector3);
  73085. /**
  73086. * Legacy support, changed quaternion to rotationQuaternion
  73087. */
  73088. get quaternion(): Nullable<Quaternion>;
  73089. /**
  73090. * Legacy support, changed quaternion to rotationQuaternion
  73091. */
  73092. set quaternion(q: Nullable<Quaternion>);
  73093. /**
  73094. * Returns a boolean. True if the particle intersects a mesh, else false
  73095. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73096. * @param target is the object (point or mesh) what the intersection is computed against
  73097. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bounding sphere is used
  73098. * @returns true if it intersects
  73099. */
  73100. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73101. /**
  73102. * get the rotation matrix of the particle
  73103. * @hidden
  73104. */
  73105. getRotationMatrix(m: Matrix): void;
  73106. }
  73107. /**
  73108. * Represents a group of points in a points cloud system
  73109. * * PCS internal tool, don't use it manually.
  73110. */
  73111. export class PointsGroup {
  73112. /**
  73113. * The group id
  73114. * @hidden
  73115. */
  73116. groupID: number;
  73117. /**
  73118. * image data for group (internal use)
  73119. * @hidden
  73120. */
  73121. _groupImageData: Nullable<ArrayBufferView>;
  73122. /**
  73123. * Image Width (internal use)
  73124. * @hidden
  73125. */
  73126. _groupImgWidth: number;
  73127. /**
  73128. * Image Height (internal use)
  73129. * @hidden
  73130. */
  73131. _groupImgHeight: number;
  73132. /**
  73133. * Custom position function (internal use)
  73134. * @hidden
  73135. */
  73136. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73137. /**
  73138. * density per facet for surface points
  73139. * @hidden
  73140. */
  73141. _groupDensity: number[];
  73142. /**
  73143. * Only when points are colored by texture carries pointer to texture list array
  73144. * @hidden
  73145. */
  73146. _textureNb: number;
  73147. /**
  73148. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73149. * PCS internal tool, don't use it manually.
  73150. * @hidden
  73151. */
  73152. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73153. }
  73154. }
  73155. declare module BABYLON {
  73156. interface Scene {
  73157. /** @hidden (Backing field) */
  73158. _physicsEngine: Nullable<IPhysicsEngine>;
  73159. /** @hidden */
  73160. _physicsTimeAccumulator: number;
  73161. /**
  73162. * Gets the current physics engine
  73163. * @returns a IPhysicsEngine or null if none attached
  73164. */
  73165. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73166. /**
  73167. * Enables physics to the current scene
  73168. * @param gravity defines the scene's gravity for the physics engine
  73169. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73170. * @return a boolean indicating if the physics engine was initialized
  73171. */
  73172. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73173. /**
  73174. * Disables and disposes the physics engine associated with the scene
  73175. */
  73176. disablePhysicsEngine(): void;
  73177. /**
  73178. * Gets a boolean indicating if there is an active physics engine
  73179. * @returns a boolean indicating if there is an active physics engine
  73180. */
  73181. isPhysicsEnabled(): boolean;
  73182. /**
  73183. * Deletes a physics compound impostor
  73184. * @param compound defines the compound to delete
  73185. */
  73186. deleteCompoundImpostor(compound: any): void;
  73187. /**
  73188. * An event triggered when physic simulation is about to be run
  73189. */
  73190. onBeforePhysicsObservable: Observable<Scene>;
  73191. /**
  73192. * An event triggered when physic simulation has been done
  73193. */
  73194. onAfterPhysicsObservable: Observable<Scene>;
  73195. }
  73196. interface AbstractMesh {
  73197. /** @hidden */
  73198. _physicsImpostor: Nullable<PhysicsImpostor>;
  73199. /**
  73200. * Gets or sets impostor used for physic simulation
  73201. * @see https://doc.babylonjs.com/features/physics_engine
  73202. */
  73203. physicsImpostor: Nullable<PhysicsImpostor>;
  73204. /**
  73205. * Gets the current physics impostor
  73206. * @see https://doc.babylonjs.com/features/physics_engine
  73207. * @returns a physics impostor or null
  73208. */
  73209. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73210. /** Apply a physic impulse to the mesh
  73211. * @param force defines the force to apply
  73212. * @param contactPoint defines where to apply the force
  73213. * @returns the current mesh
  73214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73215. */
  73216. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73217. /**
  73218. * Creates a physic joint between two meshes
  73219. * @param otherMesh defines the other mesh to use
  73220. * @param pivot1 defines the pivot to use on this mesh
  73221. * @param pivot2 defines the pivot to use on the other mesh
  73222. * @param options defines additional options (can be plugin dependent)
  73223. * @returns the current mesh
  73224. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73225. */
  73226. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73227. /** @hidden */
  73228. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73229. }
  73230. /**
  73231. * Defines the physics engine scene component responsible to manage a physics engine
  73232. */
  73233. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73234. /**
  73235. * The component name helpful to identify the component in the list of scene components.
  73236. */
  73237. readonly name: string;
  73238. /**
  73239. * The scene the component belongs to.
  73240. */
  73241. scene: Scene;
  73242. /**
  73243. * Creates a new instance of the component for the given scene
  73244. * @param scene Defines the scene to register the component in
  73245. */
  73246. constructor(scene: Scene);
  73247. /**
  73248. * Registers the component in a given scene
  73249. */
  73250. register(): void;
  73251. /**
  73252. * Rebuilds the elements related to this component in case of
  73253. * context lost for instance.
  73254. */
  73255. rebuild(): void;
  73256. /**
  73257. * Disposes the component and the associated resources
  73258. */
  73259. dispose(): void;
  73260. }
  73261. }
  73262. declare module BABYLON {
  73263. /**
  73264. * A helper for physics simulations
  73265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73266. */
  73267. export class PhysicsHelper {
  73268. private _scene;
  73269. private _physicsEngine;
  73270. /**
  73271. * Initializes the Physics helper
  73272. * @param scene Babylon.js scene
  73273. */
  73274. constructor(scene: Scene);
  73275. /**
  73276. * Applies a radial explosion impulse
  73277. * @param origin the origin of the explosion
  73278. * @param radiusOrEventOptions the radius or the options of radial explosion
  73279. * @param strength the explosion strength
  73280. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73281. * @returns A physics radial explosion event, or null
  73282. */
  73283. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73284. /**
  73285. * Applies a radial explosion force
  73286. * @param origin the origin of the explosion
  73287. * @param radiusOrEventOptions the radius or the options of radial explosion
  73288. * @param strength the explosion strength
  73289. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73290. * @returns A physics radial explosion event, or null
  73291. */
  73292. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73293. /**
  73294. * Creates a gravitational field
  73295. * @param origin the origin of the explosion
  73296. * @param radiusOrEventOptions the radius or the options of radial explosion
  73297. * @param strength the explosion strength
  73298. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73299. * @returns A physics gravitational field event, or null
  73300. */
  73301. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73302. /**
  73303. * Creates a physics updraft event
  73304. * @param origin the origin of the updraft
  73305. * @param radiusOrEventOptions the radius or the options of the updraft
  73306. * @param strength the strength of the updraft
  73307. * @param height the height of the updraft
  73308. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73309. * @returns A physics updraft event, or null
  73310. */
  73311. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73312. /**
  73313. * Creates a physics vortex event
  73314. * @param origin the of the vortex
  73315. * @param radiusOrEventOptions the radius or the options of the vortex
  73316. * @param strength the strength of the vortex
  73317. * @param height the height of the vortex
  73318. * @returns a Physics vortex event, or null
  73319. * A physics vortex event or null
  73320. */
  73321. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73322. }
  73323. /**
  73324. * Represents a physics radial explosion event
  73325. */
  73326. class PhysicsRadialExplosionEvent {
  73327. private _scene;
  73328. private _options;
  73329. private _sphere;
  73330. private _dataFetched;
  73331. /**
  73332. * Initializes a radial explosion event
  73333. * @param _scene BabylonJS scene
  73334. * @param _options The options for the vortex event
  73335. */
  73336. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73337. /**
  73338. * Returns the data related to the radial explosion event (sphere).
  73339. * @returns The radial explosion event data
  73340. */
  73341. getData(): PhysicsRadialExplosionEventData;
  73342. /**
  73343. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73344. * @param impostor A physics imposter
  73345. * @param origin the origin of the explosion
  73346. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73347. */
  73348. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73349. /**
  73350. * Triggers affected impostors callbacks
  73351. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73352. */
  73353. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73354. /**
  73355. * Disposes the sphere.
  73356. * @param force Specifies if the sphere should be disposed by force
  73357. */
  73358. dispose(force?: boolean): void;
  73359. /*** Helpers ***/
  73360. private _prepareSphere;
  73361. private _intersectsWithSphere;
  73362. }
  73363. /**
  73364. * Represents a gravitational field event
  73365. */
  73366. class PhysicsGravitationalFieldEvent {
  73367. private _physicsHelper;
  73368. private _scene;
  73369. private _origin;
  73370. private _options;
  73371. private _tickCallback;
  73372. private _sphere;
  73373. private _dataFetched;
  73374. /**
  73375. * Initializes the physics gravitational field event
  73376. * @param _physicsHelper A physics helper
  73377. * @param _scene BabylonJS scene
  73378. * @param _origin The origin position of the gravitational field event
  73379. * @param _options The options for the vortex event
  73380. */
  73381. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73382. /**
  73383. * Returns the data related to the gravitational field event (sphere).
  73384. * @returns A gravitational field event
  73385. */
  73386. getData(): PhysicsGravitationalFieldEventData;
  73387. /**
  73388. * Enables the gravitational field.
  73389. */
  73390. enable(): void;
  73391. /**
  73392. * Disables the gravitational field.
  73393. */
  73394. disable(): void;
  73395. /**
  73396. * Disposes the sphere.
  73397. * @param force The force to dispose from the gravitational field event
  73398. */
  73399. dispose(force?: boolean): void;
  73400. private _tick;
  73401. }
  73402. /**
  73403. * Represents a physics updraft event
  73404. */
  73405. class PhysicsUpdraftEvent {
  73406. private _scene;
  73407. private _origin;
  73408. private _options;
  73409. private _physicsEngine;
  73410. private _originTop;
  73411. private _originDirection;
  73412. private _tickCallback;
  73413. private _cylinder;
  73414. private _cylinderPosition;
  73415. private _dataFetched;
  73416. /**
  73417. * Initializes the physics updraft event
  73418. * @param _scene BabylonJS scene
  73419. * @param _origin The origin position of the updraft
  73420. * @param _options The options for the updraft event
  73421. */
  73422. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73423. /**
  73424. * Returns the data related to the updraft event (cylinder).
  73425. * @returns A physics updraft event
  73426. */
  73427. getData(): PhysicsUpdraftEventData;
  73428. /**
  73429. * Enables the updraft.
  73430. */
  73431. enable(): void;
  73432. /**
  73433. * Disables the updraft.
  73434. */
  73435. disable(): void;
  73436. /**
  73437. * Disposes the cylinder.
  73438. * @param force Specifies if the updraft should be disposed by force
  73439. */
  73440. dispose(force?: boolean): void;
  73441. private getImpostorHitData;
  73442. private _tick;
  73443. /*** Helpers ***/
  73444. private _prepareCylinder;
  73445. private _intersectsWithCylinder;
  73446. }
  73447. /**
  73448. * Represents a physics vortex event
  73449. */
  73450. class PhysicsVortexEvent {
  73451. private _scene;
  73452. private _origin;
  73453. private _options;
  73454. private _physicsEngine;
  73455. private _originTop;
  73456. private _tickCallback;
  73457. private _cylinder;
  73458. private _cylinderPosition;
  73459. private _dataFetched;
  73460. /**
  73461. * Initializes the physics vortex event
  73462. * @param _scene The BabylonJS scene
  73463. * @param _origin The origin position of the vortex
  73464. * @param _options The options for the vortex event
  73465. */
  73466. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73467. /**
  73468. * Returns the data related to the vortex event (cylinder).
  73469. * @returns The physics vortex event data
  73470. */
  73471. getData(): PhysicsVortexEventData;
  73472. /**
  73473. * Enables the vortex.
  73474. */
  73475. enable(): void;
  73476. /**
  73477. * Disables the cortex.
  73478. */
  73479. disable(): void;
  73480. /**
  73481. * Disposes the sphere.
  73482. * @param force
  73483. */
  73484. dispose(force?: boolean): void;
  73485. private getImpostorHitData;
  73486. private _tick;
  73487. /*** Helpers ***/
  73488. private _prepareCylinder;
  73489. private _intersectsWithCylinder;
  73490. }
  73491. /**
  73492. * Options fot the radial explosion event
  73493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73494. */
  73495. export class PhysicsRadialExplosionEventOptions {
  73496. /**
  73497. * The radius of the sphere for the radial explosion.
  73498. */
  73499. radius: number;
  73500. /**
  73501. * The strength of the explosion.
  73502. */
  73503. strength: number;
  73504. /**
  73505. * The strength of the force in correspondence to the distance of the affected object
  73506. */
  73507. falloff: PhysicsRadialImpulseFalloff;
  73508. /**
  73509. * Sphere options for the radial explosion.
  73510. */
  73511. sphere: {
  73512. segments: number;
  73513. diameter: number;
  73514. };
  73515. /**
  73516. * Sphere options for the radial explosion.
  73517. */
  73518. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73519. }
  73520. /**
  73521. * Options fot the updraft event
  73522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73523. */
  73524. export class PhysicsUpdraftEventOptions {
  73525. /**
  73526. * The radius of the cylinder for the vortex
  73527. */
  73528. radius: number;
  73529. /**
  73530. * The strength of the updraft.
  73531. */
  73532. strength: number;
  73533. /**
  73534. * The height of the cylinder for the updraft.
  73535. */
  73536. height: number;
  73537. /**
  73538. * The mode for the the updraft.
  73539. */
  73540. updraftMode: PhysicsUpdraftMode;
  73541. }
  73542. /**
  73543. * Options fot the vortex event
  73544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73545. */
  73546. export class PhysicsVortexEventOptions {
  73547. /**
  73548. * The radius of the cylinder for the vortex
  73549. */
  73550. radius: number;
  73551. /**
  73552. * The strength of the vortex.
  73553. */
  73554. strength: number;
  73555. /**
  73556. * The height of the cylinder for the vortex.
  73557. */
  73558. height: number;
  73559. /**
  73560. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73561. */
  73562. centripetalForceThreshold: number;
  73563. /**
  73564. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
  73565. */
  73566. centripetalForceMultiplier: number;
  73567. /**
  73568. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
  73569. */
  73570. centrifugalForceMultiplier: number;
  73571. /**
  73572. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73573. */
  73574. updraftForceMultiplier: number;
  73575. }
  73576. /**
  73577. * The strength of the force in correspondence to the distance of the affected object
  73578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73579. */
  73580. export enum PhysicsRadialImpulseFalloff {
  73581. /** Defines that impulse is constant in strength across it's whole radius */
  73582. Constant = 0,
  73583. /** Defines that impulse gets weaker if it's further from the origin */
  73584. Linear = 1
  73585. }
  73586. /**
  73587. * The strength of the force in correspondence to the distance of the affected object
  73588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73589. */
  73590. export enum PhysicsUpdraftMode {
  73591. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73592. Center = 0,
  73593. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73594. Perpendicular = 1
  73595. }
  73596. /**
  73597. * Interface for a physics hit data
  73598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73599. */
  73600. export interface PhysicsHitData {
  73601. /**
  73602. * The force applied at the contact point
  73603. */
  73604. force: Vector3;
  73605. /**
  73606. * The contact point
  73607. */
  73608. contactPoint: Vector3;
  73609. /**
  73610. * The distance from the origin to the contact point
  73611. */
  73612. distanceFromOrigin: number;
  73613. }
  73614. /**
  73615. * Interface for radial explosion event data
  73616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73617. */
  73618. export interface PhysicsRadialExplosionEventData {
  73619. /**
  73620. * A sphere used for the radial explosion event
  73621. */
  73622. sphere: Mesh;
  73623. }
  73624. /**
  73625. * Interface for gravitational field event data
  73626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73627. */
  73628. export interface PhysicsGravitationalFieldEventData {
  73629. /**
  73630. * A sphere mesh used for the gravitational field event
  73631. */
  73632. sphere: Mesh;
  73633. }
  73634. /**
  73635. * Interface for updraft event data
  73636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73637. */
  73638. export interface PhysicsUpdraftEventData {
  73639. /**
  73640. * A cylinder used for the updraft event
  73641. */
  73642. cylinder: Mesh;
  73643. }
  73644. /**
  73645. * Interface for vortex event data
  73646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73647. */
  73648. export interface PhysicsVortexEventData {
  73649. /**
  73650. * A cylinder used for the vortex event
  73651. */
  73652. cylinder: Mesh;
  73653. }
  73654. /**
  73655. * Interface for an affected physics impostor
  73656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73657. */
  73658. export interface PhysicsAffectedImpostorWithData {
  73659. /**
  73660. * The impostor affected by the effect
  73661. */
  73662. impostor: PhysicsImpostor;
  73663. /**
  73664. * The data about the hit/force from the explosion
  73665. */
  73666. hitData: PhysicsHitData;
  73667. }
  73668. }
  73669. declare module BABYLON {
  73670. /** @hidden */
  73671. export var blackAndWhitePixelShader: {
  73672. name: string;
  73673. shader: string;
  73674. };
  73675. }
  73676. declare module BABYLON {
  73677. /**
  73678. * Post process used to render in black and white
  73679. */
  73680. export class BlackAndWhitePostProcess extends PostProcess {
  73681. /**
  73682. * Linear about to convert he result to black and white (default: 1)
  73683. */
  73684. degree: number;
  73685. /**
  73686. * Gets a string identifying the name of the class
  73687. * @returns "BlackAndWhitePostProcess" string
  73688. */
  73689. getClassName(): string;
  73690. /**
  73691. * Creates a black and white post process
  73692. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73693. * @param name The name of the effect.
  73694. * @param options The required width/height ratio to downsize to before computing the render pass.
  73695. * @param camera The camera to apply the render pass to.
  73696. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73697. * @param engine The engine which the post process will be applied. (default: current engine)
  73698. * @param reusable If the post process can be reused on the same frame. (default: false)
  73699. */
  73700. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73701. /** @hidden */
  73702. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73703. }
  73704. }
  73705. declare module BABYLON {
  73706. /**
  73707. * This represents a set of one or more post processes in Babylon.
  73708. * A post process can be used to apply a shader to a texture after it is rendered.
  73709. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73710. */
  73711. export class PostProcessRenderEffect {
  73712. private _postProcesses;
  73713. private _getPostProcesses;
  73714. private _singleInstance;
  73715. private _cameras;
  73716. private _indicesForCamera;
  73717. /**
  73718. * Name of the effect
  73719. * @hidden
  73720. */
  73721. _name: string;
  73722. /**
  73723. * Instantiates a post process render effect.
  73724. * A post process can be used to apply a shader to a texture after it is rendered.
  73725. * @param engine The engine the effect is tied to
  73726. * @param name The name of the effect
  73727. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73728. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73729. */
  73730. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73731. /**
  73732. * Checks if all the post processes in the effect are supported.
  73733. */
  73734. get isSupported(): boolean;
  73735. /**
  73736. * Updates the current state of the effect
  73737. * @hidden
  73738. */
  73739. _update(): void;
  73740. /**
  73741. * Attaches the effect on cameras
  73742. * @param cameras The camera to attach to.
  73743. * @hidden
  73744. */
  73745. _attachCameras(cameras: Camera): void;
  73746. /**
  73747. * Attaches the effect on cameras
  73748. * @param cameras The camera to attach to.
  73749. * @hidden
  73750. */
  73751. _attachCameras(cameras: Camera[]): void;
  73752. /**
  73753. * Detaches the effect on cameras
  73754. * @param cameras The camera to detach from.
  73755. * @hidden
  73756. */
  73757. _detachCameras(cameras: Camera): void;
  73758. /**
  73759. * Detaches the effect on cameras
  73760. * @param cameras The camera to detach from.
  73761. * @hidden
  73762. */
  73763. _detachCameras(cameras: Camera[]): void;
  73764. /**
  73765. * Enables the effect on given cameras
  73766. * @param cameras The camera to enable.
  73767. * @hidden
  73768. */
  73769. _enable(cameras: Camera): void;
  73770. /**
  73771. * Enables the effect on given cameras
  73772. * @param cameras The camera to enable.
  73773. * @hidden
  73774. */
  73775. _enable(cameras: Nullable<Camera[]>): void;
  73776. /**
  73777. * Disables the effect on the given cameras
  73778. * @param cameras The camera to disable.
  73779. * @hidden
  73780. */
  73781. _disable(cameras: Camera): void;
  73782. /**
  73783. * Disables the effect on the given cameras
  73784. * @param cameras The camera to disable.
  73785. * @hidden
  73786. */
  73787. _disable(cameras: Nullable<Camera[]>): void;
  73788. /**
  73789. * Gets a list of the post processes contained in the effect.
  73790. * @param camera The camera to get the post processes on.
  73791. * @returns The list of the post processes in the effect.
  73792. */
  73793. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73794. }
  73795. }
  73796. declare module BABYLON {
  73797. /** @hidden */
  73798. export var extractHighlightsPixelShader: {
  73799. name: string;
  73800. shader: string;
  73801. };
  73802. }
  73803. declare module BABYLON {
  73804. /**
  73805. * 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.
  73806. */
  73807. export class ExtractHighlightsPostProcess extends PostProcess {
  73808. /**
  73809. * The luminance threshold, pixels below this value will be set to black.
  73810. */
  73811. threshold: number;
  73812. /** @hidden */
  73813. _exposure: number;
  73814. /**
  73815. * Post process which has the input texture to be used when performing highlight extraction
  73816. * @hidden
  73817. */
  73818. _inputPostProcess: Nullable<PostProcess>;
  73819. /**
  73820. * Gets a string identifying the name of the class
  73821. * @returns "ExtractHighlightsPostProcess" string
  73822. */
  73823. getClassName(): string;
  73824. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73825. }
  73826. }
  73827. declare module BABYLON {
  73828. /** @hidden */
  73829. export var bloomMergePixelShader: {
  73830. name: string;
  73831. shader: string;
  73832. };
  73833. }
  73834. declare module BABYLON {
  73835. /**
  73836. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73837. */
  73838. export class BloomMergePostProcess extends PostProcess {
  73839. /** Weight of the bloom to be added to the original input. */
  73840. weight: number;
  73841. /**
  73842. * Gets a string identifying the name of the class
  73843. * @returns "BloomMergePostProcess" string
  73844. */
  73845. getClassName(): string;
  73846. /**
  73847. * Creates a new instance of @see BloomMergePostProcess
  73848. * @param name The name of the effect.
  73849. * @param originalFromInput Post process which's input will be used for the merge.
  73850. * @param blurred Blurred highlights post process which's output will be used.
  73851. * @param weight Weight of the bloom to be added to the original input.
  73852. * @param options The required width/height ratio to downsize to before computing the render pass.
  73853. * @param camera The camera to apply the render pass to.
  73854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73855. * @param engine The engine which the post process will be applied. (default: current engine)
  73856. * @param reusable If the post process can be reused on the same frame. (default: false)
  73857. * @param textureType Type of textures used when performing the post process. (default: 0)
  73858. * @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)
  73859. */
  73860. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73861. /** Weight of the bloom to be added to the original input. */
  73862. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73863. }
  73864. }
  73865. declare module BABYLON {
  73866. /**
  73867. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73868. */
  73869. export class BloomEffect extends PostProcessRenderEffect {
  73870. private bloomScale;
  73871. /**
  73872. * @hidden Internal
  73873. */
  73874. _effects: Array<PostProcess>;
  73875. /**
  73876. * @hidden Internal
  73877. */
  73878. _downscale: ExtractHighlightsPostProcess;
  73879. private _blurX;
  73880. private _blurY;
  73881. private _merge;
  73882. /**
  73883. * The luminance threshold to find bright areas of the image to bloom.
  73884. */
  73885. get threshold(): number;
  73886. set threshold(value: number);
  73887. /**
  73888. * The strength of the bloom.
  73889. */
  73890. get weight(): number;
  73891. set weight(value: number);
  73892. /**
  73893. * Specifies the size of the bloom blur kernel, relative to the final output size
  73894. */
  73895. get kernel(): number;
  73896. set kernel(value: number);
  73897. /**
  73898. * Creates a new instance of @see BloomEffect
  73899. * @param scene The scene the effect belongs to.
  73900. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73901. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73902. * @param bloomWeight The the strength of bloom.
  73903. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73904. * @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)
  73905. */
  73906. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73907. /**
  73908. * Disposes each of the internal effects for a given camera.
  73909. * @param camera The camera to dispose the effect on.
  73910. */
  73911. disposeEffects(camera: Camera): void;
  73912. /**
  73913. * @hidden Internal
  73914. */
  73915. _updateEffects(): void;
  73916. /**
  73917. * Internal
  73918. * @returns if all the contained post processes are ready.
  73919. * @hidden
  73920. */
  73921. _isReady(): boolean;
  73922. }
  73923. }
  73924. declare module BABYLON {
  73925. /** @hidden */
  73926. export var chromaticAberrationPixelShader: {
  73927. name: string;
  73928. shader: string;
  73929. };
  73930. }
  73931. declare module BABYLON {
  73932. /**
  73933. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73934. */
  73935. export class ChromaticAberrationPostProcess extends PostProcess {
  73936. /**
  73937. * The amount of separation of rgb channels (default: 30)
  73938. */
  73939. aberrationAmount: number;
  73940. /**
  73941. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73942. */
  73943. radialIntensity: number;
  73944. /**
  73945. * The normalized direction in which the rgb channels should be separated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  73946. */
  73947. direction: Vector2;
  73948. /**
  73949. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corner] (default: Vector2(0.5 ,0.5))
  73950. */
  73951. centerPosition: Vector2;
  73952. /** The width of the screen to apply the effect on */
  73953. screenWidth: number;
  73954. /** The height of the screen to apply the effect on */
  73955. screenHeight: number;
  73956. /**
  73957. * Gets a string identifying the name of the class
  73958. * @returns "ChromaticAberrationPostProcess" string
  73959. */
  73960. getClassName(): string;
  73961. /**
  73962. * Creates a new instance ChromaticAberrationPostProcess
  73963. * @param name The name of the effect.
  73964. * @param screenWidth The width of the screen to apply the effect on.
  73965. * @param screenHeight The height of the screen to apply the effect on.
  73966. * @param options The required width/height ratio to downsize to before computing the render pass.
  73967. * @param camera The camera to apply the render pass to.
  73968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73969. * @param engine The engine which the post process will be applied. (default: current engine)
  73970. * @param reusable If the post process can be reused on the same frame. (default: false)
  73971. * @param textureType Type of textures used when performing the post process. (default: 0)
  73972. * @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)
  73973. */
  73974. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73975. /** @hidden */
  73976. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73977. }
  73978. }
  73979. declare module BABYLON {
  73980. /** @hidden */
  73981. export var circleOfConfusionPixelShader: {
  73982. name: string;
  73983. shader: string;
  73984. };
  73985. }
  73986. declare module BABYLON {
  73987. /**
  73988. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73989. */
  73990. export class CircleOfConfusionPostProcess extends PostProcess {
  73991. /**
  73992. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.
  73993. */
  73994. lensSize: number;
  73995. /**
  73996. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73997. */
  73998. fStop: number;
  73999. /**
  74000. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74001. */
  74002. focusDistance: number;
  74003. /**
  74004. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74005. */
  74006. focalLength: number;
  74007. /**
  74008. * Gets a string identifying the name of the class
  74009. * @returns "CircleOfConfusionPostProcess" string
  74010. */
  74011. getClassName(): string;
  74012. private _depthTexture;
  74013. /**
  74014. * Creates a new instance CircleOfConfusionPostProcess
  74015. * @param name The name of the effect.
  74016. * @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.
  74017. * @param options The required width/height ratio to downsize to before computing the render pass.
  74018. * @param camera The camera to apply the render pass to.
  74019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74020. * @param engine The engine which the post process will be applied. (default: current engine)
  74021. * @param reusable If the post process can be reused on the same frame. (default: false)
  74022. * @param textureType Type of textures used when performing the post process. (default: 0)
  74023. * @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)
  74024. */
  74025. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74026. /**
  74027. * 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.
  74028. */
  74029. set depthTexture(value: RenderTargetTexture);
  74030. }
  74031. }
  74032. declare module BABYLON {
  74033. /** @hidden */
  74034. export var colorCorrectionPixelShader: {
  74035. name: string;
  74036. shader: string;
  74037. };
  74038. }
  74039. declare module BABYLON {
  74040. /**
  74041. *
  74042. * This post-process allows the modification of rendered colors by using
  74043. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74044. *
  74045. * The object needs to be provided an url to a texture containing the color
  74046. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74047. * Use an image editing software to tweak the LUT to match your needs.
  74048. *
  74049. * For an example of a color LUT, see here:
  74050. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74051. * For explanations on color grading, see here:
  74052. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74053. *
  74054. */
  74055. export class ColorCorrectionPostProcess extends PostProcess {
  74056. private _colorTableTexture;
  74057. /**
  74058. * Gets the color table url used to create the LUT texture
  74059. */
  74060. colorTableUrl: string;
  74061. /**
  74062. * Gets a string identifying the name of the class
  74063. * @returns "ColorCorrectionPostProcess" string
  74064. */
  74065. getClassName(): string;
  74066. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74067. /** @hidden */
  74068. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74069. }
  74070. }
  74071. declare module BABYLON {
  74072. /** @hidden */
  74073. export var convolutionPixelShader: {
  74074. name: string;
  74075. shader: string;
  74076. };
  74077. }
  74078. declare module BABYLON {
  74079. /**
  74080. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74081. * input texture to perform effects such as edge detection or sharpening
  74082. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74083. */
  74084. export class ConvolutionPostProcess extends PostProcess {
  74085. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74086. kernel: number[];
  74087. /**
  74088. * Gets a string identifying the name of the class
  74089. * @returns "ConvolutionPostProcess" string
  74090. */
  74091. getClassName(): string;
  74092. /**
  74093. * Creates a new instance ConvolutionPostProcess
  74094. * @param name The name of the effect.
  74095. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74096. * @param options The required width/height ratio to downsize to before computing the render pass.
  74097. * @param camera The camera to apply the render pass to.
  74098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74099. * @param engine The engine which the post process will be applied. (default: current engine)
  74100. * @param reusable If the post process can be reused on the same frame. (default: false)
  74101. * @param textureType Type of textures used when performing the post process. (default: 0)
  74102. */
  74103. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74104. /** @hidden */
  74105. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74106. /**
  74107. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74108. */
  74109. static EdgeDetect0Kernel: number[];
  74110. /**
  74111. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74112. */
  74113. static EdgeDetect1Kernel: number[];
  74114. /**
  74115. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74116. */
  74117. static EdgeDetect2Kernel: number[];
  74118. /**
  74119. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74120. */
  74121. static SharpenKernel: number[];
  74122. /**
  74123. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74124. */
  74125. static EmbossKernel: number[];
  74126. /**
  74127. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74128. */
  74129. static GaussianKernel: number[];
  74130. }
  74131. }
  74132. declare module BABYLON {
  74133. /**
  74134. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74135. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74136. * based on samples that have a large difference in distance than the center pixel.
  74137. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74138. */
  74139. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74140. /**
  74141. * The direction the blur should be applied
  74142. */
  74143. direction: Vector2;
  74144. /**
  74145. * Gets a string identifying the name of the class
  74146. * @returns "DepthOfFieldBlurPostProcess" string
  74147. */
  74148. getClassName(): string;
  74149. /**
  74150. * Creates a new instance CircleOfConfusionPostProcess
  74151. * @param name The name of the effect.
  74152. * @param scene The scene the effect belongs to.
  74153. * @param direction The direction the blur should be applied.
  74154. * @param kernel The size of the kernel used to blur.
  74155. * @param options The required width/height ratio to downsize to before computing the render pass.
  74156. * @param camera The camera to apply the render pass to.
  74157. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring across edges
  74158. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74160. * @param engine The engine which the post process will be applied. (default: current engine)
  74161. * @param reusable If the post process can be reused on the same frame. (default: false)
  74162. * @param textureType Type of textures used when performing the post process. (default: 0)
  74163. * @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)
  74164. */
  74165. 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);
  74166. }
  74167. }
  74168. declare module BABYLON {
  74169. /** @hidden */
  74170. export var depthOfFieldMergePixelShader: {
  74171. name: string;
  74172. shader: string;
  74173. };
  74174. }
  74175. declare module BABYLON {
  74176. /**
  74177. * Options to be set when merging outputs from the default pipeline.
  74178. */
  74179. export class DepthOfFieldMergePostProcessOptions {
  74180. /**
  74181. * The original image to merge on top of
  74182. */
  74183. originalFromInput: PostProcess;
  74184. /**
  74185. * Parameters to perform the merge of the depth of field effect
  74186. */
  74187. depthOfField?: {
  74188. circleOfConfusion: PostProcess;
  74189. blurSteps: Array<PostProcess>;
  74190. };
  74191. /**
  74192. * Parameters to perform the merge of bloom effect
  74193. */
  74194. bloom?: {
  74195. blurred: PostProcess;
  74196. weight: number;
  74197. };
  74198. }
  74199. /**
  74200. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74201. */
  74202. export class DepthOfFieldMergePostProcess extends PostProcess {
  74203. private blurSteps;
  74204. /**
  74205. * Gets a string identifying the name of the class
  74206. * @returns "DepthOfFieldMergePostProcess" string
  74207. */
  74208. getClassName(): string;
  74209. /**
  74210. * Creates a new instance of DepthOfFieldMergePostProcess
  74211. * @param name The name of the effect.
  74212. * @param originalFromInput Post process which's input will be used for the merge.
  74213. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74214. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74215. * @param options The required width/height ratio to downsize to before computing the render pass.
  74216. * @param camera The camera to apply the render pass to.
  74217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74218. * @param engine The engine which the post process will be applied. (default: current engine)
  74219. * @param reusable If the post process can be reused on the same frame. (default: false)
  74220. * @param textureType Type of textures used when performing the post process. (default: 0)
  74221. * @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)
  74222. */
  74223. 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);
  74224. /**
  74225. * Updates the effect with the current post process compile time values and recompiles the shader.
  74226. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74227. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74228. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74229. * @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
  74230. * @param onCompiled Called when the shader has been compiled.
  74231. * @param onError Called if there is an error when compiling a shader.
  74232. */
  74233. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74234. }
  74235. }
  74236. declare module BABYLON {
  74237. /**
  74238. * Specifies the level of max blur that should be applied when using the depth of field effect
  74239. */
  74240. export enum DepthOfFieldEffectBlurLevel {
  74241. /**
  74242. * Subtle blur
  74243. */
  74244. Low = 0,
  74245. /**
  74246. * Medium blur
  74247. */
  74248. Medium = 1,
  74249. /**
  74250. * Large blur
  74251. */
  74252. High = 2
  74253. }
  74254. /**
  74255. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74256. */
  74257. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74258. private _circleOfConfusion;
  74259. /**
  74260. * @hidden Internal, blurs from high to low
  74261. */
  74262. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74263. private _depthOfFieldBlurY;
  74264. private _dofMerge;
  74265. /**
  74266. * @hidden Internal post processes in depth of field effect
  74267. */
  74268. _effects: Array<PostProcess>;
  74269. /**
  74270. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74271. */
  74272. set focalLength(value: number);
  74273. get focalLength(): number;
  74274. /**
  74275. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74276. */
  74277. set fStop(value: number);
  74278. get fStop(): number;
  74279. /**
  74280. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74281. */
  74282. set focusDistance(value: number);
  74283. get focusDistance(): number;
  74284. /**
  74285. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.
  74286. */
  74287. set lensSize(value: number);
  74288. get lensSize(): number;
  74289. /**
  74290. * Creates a new instance DepthOfFieldEffect
  74291. * @param scene The scene the effect belongs to.
  74292. * @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.
  74293. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74294. * @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)
  74295. */
  74296. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74297. /**
  74298. * Get the current class name of the current effect
  74299. * @returns "DepthOfFieldEffect"
  74300. */
  74301. getClassName(): string;
  74302. /**
  74303. * 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.
  74304. */
  74305. set depthTexture(value: RenderTargetTexture);
  74306. /**
  74307. * Disposes each of the internal effects for a given camera.
  74308. * @param camera The camera to dispose the effect on.
  74309. */
  74310. disposeEffects(camera: Camera): void;
  74311. /**
  74312. * @hidden Internal
  74313. */
  74314. _updateEffects(): void;
  74315. /**
  74316. * Internal
  74317. * @returns if all the contained post processes are ready.
  74318. * @hidden
  74319. */
  74320. _isReady(): boolean;
  74321. }
  74322. }
  74323. declare module BABYLON {
  74324. /** @hidden */
  74325. export var displayPassPixelShader: {
  74326. name: string;
  74327. shader: string;
  74328. };
  74329. }
  74330. declare module BABYLON {
  74331. /**
  74332. * DisplayPassPostProcess which produces an output the same as it's input
  74333. */
  74334. export class DisplayPassPostProcess extends PostProcess {
  74335. /**
  74336. * Gets a string identifying the name of the class
  74337. * @returns "DisplayPassPostProcess" string
  74338. */
  74339. getClassName(): string;
  74340. /**
  74341. * Creates the DisplayPassPostProcess
  74342. * @param name The name of the effect.
  74343. * @param options The required width/height ratio to downsize to before computing the render pass.
  74344. * @param camera The camera to apply the render pass to.
  74345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74346. * @param engine The engine which the post process will be applied. (default: current engine)
  74347. * @param reusable If the post process can be reused on the same frame. (default: false)
  74348. */
  74349. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74350. /** @hidden */
  74351. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74352. }
  74353. }
  74354. declare module BABYLON {
  74355. /** @hidden */
  74356. export var filterPixelShader: {
  74357. name: string;
  74358. shader: string;
  74359. };
  74360. }
  74361. declare module BABYLON {
  74362. /**
  74363. * Applies a kernel filter to the image
  74364. */
  74365. export class FilterPostProcess extends PostProcess {
  74366. /** The matrix to be applied to the image */
  74367. kernelMatrix: Matrix;
  74368. /**
  74369. * Gets a string identifying the name of the class
  74370. * @returns "FilterPostProcess" string
  74371. */
  74372. getClassName(): string;
  74373. /**
  74374. *
  74375. * @param name The name of the effect.
  74376. * @param kernelMatrix The matrix to be applied to the image
  74377. * @param options The required width/height ratio to downsize to before computing the render pass.
  74378. * @param camera The camera to apply the render pass to.
  74379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74380. * @param engine The engine which the post process will be applied. (default: current engine)
  74381. * @param reusable If the post process can be reused on the same frame. (default: false)
  74382. */
  74383. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74384. /** @hidden */
  74385. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74386. }
  74387. }
  74388. declare module BABYLON {
  74389. /** @hidden */
  74390. export var fxaaPixelShader: {
  74391. name: string;
  74392. shader: string;
  74393. };
  74394. }
  74395. declare module BABYLON {
  74396. /** @hidden */
  74397. export var fxaaVertexShader: {
  74398. name: string;
  74399. shader: string;
  74400. };
  74401. }
  74402. declare module BABYLON {
  74403. /**
  74404. * Fxaa post process
  74405. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74406. */
  74407. export class FxaaPostProcess extends PostProcess {
  74408. /**
  74409. * Gets a string identifying the name of the class
  74410. * @returns "FxaaPostProcess" string
  74411. */
  74412. getClassName(): string;
  74413. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74414. private _getDefines;
  74415. /** @hidden */
  74416. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74417. }
  74418. }
  74419. declare module BABYLON {
  74420. /** @hidden */
  74421. export var grainPixelShader: {
  74422. name: string;
  74423. shader: string;
  74424. };
  74425. }
  74426. declare module BABYLON {
  74427. /**
  74428. * The GrainPostProcess adds noise to the image at mid luminance levels
  74429. */
  74430. export class GrainPostProcess extends PostProcess {
  74431. /**
  74432. * The intensity of the grain added (default: 30)
  74433. */
  74434. intensity: number;
  74435. /**
  74436. * If the grain should be randomized on every frame
  74437. */
  74438. animated: boolean;
  74439. /**
  74440. * Gets a string identifying the name of the class
  74441. * @returns "GrainPostProcess" string
  74442. */
  74443. getClassName(): string;
  74444. /**
  74445. * Creates a new instance of @see GrainPostProcess
  74446. * @param name The name of the effect.
  74447. * @param options The required width/height ratio to downsize to before computing the render pass.
  74448. * @param camera The camera to apply the render pass to.
  74449. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74450. * @param engine The engine which the post process will be applied. (default: current engine)
  74451. * @param reusable If the post process can be reused on the same frame. (default: false)
  74452. * @param textureType Type of textures used when performing the post process. (default: 0)
  74453. * @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)
  74454. */
  74455. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74456. /** @hidden */
  74457. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74458. }
  74459. }
  74460. declare module BABYLON {
  74461. /** @hidden */
  74462. export var highlightsPixelShader: {
  74463. name: string;
  74464. shader: string;
  74465. };
  74466. }
  74467. declare module BABYLON {
  74468. /**
  74469. * Extracts highlights from the image
  74470. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74471. */
  74472. export class HighlightsPostProcess extends PostProcess {
  74473. /**
  74474. * Gets a string identifying the name of the class
  74475. * @returns "HighlightsPostProcess" string
  74476. */
  74477. getClassName(): string;
  74478. /**
  74479. * Extracts highlights from the image
  74480. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74481. * @param name The name of the effect.
  74482. * @param options The required width/height ratio to downsize to before computing the render pass.
  74483. * @param camera The camera to apply the render pass to.
  74484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74485. * @param engine The engine which the post process will be applied. (default: current engine)
  74486. * @param reusable If the post process can be reused on the same frame. (default: false)
  74487. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74488. */
  74489. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74490. }
  74491. }
  74492. declare module BABYLON {
  74493. /**
  74494. * Contains all parameters needed for the prepass to perform
  74495. * motion blur
  74496. */
  74497. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74498. /**
  74499. * Is motion blur enabled
  74500. */
  74501. enabled: boolean;
  74502. /**
  74503. * Name of the configuration
  74504. */
  74505. name: string;
  74506. /**
  74507. * Textures that should be present in the MRT for this effect to work
  74508. */
  74509. readonly texturesRequired: number[];
  74510. }
  74511. }
  74512. declare module BABYLON {
  74513. interface Scene {
  74514. /** @hidden (Backing field) */
  74515. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74516. /**
  74517. * Gets or Sets the current geometry buffer associated to the scene.
  74518. */
  74519. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74520. /**
  74521. * Enables a GeometryBufferRender and associates it with the scene
  74522. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74523. * @returns the GeometryBufferRenderer
  74524. */
  74525. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74526. /**
  74527. * Disables the GeometryBufferRender associated with the scene
  74528. */
  74529. disableGeometryBufferRenderer(): void;
  74530. }
  74531. /**
  74532. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74533. * in several rendering techniques.
  74534. */
  74535. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74536. /**
  74537. * The component name helpful to identify the component in the list of scene components.
  74538. */
  74539. readonly name: string;
  74540. /**
  74541. * The scene the component belongs to.
  74542. */
  74543. scene: Scene;
  74544. /**
  74545. * Creates a new instance of the component for the given scene
  74546. * @param scene Defines the scene to register the component in
  74547. */
  74548. constructor(scene: Scene);
  74549. /**
  74550. * Registers the component in a given scene
  74551. */
  74552. register(): void;
  74553. /**
  74554. * Rebuilds the elements related to this component in case of
  74555. * context lost for instance.
  74556. */
  74557. rebuild(): void;
  74558. /**
  74559. * Disposes the component and the associated resources
  74560. */
  74561. dispose(): void;
  74562. private _gatherRenderTargets;
  74563. }
  74564. }
  74565. declare module BABYLON {
  74566. /** @hidden */
  74567. export var motionBlurPixelShader: {
  74568. name: string;
  74569. shader: string;
  74570. };
  74571. }
  74572. declare module BABYLON {
  74573. /**
  74574. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74575. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74576. * As an example, all you have to do is to create the post-process:
  74577. * var mb = new BABYLON.MotionBlurPostProcess(
  74578. * 'mb', // The name of the effect.
  74579. * scene, // The scene containing the objects to blur according to their velocity.
  74580. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74581. * camera // The camera to apply the render pass to.
  74582. * );
  74583. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74584. */
  74585. export class MotionBlurPostProcess extends PostProcess {
  74586. /**
  74587. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74588. */
  74589. motionStrength: number;
  74590. /**
  74591. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74592. */
  74593. get motionBlurSamples(): number;
  74594. /**
  74595. * Sets the number of iterations to be used for motion blur quality
  74596. */
  74597. set motionBlurSamples(samples: number);
  74598. private _motionBlurSamples;
  74599. /**
  74600. * Gets whether or not the motion blur post-process is in object based mode.
  74601. */
  74602. get isObjectBased(): boolean;
  74603. /**
  74604. * Sets whether or not the motion blur post-process is in object based mode.
  74605. */
  74606. set isObjectBased(value: boolean);
  74607. private _isObjectBased;
  74608. private _forceGeometryBuffer;
  74609. private _geometryBufferRenderer;
  74610. private _prePassRenderer;
  74611. private _invViewProjection;
  74612. private _previousViewProjection;
  74613. /**
  74614. * Gets a string identifying the name of the class
  74615. * @returns "MotionBlurPostProcess" string
  74616. */
  74617. getClassName(): string;
  74618. /**
  74619. * Creates a new instance MotionBlurPostProcess
  74620. * @param name The name of the effect.
  74621. * @param scene The scene containing the objects to blur according to their velocity.
  74622. * @param options The required width/height ratio to downsize to before computing the render pass.
  74623. * @param camera The camera to apply the render pass to.
  74624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74625. * @param engine The engine which the post process will be applied. (default: current engine)
  74626. * @param reusable If the post process can be reused on the same frame. (default: false)
  74627. * @param textureType Type of textures used when performing the post process. (default: 0)
  74628. * @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: true)
  74629. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74630. */
  74631. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74632. /**
  74633. * Excludes the given skinned mesh from computing bones velocities.
  74634. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  74635. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74636. */
  74637. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74638. /**
  74639. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74640. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74641. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74642. */
  74643. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74644. /**
  74645. * Disposes the post process.
  74646. * @param camera The camera to dispose the post process on.
  74647. */
  74648. dispose(camera?: Camera): void;
  74649. /**
  74650. * Called on the mode changed (object based or screen based).
  74651. */
  74652. private _applyMode;
  74653. /**
  74654. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74655. */
  74656. private _onApplyObjectBased;
  74657. /**
  74658. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74659. */
  74660. private _onApplyScreenBased;
  74661. /**
  74662. * Called on the effect must be updated (changed mode, samples count, etc.).
  74663. */
  74664. private _updateEffect;
  74665. /** @hidden */
  74666. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74667. }
  74668. }
  74669. declare module BABYLON {
  74670. /** @hidden */
  74671. export var refractionPixelShader: {
  74672. name: string;
  74673. shader: string;
  74674. };
  74675. }
  74676. declare module BABYLON {
  74677. /**
  74678. * Post process which applies a refraction texture
  74679. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74680. */
  74681. export class RefractionPostProcess extends PostProcess {
  74682. private _refTexture;
  74683. private _ownRefractionTexture;
  74684. /** the base color of the refraction (used to taint the rendering) */
  74685. color: Color3;
  74686. /** simulated refraction depth */
  74687. depth: number;
  74688. /** the coefficient of the base color (0 to remove base color tainting) */
  74689. colorLevel: number;
  74690. /** Gets the url used to load the refraction texture */
  74691. refractionTextureUrl: string;
  74692. /**
  74693. * Gets or sets the refraction texture
  74694. * Please note that you are responsible for disposing the texture if you set it manually
  74695. */
  74696. get refractionTexture(): Texture;
  74697. set refractionTexture(value: Texture);
  74698. /**
  74699. * Gets a string identifying the name of the class
  74700. * @returns "RefractionPostProcess" string
  74701. */
  74702. getClassName(): string;
  74703. /**
  74704. * Initializes the RefractionPostProcess
  74705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74706. * @param name The name of the effect.
  74707. * @param refractionTextureUrl Url of the refraction texture to use
  74708. * @param color the base color of the refraction (used to taint the rendering)
  74709. * @param depth simulated refraction depth
  74710. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74711. * @param camera The camera to apply the render pass to.
  74712. * @param options The required width/height ratio to downsize to before computing the render pass.
  74713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74714. * @param engine The engine which the post process will be applied. (default: current engine)
  74715. * @param reusable If the post process can be reused on the same frame. (default: false)
  74716. */
  74717. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74718. /**
  74719. * Disposes of the post process
  74720. * @param camera Camera to dispose post process on
  74721. */
  74722. dispose(camera: Camera): void;
  74723. /** @hidden */
  74724. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74725. }
  74726. }
  74727. declare module BABYLON {
  74728. /** @hidden */
  74729. export var sharpenPixelShader: {
  74730. name: string;
  74731. shader: string;
  74732. };
  74733. }
  74734. declare module BABYLON {
  74735. /**
  74736. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74737. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74738. */
  74739. export class SharpenPostProcess extends PostProcess {
  74740. /**
  74741. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74742. */
  74743. colorAmount: number;
  74744. /**
  74745. * How much sharpness should be applied (default: 0.3)
  74746. */
  74747. edgeAmount: number;
  74748. /**
  74749. * Gets a string identifying the name of the class
  74750. * @returns "SharpenPostProcess" string
  74751. */
  74752. getClassName(): string;
  74753. /**
  74754. * Creates a new instance ConvolutionPostProcess
  74755. * @param name The name of the effect.
  74756. * @param options The required width/height ratio to downsize to before computing the render pass.
  74757. * @param camera The camera to apply the render pass to.
  74758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74759. * @param engine The engine which the post process will be applied. (default: current engine)
  74760. * @param reusable If the post process can be reused on the same frame. (default: false)
  74761. * @param textureType Type of textures used when performing the post process. (default: 0)
  74762. * @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)
  74763. */
  74764. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74765. /** @hidden */
  74766. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74767. }
  74768. }
  74769. declare module BABYLON {
  74770. /**
  74771. * PostProcessRenderPipeline
  74772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74773. */
  74774. export class PostProcessRenderPipeline {
  74775. private engine;
  74776. private _renderEffects;
  74777. private _renderEffectsForIsolatedPass;
  74778. /**
  74779. * List of inspectable custom properties (used by the Inspector)
  74780. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74781. */
  74782. inspectableCustomProperties: IInspectable[];
  74783. /**
  74784. * @hidden
  74785. */
  74786. protected _cameras: Camera[];
  74787. /** @hidden */
  74788. _name: string;
  74789. /**
  74790. * Gets pipeline name
  74791. */
  74792. get name(): string;
  74793. /** Gets the list of attached cameras */
  74794. get cameras(): Camera[];
  74795. /**
  74796. * Initializes a PostProcessRenderPipeline
  74797. * @param engine engine to add the pipeline to
  74798. * @param name name of the pipeline
  74799. */
  74800. constructor(engine: Engine, name: string);
  74801. /**
  74802. * Gets the class name
  74803. * @returns "PostProcessRenderPipeline"
  74804. */
  74805. getClassName(): string;
  74806. /**
  74807. * If all the render effects in the pipeline are supported
  74808. */
  74809. get isSupported(): boolean;
  74810. /**
  74811. * Adds an effect to the pipeline
  74812. * @param renderEffect the effect to add
  74813. */
  74814. addEffect(renderEffect: PostProcessRenderEffect): void;
  74815. /** @hidden */
  74816. _rebuild(): void;
  74817. /** @hidden */
  74818. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74819. /** @hidden */
  74820. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74821. /** @hidden */
  74822. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74823. /** @hidden */
  74824. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74825. /** @hidden */
  74826. _attachCameras(cameras: Camera, unique: boolean): void;
  74827. /** @hidden */
  74828. _attachCameras(cameras: Camera[], unique: boolean): void;
  74829. /** @hidden */
  74830. _detachCameras(cameras: Camera): void;
  74831. /** @hidden */
  74832. _detachCameras(cameras: Nullable<Camera[]>): void;
  74833. /** @hidden */
  74834. _update(): void;
  74835. /** @hidden */
  74836. _reset(): void;
  74837. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74838. /**
  74839. * Sets the required values to the prepass renderer.
  74840. * @param prePassRenderer defines the prepass renderer to setup.
  74841. * @returns true if the pre pass is needed.
  74842. */
  74843. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74844. /**
  74845. * Disposes of the pipeline
  74846. */
  74847. dispose(): void;
  74848. }
  74849. }
  74850. declare module BABYLON {
  74851. /**
  74852. * PostProcessRenderPipelineManager class
  74853. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74854. */
  74855. export class PostProcessRenderPipelineManager {
  74856. private _renderPipelines;
  74857. /**
  74858. * Initializes a PostProcessRenderPipelineManager
  74859. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74860. */
  74861. constructor();
  74862. /**
  74863. * Gets the list of supported render pipelines
  74864. */
  74865. get supportedPipelines(): PostProcessRenderPipeline[];
  74866. /**
  74867. * Adds a pipeline to the manager
  74868. * @param renderPipeline The pipeline to add
  74869. */
  74870. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74871. /**
  74872. * Attaches a camera to the pipeline
  74873. * @param renderPipelineName The name of the pipeline to attach to
  74874. * @param cameras the camera to attach
  74875. * @param unique if the camera can be attached multiple times to the pipeline
  74876. */
  74877. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74878. /**
  74879. * Detaches a camera from the pipeline
  74880. * @param renderPipelineName The name of the pipeline to detach from
  74881. * @param cameras the camera to detach
  74882. */
  74883. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74884. /**
  74885. * Enables an effect by name on a pipeline
  74886. * @param renderPipelineName the name of the pipeline to enable the effect in
  74887. * @param renderEffectName the name of the effect to enable
  74888. * @param cameras the cameras that the effect should be enabled on
  74889. */
  74890. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74891. /**
  74892. * Disables an effect by name on a pipeline
  74893. * @param renderPipelineName the name of the pipeline to disable the effect in
  74894. * @param renderEffectName the name of the effect to disable
  74895. * @param cameras the cameras that the effect should be disabled on
  74896. */
  74897. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74898. /**
  74899. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74900. */
  74901. update(): void;
  74902. /** @hidden */
  74903. _rebuild(): void;
  74904. /**
  74905. * Disposes of the manager and pipelines
  74906. */
  74907. dispose(): void;
  74908. }
  74909. }
  74910. declare module BABYLON {
  74911. interface Scene {
  74912. /** @hidden (Backing field) */
  74913. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74914. /**
  74915. * Gets the postprocess render pipeline manager
  74916. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74917. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74918. */
  74919. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74920. }
  74921. /**
  74922. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74923. */
  74924. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74925. /**
  74926. * The component name helpful to identify the component in the list of scene components.
  74927. */
  74928. readonly name: string;
  74929. /**
  74930. * The scene the component belongs to.
  74931. */
  74932. scene: Scene;
  74933. /**
  74934. * Creates a new instance of the component for the given scene
  74935. * @param scene Defines the scene to register the component in
  74936. */
  74937. constructor(scene: Scene);
  74938. /**
  74939. * Registers the component in a given scene
  74940. */
  74941. register(): void;
  74942. /**
  74943. * Rebuilds the elements related to this component in case of
  74944. * context lost for instance.
  74945. */
  74946. rebuild(): void;
  74947. /**
  74948. * Disposes the component and the associated resources
  74949. */
  74950. dispose(): void;
  74951. private _gatherRenderTargets;
  74952. }
  74953. }
  74954. declare module BABYLON {
  74955. /**
  74956. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74957. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74958. */
  74959. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74960. private _scene;
  74961. private _camerasToBeAttached;
  74962. /**
  74963. * ID of the sharpen post process,
  74964. */
  74965. private readonly SharpenPostProcessId;
  74966. /**
  74967. * @ignore
  74968. * ID of the image processing post process;
  74969. */
  74970. readonly ImageProcessingPostProcessId: string;
  74971. /**
  74972. * @ignore
  74973. * ID of the Fast Approximate Anti-Aliasing post process;
  74974. */
  74975. readonly FxaaPostProcessId: string;
  74976. /**
  74977. * ID of the chromatic aberration post process,
  74978. */
  74979. private readonly ChromaticAberrationPostProcessId;
  74980. /**
  74981. * ID of the grain post process
  74982. */
  74983. private readonly GrainPostProcessId;
  74984. /**
  74985. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74986. */
  74987. sharpen: SharpenPostProcess;
  74988. private _sharpenEffect;
  74989. private bloom;
  74990. /**
  74991. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74992. */
  74993. depthOfField: DepthOfFieldEffect;
  74994. /**
  74995. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  74996. */
  74997. fxaa: FxaaPostProcess;
  74998. /**
  74999. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75000. */
  75001. imageProcessing: ImageProcessingPostProcess;
  75002. /**
  75003. * Chromatic aberration post process which will shift rgb colors in the image
  75004. */
  75005. chromaticAberration: ChromaticAberrationPostProcess;
  75006. private _chromaticAberrationEffect;
  75007. /**
  75008. * Grain post process which add noise to the image
  75009. */
  75010. grain: GrainPostProcess;
  75011. private _grainEffect;
  75012. /**
  75013. * Glow post process which adds a glow to emissive areas of the image
  75014. */
  75015. private _glowLayer;
  75016. /**
  75017. * Animations which can be used to tweak settings over a period of time
  75018. */
  75019. animations: Animation[];
  75020. private _imageProcessingConfigurationObserver;
  75021. private _sharpenEnabled;
  75022. private _bloomEnabled;
  75023. private _depthOfFieldEnabled;
  75024. private _depthOfFieldBlurLevel;
  75025. private _fxaaEnabled;
  75026. private _imageProcessingEnabled;
  75027. private _defaultPipelineTextureType;
  75028. private _bloomScale;
  75029. private _chromaticAberrationEnabled;
  75030. private _grainEnabled;
  75031. private _buildAllowed;
  75032. /**
  75033. * This is triggered each time the pipeline has been built.
  75034. */
  75035. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75036. /**
  75037. * Gets active scene
  75038. */
  75039. get scene(): Scene;
  75040. /**
  75041. * Enable or disable the sharpen process from the pipeline
  75042. */
  75043. set sharpenEnabled(enabled: boolean);
  75044. get sharpenEnabled(): boolean;
  75045. private _resizeObserver;
  75046. private _hardwareScaleLevel;
  75047. private _bloomKernel;
  75048. /**
  75049. * Specifies the size of the bloom blur kernel, relative to the final output size
  75050. */
  75051. get bloomKernel(): number;
  75052. set bloomKernel(value: number);
  75053. /**
  75054. * Specifies the weight of the bloom in the final rendering
  75055. */
  75056. private _bloomWeight;
  75057. /**
  75058. * Specifies the luma threshold for the area that will be blurred by the bloom
  75059. */
  75060. private _bloomThreshold;
  75061. private _hdr;
  75062. /**
  75063. * The strength of the bloom.
  75064. */
  75065. set bloomWeight(value: number);
  75066. get bloomWeight(): number;
  75067. /**
  75068. * The strength of the bloom.
  75069. */
  75070. set bloomThreshold(value: number);
  75071. get bloomThreshold(): number;
  75072. /**
  75073. * The scale of the bloom, lower value will provide better performance.
  75074. */
  75075. set bloomScale(value: number);
  75076. get bloomScale(): number;
  75077. /**
  75078. * Enable or disable the bloom from the pipeline
  75079. */
  75080. set bloomEnabled(enabled: boolean);
  75081. get bloomEnabled(): boolean;
  75082. private _rebuildBloom;
  75083. /**
  75084. * If the depth of field is enabled.
  75085. */
  75086. get depthOfFieldEnabled(): boolean;
  75087. set depthOfFieldEnabled(enabled: boolean);
  75088. /**
  75089. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75090. */
  75091. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75092. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75093. /**
  75094. * If the anti aliasing is enabled.
  75095. */
  75096. set fxaaEnabled(enabled: boolean);
  75097. get fxaaEnabled(): boolean;
  75098. private _samples;
  75099. /**
  75100. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75101. */
  75102. set samples(sampleCount: number);
  75103. get samples(): number;
  75104. /**
  75105. * If image processing is enabled.
  75106. */
  75107. set imageProcessingEnabled(enabled: boolean);
  75108. get imageProcessingEnabled(): boolean;
  75109. /**
  75110. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75111. */
  75112. set glowLayerEnabled(enabled: boolean);
  75113. get glowLayerEnabled(): boolean;
  75114. /**
  75115. * Gets the glow layer (or null if not defined)
  75116. */
  75117. get glowLayer(): Nullable<GlowLayer>;
  75118. /**
  75119. * Enable or disable the chromaticAberration process from the pipeline
  75120. */
  75121. set chromaticAberrationEnabled(enabled: boolean);
  75122. get chromaticAberrationEnabled(): boolean;
  75123. /**
  75124. * Enable or disable the grain process from the pipeline
  75125. */
  75126. set grainEnabled(enabled: boolean);
  75127. get grainEnabled(): boolean;
  75128. /**
  75129. * @constructor
  75130. * @param name - The rendering pipeline name (default: "")
  75131. * @param hdr - If high dynamic range textures should be used (default: true)
  75132. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75133. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75134. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75135. */
  75136. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75137. /**
  75138. * Get the class name
  75139. * @returns "DefaultRenderingPipeline"
  75140. */
  75141. getClassName(): string;
  75142. /**
  75143. * Force the compilation of the entire pipeline.
  75144. */
  75145. prepare(): void;
  75146. private _hasCleared;
  75147. private _prevPostProcess;
  75148. private _prevPrevPostProcess;
  75149. private _setAutoClearAndTextureSharing;
  75150. private _depthOfFieldSceneObserver;
  75151. private _buildPipeline;
  75152. private _disposePostProcesses;
  75153. /**
  75154. * Adds a camera to the pipeline
  75155. * @param camera the camera to be added
  75156. */
  75157. addCamera(camera: Camera): void;
  75158. /**
  75159. * Removes a camera from the pipeline
  75160. * @param camera the camera to remove
  75161. */
  75162. removeCamera(camera: Camera): void;
  75163. /**
  75164. * Dispose of the pipeline and stop all post processes
  75165. */
  75166. dispose(): void;
  75167. /**
  75168. * Serialize the rendering pipeline (Used when exporting)
  75169. * @returns the serialized object
  75170. */
  75171. serialize(): any;
  75172. /**
  75173. * Parse the serialized pipeline
  75174. * @param source Source pipeline.
  75175. * @param scene The scene to load the pipeline to.
  75176. * @param rootUrl The URL of the serialized pipeline.
  75177. * @returns An instantiated pipeline from the serialized object.
  75178. */
  75179. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75180. }
  75181. }
  75182. declare module BABYLON {
  75183. /** @hidden */
  75184. export var lensHighlightsPixelShader: {
  75185. name: string;
  75186. shader: string;
  75187. };
  75188. }
  75189. declare module BABYLON {
  75190. /** @hidden */
  75191. export var depthOfFieldPixelShader: {
  75192. name: string;
  75193. shader: string;
  75194. };
  75195. }
  75196. declare module BABYLON {
  75197. /**
  75198. * BABYLON.JS Chromatic Aberration GLSL Shader
  75199. * Author: Olivier Guyot
  75200. * Separates very slightly R, G and B colors on the edges of the screen
  75201. * Inspired by Francois Tarlier & Martins Upitis
  75202. */
  75203. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75204. /**
  75205. * @ignore
  75206. * The chromatic aberration PostProcess id in the pipeline
  75207. */
  75208. LensChromaticAberrationEffect: string;
  75209. /**
  75210. * @ignore
  75211. * The highlights enhancing PostProcess id in the pipeline
  75212. */
  75213. HighlightsEnhancingEffect: string;
  75214. /**
  75215. * @ignore
  75216. * The depth-of-field PostProcess id in the pipeline
  75217. */
  75218. LensDepthOfFieldEffect: string;
  75219. private _scene;
  75220. private _depthTexture;
  75221. private _grainTexture;
  75222. private _chromaticAberrationPostProcess;
  75223. private _highlightsPostProcess;
  75224. private _depthOfFieldPostProcess;
  75225. private _edgeBlur;
  75226. private _grainAmount;
  75227. private _chromaticAberration;
  75228. private _distortion;
  75229. private _highlightsGain;
  75230. private _highlightsThreshold;
  75231. private _dofDistance;
  75232. private _dofAperture;
  75233. private _dofDarken;
  75234. private _dofPentagon;
  75235. private _blurNoise;
  75236. /**
  75237. * @constructor
  75238. *
  75239. * Effect parameters are as follow:
  75240. * {
  75241. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75242. * edge_blur: number; // from 0 to x (1 for realism)
  75243. * distortion: number; // from 0 to x (1 for realism)
  75244. * grain_amount: number; // from 0 to 1
  75245. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75246. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75247. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75248. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75249. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75250. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75251. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75252. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75253. * }
  75254. * Note: if an effect parameter is unset, effect is disabled
  75255. *
  75256. * @param name The rendering pipeline name
  75257. * @param parameters - An object containing all parameters (see above)
  75258. * @param scene The scene linked to this pipeline
  75259. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  75260. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75261. */
  75262. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75263. /**
  75264. * Get the class name
  75265. * @returns "LensRenderingPipeline"
  75266. */
  75267. getClassName(): string;
  75268. /**
  75269. * Gets associated scene
  75270. */
  75271. get scene(): Scene;
  75272. /**
  75273. * Gets or sets the edge blur
  75274. */
  75275. get edgeBlur(): number;
  75276. set edgeBlur(value: number);
  75277. /**
  75278. * Gets or sets the grain amount
  75279. */
  75280. get grainAmount(): number;
  75281. set grainAmount(value: number);
  75282. /**
  75283. * Gets or sets the chromatic aberration amount
  75284. */
  75285. get chromaticAberration(): number;
  75286. set chromaticAberration(value: number);
  75287. /**
  75288. * Gets or sets the depth of field aperture
  75289. */
  75290. get dofAperture(): number;
  75291. set dofAperture(value: number);
  75292. /**
  75293. * Gets or sets the edge distortion
  75294. */
  75295. get edgeDistortion(): number;
  75296. set edgeDistortion(value: number);
  75297. /**
  75298. * Gets or sets the depth of field distortion
  75299. */
  75300. get dofDistortion(): number;
  75301. set dofDistortion(value: number);
  75302. /**
  75303. * Gets or sets the darken out of focus amount
  75304. */
  75305. get darkenOutOfFocus(): number;
  75306. set darkenOutOfFocus(value: number);
  75307. /**
  75308. * Gets or sets a boolean indicating if blur noise is enabled
  75309. */
  75310. get blurNoise(): boolean;
  75311. set blurNoise(value: boolean);
  75312. /**
  75313. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75314. */
  75315. get pentagonBokeh(): boolean;
  75316. set pentagonBokeh(value: boolean);
  75317. /**
  75318. * Gets or sets the highlight grain amount
  75319. */
  75320. get highlightsGain(): number;
  75321. set highlightsGain(value: number);
  75322. /**
  75323. * Gets or sets the highlight threshold
  75324. */
  75325. get highlightsThreshold(): number;
  75326. set highlightsThreshold(value: number);
  75327. /**
  75328. * Sets the amount of blur at the edges
  75329. * @param amount blur amount
  75330. */
  75331. setEdgeBlur(amount: number): void;
  75332. /**
  75333. * Sets edge blur to 0
  75334. */
  75335. disableEdgeBlur(): void;
  75336. /**
  75337. * Sets the amount of grain
  75338. * @param amount Amount of grain
  75339. */
  75340. setGrainAmount(amount: number): void;
  75341. /**
  75342. * Set grain amount to 0
  75343. */
  75344. disableGrain(): void;
  75345. /**
  75346. * Sets the chromatic aberration amount
  75347. * @param amount amount of chromatic aberration
  75348. */
  75349. setChromaticAberration(amount: number): void;
  75350. /**
  75351. * Sets chromatic aberration amount to 0
  75352. */
  75353. disableChromaticAberration(): void;
  75354. /**
  75355. * Sets the EdgeDistortion amount
  75356. * @param amount amount of EdgeDistortion
  75357. */
  75358. setEdgeDistortion(amount: number): void;
  75359. /**
  75360. * Sets edge distortion to 0
  75361. */
  75362. disableEdgeDistortion(): void;
  75363. /**
  75364. * Sets the FocusDistance amount
  75365. * @param amount amount of FocusDistance
  75366. */
  75367. setFocusDistance(amount: number): void;
  75368. /**
  75369. * Disables depth of field
  75370. */
  75371. disableDepthOfField(): void;
  75372. /**
  75373. * Sets the Aperture amount
  75374. * @param amount amount of Aperture
  75375. */
  75376. setAperture(amount: number): void;
  75377. /**
  75378. * Sets the DarkenOutOfFocus amount
  75379. * @param amount amount of DarkenOutOfFocus
  75380. */
  75381. setDarkenOutOfFocus(amount: number): void;
  75382. private _pentagonBokehIsEnabled;
  75383. /**
  75384. * Creates a pentagon bokeh effect
  75385. */
  75386. enablePentagonBokeh(): void;
  75387. /**
  75388. * Disables the pentagon bokeh effect
  75389. */
  75390. disablePentagonBokeh(): void;
  75391. /**
  75392. * Enables noise blur
  75393. */
  75394. enableNoiseBlur(): void;
  75395. /**
  75396. * Disables noise blur
  75397. */
  75398. disableNoiseBlur(): void;
  75399. /**
  75400. * Sets the HighlightsGain amount
  75401. * @param amount amount of HighlightsGain
  75402. */
  75403. setHighlightsGain(amount: number): void;
  75404. /**
  75405. * Sets the HighlightsThreshold amount
  75406. * @param amount amount of HighlightsThreshold
  75407. */
  75408. setHighlightsThreshold(amount: number): void;
  75409. /**
  75410. * Disables highlights
  75411. */
  75412. disableHighlights(): void;
  75413. /**
  75414. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75415. * @param disableDepthRender If the scene's depth rendering should be disabled (default: false)
  75416. */
  75417. dispose(disableDepthRender?: boolean): void;
  75418. private _createChromaticAberrationPostProcess;
  75419. private _createHighlightsPostProcess;
  75420. private _createDepthOfFieldPostProcess;
  75421. private _createGrainTexture;
  75422. }
  75423. }
  75424. declare module BABYLON {
  75425. /**
  75426. * Contains all parameters needed for the prepass to perform
  75427. * screen space subsurface scattering
  75428. */
  75429. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75430. /**
  75431. * Is subsurface enabled
  75432. */
  75433. enabled: boolean;
  75434. /**
  75435. * Name of the configuration
  75436. */
  75437. name: string;
  75438. /**
  75439. * Textures that should be present in the MRT for this effect to work
  75440. */
  75441. readonly texturesRequired: number[];
  75442. }
  75443. }
  75444. declare module BABYLON {
  75445. /** @hidden */
  75446. export var ssao2PixelShader: {
  75447. name: string;
  75448. shader: string;
  75449. };
  75450. }
  75451. declare module BABYLON {
  75452. /** @hidden */
  75453. export var ssaoCombinePixelShader: {
  75454. name: string;
  75455. shader: string;
  75456. };
  75457. }
  75458. declare module BABYLON {
  75459. /**
  75460. * Render pipeline to produce ssao effect
  75461. */
  75462. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75463. /**
  75464. * @ignore
  75465. * The PassPostProcess id in the pipeline that contains the original scene color
  75466. */
  75467. SSAOOriginalSceneColorEffect: string;
  75468. /**
  75469. * @ignore
  75470. * The SSAO PostProcess id in the pipeline
  75471. */
  75472. SSAORenderEffect: string;
  75473. /**
  75474. * @ignore
  75475. * The horizontal blur PostProcess id in the pipeline
  75476. */
  75477. SSAOBlurHRenderEffect: string;
  75478. /**
  75479. * @ignore
  75480. * The vertical blur PostProcess id in the pipeline
  75481. */
  75482. SSAOBlurVRenderEffect: string;
  75483. /**
  75484. * @ignore
  75485. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75486. */
  75487. SSAOCombineRenderEffect: string;
  75488. /**
  75489. * The output strength of the SSAO post-process. Default value is 1.0.
  75490. */
  75491. totalStrength: number;
  75492. /**
  75493. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75494. */
  75495. maxZ: number;
  75496. /**
  75497. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75498. */
  75499. minZAspect: number;
  75500. private _samples;
  75501. /**
  75502. * Number of samples used for the SSAO calculations. Default value is 8
  75503. */
  75504. set samples(n: number);
  75505. get samples(): number;
  75506. private _textureSamples;
  75507. /**
  75508. * Number of samples to use for antialiasing
  75509. */
  75510. set textureSamples(n: number);
  75511. get textureSamples(): number;
  75512. /**
  75513. * Force rendering the geometry through geometry buffer
  75514. */
  75515. private _forceGeometryBuffer;
  75516. /**
  75517. * Ratio object used for SSAO ratio and blur ratio
  75518. */
  75519. private _ratio;
  75520. /**
  75521. * Dynamically generated sphere sampler.
  75522. */
  75523. private _sampleSphere;
  75524. /**
  75525. * Blur filter offsets
  75526. */
  75527. private _samplerOffsets;
  75528. private _expensiveBlur;
  75529. /**
  75530. * If bilateral blur should be used
  75531. */
  75532. set expensiveBlur(b: boolean);
  75533. get expensiveBlur(): boolean;
  75534. /**
  75535. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75536. */
  75537. radius: number;
  75538. /**
  75539. * The base color of the SSAO post-process
  75540. * The final result is "base + ssao" between [0, 1]
  75541. */
  75542. base: number;
  75543. /**
  75544. * Support test.
  75545. */
  75546. static get IsSupported(): boolean;
  75547. private _scene;
  75548. private _randomTexture;
  75549. private _originalColorPostProcess;
  75550. private _ssaoPostProcess;
  75551. private _blurHPostProcess;
  75552. private _blurVPostProcess;
  75553. private _ssaoCombinePostProcess;
  75554. private _prePassRenderer;
  75555. /**
  75556. * Gets active scene
  75557. */
  75558. get scene(): Scene;
  75559. /**
  75560. * @constructor
  75561. * @param name The rendering pipeline name
  75562. * @param scene The scene linked to this pipeline
  75563. * @param ratio The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, blurRatio: 1.0 }
  75564. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75565. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75566. */
  75567. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75568. /**
  75569. * Get the class name
  75570. * @returns "SSAO2RenderingPipeline"
  75571. */
  75572. getClassName(): string;
  75573. /**
  75574. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75575. */
  75576. dispose(disableGeometryBufferRenderer?: boolean): void;
  75577. private _createBlurPostProcess;
  75578. /** @hidden */
  75579. _rebuild(): void;
  75580. private _bits;
  75581. private _radicalInverse_VdC;
  75582. private _hammersley;
  75583. private _hemisphereSample_uniform;
  75584. private _generateHemisphere;
  75585. private _getDefinesForSSAO;
  75586. private static readonly ORTHO_DEPTH_PROJECTION;
  75587. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75588. private _createSSAOPostProcess;
  75589. private _createSSAOCombinePostProcess;
  75590. private _createRandomTexture;
  75591. /**
  75592. * Serialize the rendering pipeline (Used when exporting)
  75593. * @returns the serialized object
  75594. */
  75595. serialize(): any;
  75596. /**
  75597. * Parse the serialized pipeline
  75598. * @param source Source pipeline.
  75599. * @param scene The scene to load the pipeline to.
  75600. * @param rootUrl The URL of the serialized pipeline.
  75601. * @returns An instantiated pipeline from the serialized object.
  75602. */
  75603. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75604. }
  75605. }
  75606. declare module BABYLON {
  75607. /** @hidden */
  75608. export var ssaoPixelShader: {
  75609. name: string;
  75610. shader: string;
  75611. };
  75612. }
  75613. declare module BABYLON {
  75614. /**
  75615. * Render pipeline to produce ssao effect
  75616. */
  75617. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75618. /**
  75619. * @ignore
  75620. * The PassPostProcess id in the pipeline that contains the original scene color
  75621. */
  75622. SSAOOriginalSceneColorEffect: string;
  75623. /**
  75624. * @ignore
  75625. * The SSAO PostProcess id in the pipeline
  75626. */
  75627. SSAORenderEffect: string;
  75628. /**
  75629. * @ignore
  75630. * The horizontal blur PostProcess id in the pipeline
  75631. */
  75632. SSAOBlurHRenderEffect: string;
  75633. /**
  75634. * @ignore
  75635. * The vertical blur PostProcess id in the pipeline
  75636. */
  75637. SSAOBlurVRenderEffect: string;
  75638. /**
  75639. * @ignore
  75640. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75641. */
  75642. SSAOCombineRenderEffect: string;
  75643. /**
  75644. * The output strength of the SSAO post-process. Default value is 1.0.
  75645. */
  75646. totalStrength: number;
  75647. /**
  75648. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75649. */
  75650. radius: number;
  75651. /**
  75652. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75653. * Must not be equal to fallOff and superior to fallOff.
  75654. * Default value is 0.0075
  75655. */
  75656. area: number;
  75657. /**
  75658. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75659. * Must not be equal to area and inferior to area.
  75660. * Default value is 0.000001
  75661. */
  75662. fallOff: number;
  75663. /**
  75664. * The base color of the SSAO post-process
  75665. * The final result is "base + ssao" between [0, 1]
  75666. */
  75667. base: number;
  75668. private _scene;
  75669. private _depthTexture;
  75670. private _randomTexture;
  75671. private _originalColorPostProcess;
  75672. private _ssaoPostProcess;
  75673. private _blurHPostProcess;
  75674. private _blurVPostProcess;
  75675. private _ssaoCombinePostProcess;
  75676. private _firstUpdate;
  75677. /**
  75678. * Gets active scene
  75679. */
  75680. get scene(): Scene;
  75681. /**
  75682. * @constructor
  75683. * @param name - The rendering pipeline name
  75684. * @param scene - The scene linked to this pipeline
  75685. * @param ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  75686. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75687. */
  75688. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75689. /**
  75690. * Get the class name
  75691. * @returns "SSAORenderingPipeline"
  75692. */
  75693. getClassName(): string;
  75694. /**
  75695. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75696. */
  75697. dispose(disableDepthRender?: boolean): void;
  75698. private _createBlurPostProcess;
  75699. /** @hidden */
  75700. _rebuild(): void;
  75701. private _createSSAOPostProcess;
  75702. private _createSSAOCombinePostProcess;
  75703. private _createRandomTexture;
  75704. }
  75705. }
  75706. declare module BABYLON {
  75707. /**
  75708. * Contains all parameters needed for the prepass to perform
  75709. * screen space reflections
  75710. */
  75711. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75712. /**
  75713. * Is ssr enabled
  75714. */
  75715. enabled: boolean;
  75716. /**
  75717. * Name of the configuration
  75718. */
  75719. name: string;
  75720. /**
  75721. * Textures that should be present in the MRT for this effect to work
  75722. */
  75723. readonly texturesRequired: number[];
  75724. }
  75725. }
  75726. declare module BABYLON {
  75727. /** @hidden */
  75728. export var screenSpaceReflectionPixelShader: {
  75729. name: string;
  75730. shader: string;
  75731. };
  75732. }
  75733. declare module BABYLON {
  75734. /**
  75735. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75736. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75737. */
  75738. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75739. /**
  75740. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75741. */
  75742. threshold: number;
  75743. /**
  75744. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75745. */
  75746. strength: number;
  75747. /**
  75748. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75749. */
  75750. reflectionSpecularFalloffExponent: number;
  75751. /**
  75752. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  75753. */
  75754. step: number;
  75755. /**
  75756. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75757. */
  75758. roughnessFactor: number;
  75759. private _forceGeometryBuffer;
  75760. private _geometryBufferRenderer;
  75761. private _prePassRenderer;
  75762. private _enableSmoothReflections;
  75763. private _reflectionSamples;
  75764. private _smoothSteps;
  75765. /**
  75766. * Gets a string identifying the name of the class
  75767. * @returns "ScreenSpaceReflectionPostProcess" string
  75768. */
  75769. getClassName(): string;
  75770. /**
  75771. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75772. * @param name The name of the effect.
  75773. * @param scene The scene containing the objects to calculate reflections.
  75774. * @param options The required width/height ratio to downsize to before computing the render pass.
  75775. * @param camera The camera to apply the render pass to.
  75776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75777. * @param engine The engine which the post process will be applied. (default: current engine)
  75778. * @param reusable If the post process can be reused on the same frame. (default: false)
  75779. * @param textureType Type of textures used when performing the post process. (default: 0)
  75780. * @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: true)
  75781. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75782. */
  75783. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75784. /**
  75785. * Gets whether or not smoothing reflections is enabled.
  75786. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75787. */
  75788. get enableSmoothReflections(): boolean;
  75789. /**
  75790. * Sets whether or not smoothing reflections is enabled.
  75791. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75792. */
  75793. set enableSmoothReflections(enabled: boolean);
  75794. /**
  75795. * Gets the number of samples taken while computing reflections. More samples count is high,
  75796. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75797. */
  75798. get reflectionSamples(): number;
  75799. /**
  75800. * Sets the number of samples taken while computing reflections. More samples count is high,
  75801. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75802. */
  75803. set reflectionSamples(samples: number);
  75804. /**
  75805. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75806. * more the post-process will require GPU power and can generate a drop in FPS.
  75807. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75808. */
  75809. get smoothSteps(): number;
  75810. set smoothSteps(steps: number);
  75811. private _updateEffectDefines;
  75812. /** @hidden */
  75813. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75814. }
  75815. }
  75816. declare module BABYLON {
  75817. /** @hidden */
  75818. export var standardPixelShader: {
  75819. name: string;
  75820. shader: string;
  75821. };
  75822. }
  75823. declare module BABYLON {
  75824. /**
  75825. * Standard rendering pipeline
  75826. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75827. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75828. */
  75829. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75830. /**
  75831. * Public members
  75832. */
  75833. /**
  75834. * Post-process which contains the original scene color before the pipeline applies all the effects
  75835. */
  75836. originalPostProcess: Nullable<PostProcess>;
  75837. /**
  75838. * Post-process used to down scale an image x4
  75839. */
  75840. downSampleX4PostProcess: Nullable<PostProcess>;
  75841. /**
  75842. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75843. */
  75844. brightPassPostProcess: Nullable<PostProcess>;
  75845. /**
  75846. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75847. */
  75848. blurHPostProcesses: PostProcess[];
  75849. /**
  75850. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75851. */
  75852. blurVPostProcesses: PostProcess[];
  75853. /**
  75854. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75855. */
  75856. textureAdderPostProcess: Nullable<PostProcess>;
  75857. /**
  75858. * Post-process used to create volumetric lighting effect
  75859. */
  75860. volumetricLightPostProcess: Nullable<PostProcess>;
  75861. /**
  75862. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75863. */
  75864. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75865. /**
  75866. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75867. */
  75868. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75869. /**
  75870. * Post-process used to merge the volumetric light effect and the real scene color
  75871. */
  75872. volumetricLightMergePostProces: Nullable<PostProcess>;
  75873. /**
  75874. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75875. */
  75876. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75877. /**
  75878. * Base post-process used to calculate the average luminance of the final image for HDR
  75879. */
  75880. luminancePostProcess: Nullable<PostProcess>;
  75881. /**
  75882. * Post-processes used to create down sample post-processes in order to get
  75883. * the average luminance of the final image for HDR
  75884. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75885. */
  75886. luminanceDownSamplePostProcesses: PostProcess[];
  75887. /**
  75888. * Post-process used to create a HDR effect (light adaptation)
  75889. */
  75890. hdrPostProcess: Nullable<PostProcess>;
  75891. /**
  75892. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75893. */
  75894. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75895. /**
  75896. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75897. */
  75898. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75899. /**
  75900. * Post-process used to merge the final HDR post-process and the real scene color
  75901. */
  75902. hdrFinalPostProcess: Nullable<PostProcess>;
  75903. /**
  75904. * Post-process used to create a lens flare effect
  75905. */
  75906. lensFlarePostProcess: Nullable<PostProcess>;
  75907. /**
  75908. * Post-process that merges the result of the lens flare post-process and the real scene color
  75909. */
  75910. lensFlareComposePostProcess: Nullable<PostProcess>;
  75911. /**
  75912. * Post-process used to create a motion blur effect
  75913. */
  75914. motionBlurPostProcess: Nullable<PostProcess>;
  75915. /**
  75916. * Post-process used to create a depth of field effect
  75917. */
  75918. depthOfFieldPostProcess: Nullable<PostProcess>;
  75919. /**
  75920. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  75921. */
  75922. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75923. /**
  75924. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75925. */
  75926. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75927. /**
  75928. * Represents the brightness threshold in order to configure the illuminated surfaces
  75929. */
  75930. brightThreshold: number;
  75931. /**
  75932. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75933. */
  75934. blurWidth: number;
  75935. /**
  75936. * Sets if the blur for highlighted surfaces must be only horizontal
  75937. */
  75938. horizontalBlur: boolean;
  75939. /**
  75940. * Gets the overall exposure used by the pipeline
  75941. */
  75942. get exposure(): number;
  75943. /**
  75944. * Sets the overall exposure used by the pipeline
  75945. */
  75946. set exposure(value: number);
  75947. /**
  75948. * Texture used typically to simulate "dirty" on camera lens
  75949. */
  75950. lensTexture: Nullable<Texture>;
  75951. /**
  75952. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75953. */
  75954. volumetricLightCoefficient: number;
  75955. /**
  75956. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75957. */
  75958. volumetricLightPower: number;
  75959. /**
  75960. * Used the set the blur intensity to smooth the volumetric lights
  75961. */
  75962. volumetricLightBlurScale: number;
  75963. /**
  75964. * Light (spot or directional) used to generate the volumetric lights rays
  75965. * The source light must have a shadow generate so the pipeline can get its
  75966. * depth map
  75967. */
  75968. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75969. /**
  75970. * For eye adaptation, represents the minimum luminance the eye can see
  75971. */
  75972. hdrMinimumLuminance: number;
  75973. /**
  75974. * For eye adaptation, represents the decrease luminance speed
  75975. */
  75976. hdrDecreaseRate: number;
  75977. /**
  75978. * For eye adaptation, represents the increase luminance speed
  75979. */
  75980. hdrIncreaseRate: number;
  75981. /**
  75982. * Gets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75983. */
  75984. get hdrAutoExposure(): boolean;
  75985. /**
  75986. * Sets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75987. */
  75988. set hdrAutoExposure(value: boolean);
  75989. /**
  75990. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75991. */
  75992. lensColorTexture: Nullable<Texture>;
  75993. /**
  75994. * The overall strengh for the lens flare effect
  75995. */
  75996. lensFlareStrength: number;
  75997. /**
  75998. * Dispersion coefficient for lens flare ghosts
  75999. */
  76000. lensFlareGhostDispersal: number;
  76001. /**
  76002. * Main lens flare halo width
  76003. */
  76004. lensFlareHaloWidth: number;
  76005. /**
  76006. * Based on the lens distortion effect, defines how much the lens flare result
  76007. * is distorted
  76008. */
  76009. lensFlareDistortionStrength: number;
  76010. /**
  76011. * Configures the blur intensity used for for lens flare (halo)
  76012. */
  76013. lensFlareBlurWidth: number;
  76014. /**
  76015. * Lens star texture must be used to simulate rays on the flares and is available
  76016. * in the documentation
  76017. */
  76018. lensStarTexture: Nullable<Texture>;
  76019. /**
  76020. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76021. * flare effect by taking account of the dirt texture
  76022. */
  76023. lensFlareDirtTexture: Nullable<Texture>;
  76024. /**
  76025. * Represents the focal length for the depth of field effect
  76026. */
  76027. depthOfFieldDistance: number;
  76028. /**
  76029. * Represents the blur intensity for the blurred part of the depth of field effect
  76030. */
  76031. depthOfFieldBlurWidth: number;
  76032. /**
  76033. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76034. */
  76035. get motionStrength(): number;
  76036. /**
  76037. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76038. */
  76039. set motionStrength(strength: number);
  76040. /**
  76041. * Gets whether or not the motion blur post-process is object based or screen based.
  76042. */
  76043. get objectBasedMotionBlur(): boolean;
  76044. /**
  76045. * Sets whether or not the motion blur post-process should be object based or screen based
  76046. */
  76047. set objectBasedMotionBlur(value: boolean);
  76048. /**
  76049. * List of animations for the pipeline (IAnimatable implementation)
  76050. */
  76051. animations: Animation[];
  76052. /**
  76053. * Private members
  76054. */
  76055. private _scene;
  76056. private _currentDepthOfFieldSource;
  76057. private _basePostProcess;
  76058. private _fixedExposure;
  76059. private _currentExposure;
  76060. private _hdrAutoExposure;
  76061. private _hdrCurrentLuminance;
  76062. private _motionStrength;
  76063. private _isObjectBasedMotionBlur;
  76064. private _floatTextureType;
  76065. private _camerasToBeAttached;
  76066. private _ratio;
  76067. private _bloomEnabled;
  76068. private _depthOfFieldEnabled;
  76069. private _vlsEnabled;
  76070. private _lensFlareEnabled;
  76071. private _hdrEnabled;
  76072. private _motionBlurEnabled;
  76073. private _fxaaEnabled;
  76074. private _screenSpaceReflectionsEnabled;
  76075. private _motionBlurSamples;
  76076. private _volumetricLightStepsCount;
  76077. private _samples;
  76078. /**
  76079. * @ignore
  76080. * Specifies if the bloom pipeline is enabled
  76081. */
  76082. get BloomEnabled(): boolean;
  76083. set BloomEnabled(enabled: boolean);
  76084. /**
  76085. * @ignore
  76086. * Specifies if the depth of field pipeline is enabled
  76087. */
  76088. get DepthOfFieldEnabled(): boolean;
  76089. set DepthOfFieldEnabled(enabled: boolean);
  76090. /**
  76091. * @ignore
  76092. * Specifies if the lens flare pipeline is enabled
  76093. */
  76094. get LensFlareEnabled(): boolean;
  76095. set LensFlareEnabled(enabled: boolean);
  76096. /**
  76097. * @ignore
  76098. * Specifies if the HDR pipeline is enabled
  76099. */
  76100. get HDREnabled(): boolean;
  76101. set HDREnabled(enabled: boolean);
  76102. /**
  76103. * @ignore
  76104. * Specifies if the volumetric lights scattering effect is enabled
  76105. */
  76106. get VLSEnabled(): boolean;
  76107. set VLSEnabled(enabled: boolean);
  76108. /**
  76109. * @ignore
  76110. * Specifies if the motion blur effect is enabled
  76111. */
  76112. get MotionBlurEnabled(): boolean;
  76113. set MotionBlurEnabled(enabled: boolean);
  76114. /**
  76115. * Specifies if anti-aliasing is enabled
  76116. */
  76117. get fxaaEnabled(): boolean;
  76118. set fxaaEnabled(enabled: boolean);
  76119. /**
  76120. * Specifies if screen space reflections are enabled.
  76121. */
  76122. get screenSpaceReflectionsEnabled(): boolean;
  76123. set screenSpaceReflectionsEnabled(enabled: boolean);
  76124. /**
  76125. * Specifies the number of steps used to calculate the volumetric lights
  76126. * Typically in interval [50, 200]
  76127. */
  76128. get volumetricLightStepsCount(): number;
  76129. set volumetricLightStepsCount(count: number);
  76130. /**
  76131. * Specifies the number of samples used for the motion blur effect
  76132. * Typically in interval [16, 64]
  76133. */
  76134. get motionBlurSamples(): number;
  76135. set motionBlurSamples(samples: number);
  76136. /**
  76137. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76138. */
  76139. get samples(): number;
  76140. set samples(sampleCount: number);
  76141. /**
  76142. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76143. * @constructor
  76144. * @param name The rendering pipeline name
  76145. * @param scene The scene linked to this pipeline
  76146. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  76147. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76148. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76149. */
  76150. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76151. private _buildPipeline;
  76152. private _createDownSampleX4PostProcess;
  76153. private _createBrightPassPostProcess;
  76154. private _createBlurPostProcesses;
  76155. private _createTextureAdderPostProcess;
  76156. private _createVolumetricLightPostProcess;
  76157. private _createLuminancePostProcesses;
  76158. private _createHdrPostProcess;
  76159. private _createLensFlarePostProcess;
  76160. private _createDepthOfFieldPostProcess;
  76161. private _createMotionBlurPostProcess;
  76162. private _getDepthTexture;
  76163. private _disposePostProcesses;
  76164. /**
  76165. * Dispose of the pipeline and stop all post processes
  76166. */
  76167. dispose(): void;
  76168. /**
  76169. * Serialize the rendering pipeline (Used when exporting)
  76170. * @returns the serialized object
  76171. */
  76172. serialize(): any;
  76173. /**
  76174. * Parse the serialized pipeline
  76175. * @param source Source pipeline.
  76176. * @param scene The scene to load the pipeline to.
  76177. * @param rootUrl The URL of the serialized pipeline.
  76178. * @returns An instantiated pipeline from the serialized object.
  76179. */
  76180. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76181. /**
  76182. * Luminance steps
  76183. */
  76184. static LuminanceSteps: number;
  76185. }
  76186. }
  76187. declare module BABYLON {
  76188. /** @hidden */
  76189. export var tonemapPixelShader: {
  76190. name: string;
  76191. shader: string;
  76192. };
  76193. }
  76194. declare module BABYLON {
  76195. /** Defines operator used for tonemapping */
  76196. export enum TonemappingOperator {
  76197. /** Hable */
  76198. Hable = 0,
  76199. /** Reinhard */
  76200. Reinhard = 1,
  76201. /** HejiDawson */
  76202. HejiDawson = 2,
  76203. /** Photographic */
  76204. Photographic = 3
  76205. }
  76206. /**
  76207. * Defines a post process to apply tone mapping
  76208. */
  76209. export class TonemapPostProcess extends PostProcess {
  76210. private _operator;
  76211. /** Defines the required exposure adjustment */
  76212. exposureAdjustment: number;
  76213. /**
  76214. * Gets a string identifying the name of the class
  76215. * @returns "TonemapPostProcess" string
  76216. */
  76217. getClassName(): string;
  76218. /**
  76219. * Creates a new TonemapPostProcess
  76220. * @param name defines the name of the postprocess
  76221. * @param _operator defines the operator to use
  76222. * @param exposureAdjustment defines the required exposure adjustement
  76223. * @param camera defines the camera to use (can be null)
  76224. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76225. * @param engine defines the hosting engine (can be ignore if camera is set)
  76226. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76227. */
  76228. constructor(name: string, _operator: TonemappingOperator,
  76229. /** Defines the required exposure adjustment */
  76230. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76231. }
  76232. }
  76233. declare module BABYLON {
  76234. /** @hidden */
  76235. export var volumetricLightScatteringPixelShader: {
  76236. name: string;
  76237. shader: string;
  76238. };
  76239. }
  76240. declare module BABYLON {
  76241. /** @hidden */
  76242. export var volumetricLightScatteringPassVertexShader: {
  76243. name: string;
  76244. shader: string;
  76245. };
  76246. }
  76247. declare module BABYLON {
  76248. /** @hidden */
  76249. export var volumetricLightScatteringPassPixelShader: {
  76250. name: string;
  76251. shader: string;
  76252. };
  76253. }
  76254. declare module BABYLON {
  76255. /**
  76256. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76257. */
  76258. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76259. private _volumetricLightScatteringPass;
  76260. private _volumetricLightScatteringRTT;
  76261. private _viewPort;
  76262. private _screenCoordinates;
  76263. private _cachedDefines;
  76264. /**
  76265. * If not undefined, the mesh position is computed from the attached node position
  76266. */
  76267. attachedNode: {
  76268. position: Vector3;
  76269. };
  76270. /**
  76271. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76272. */
  76273. customMeshPosition: Vector3;
  76274. /**
  76275. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76276. */
  76277. useCustomMeshPosition: boolean;
  76278. /**
  76279. * If the post-process should inverse the light scattering direction
  76280. */
  76281. invert: boolean;
  76282. /**
  76283. * The internal mesh used by the post-process
  76284. */
  76285. mesh: Mesh;
  76286. /**
  76287. * @hidden
  76288. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76289. */
  76290. get useDiffuseColor(): boolean;
  76291. set useDiffuseColor(useDiffuseColor: boolean);
  76292. /**
  76293. * Array containing the excluded meshes not rendered in the internal pass
  76294. */
  76295. excludedMeshes: AbstractMesh[];
  76296. /**
  76297. * Controls the overall intensity of the post-process
  76298. */
  76299. exposure: number;
  76300. /**
  76301. * Dissipates each sample's contribution in range [0, 1]
  76302. */
  76303. decay: number;
  76304. /**
  76305. * Controls the overall intensity of each sample
  76306. */
  76307. weight: number;
  76308. /**
  76309. * Controls the density of each sample
  76310. */
  76311. density: number;
  76312. /**
  76313. * @constructor
  76314. * @param name The post-process name
  76315. * @param ratio The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  76316. * @param camera The camera that the post-process will be attached to
  76317. * @param mesh The mesh used to create the light scattering
  76318. * @param samples The post-process quality, default 100
  76319. * @param samplingModeThe post-process filtering mode
  76320. * @param engine The babylon engine
  76321. * @param reusable If the post-process is reusable
  76322. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76323. */
  76324. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76325. /**
  76326. * Returns the string "VolumetricLightScatteringPostProcess"
  76327. * @returns "VolumetricLightScatteringPostProcess"
  76328. */
  76329. getClassName(): string;
  76330. private _isReady;
  76331. /**
  76332. * Sets the new light position for light scattering effect
  76333. * @param position The new custom light position
  76334. */
  76335. setCustomMeshPosition(position: Vector3): void;
  76336. /**
  76337. * Returns the light position for light scattering effect
  76338. * @return Vector3 The custom light position
  76339. */
  76340. getCustomMeshPosition(): Vector3;
  76341. /**
  76342. * Disposes the internal assets and detaches the post-process from the camera
  76343. */
  76344. dispose(camera: Camera): void;
  76345. /**
  76346. * Returns the render target texture used by the post-process
  76347. * @return the render target texture used by the post-process
  76348. */
  76349. getPass(): RenderTargetTexture;
  76350. private _meshExcluded;
  76351. private _createPass;
  76352. private _updateMeshScreenCoordinates;
  76353. /**
  76354. * Creates a default mesh for the Volumeric Light Scattering post-process
  76355. * @param name The mesh name
  76356. * @param scene The scene where to create the mesh
  76357. * @return the default mesh
  76358. */
  76359. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76360. }
  76361. }
  76362. declare module BABYLON {
  76363. /** @hidden */
  76364. export var screenSpaceCurvaturePixelShader: {
  76365. name: string;
  76366. shader: string;
  76367. };
  76368. }
  76369. declare module BABYLON {
  76370. /**
  76371. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76372. */
  76373. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76374. /**
  76375. * Defines how much ridge the curvature effect displays.
  76376. */
  76377. ridge: number;
  76378. /**
  76379. * Defines how much valley the curvature effect displays.
  76380. */
  76381. valley: number;
  76382. private _geometryBufferRenderer;
  76383. /**
  76384. * Gets a string identifying the name of the class
  76385. * @returns "ScreenSpaceCurvaturePostProcess" string
  76386. */
  76387. getClassName(): string;
  76388. /**
  76389. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76390. * @param name The name of the effect.
  76391. * @param scene The scene containing the objects to blur according to their velocity.
  76392. * @param options The required width/height ratio to downsize to before computing the render pass.
  76393. * @param camera The camera to apply the render pass to.
  76394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76395. * @param engine The engine which the post process will be applied. (default: current engine)
  76396. * @param reusable If the post process can be reused on the same frame. (default: false)
  76397. * @param textureType Type of textures used when performing the post process. (default: 0)
  76398. * @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)
  76399. */
  76400. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76401. /**
  76402. * Support test.
  76403. */
  76404. static get IsSupported(): boolean;
  76405. /** @hidden */
  76406. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76407. }
  76408. }
  76409. declare module BABYLON {
  76410. interface Scene {
  76411. /** @hidden (Backing field) */
  76412. _boundingBoxRenderer: BoundingBoxRenderer;
  76413. /** @hidden (Backing field) */
  76414. _forceShowBoundingBoxes: boolean;
  76415. /**
  76416. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76417. */
  76418. forceShowBoundingBoxes: boolean;
  76419. /**
  76420. * Gets the bounding box renderer associated with the scene
  76421. * @returns a BoundingBoxRenderer
  76422. */
  76423. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76424. }
  76425. interface AbstractMesh {
  76426. /** @hidden (Backing field) */
  76427. _showBoundingBox: boolean;
  76428. /**
  76429. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76430. */
  76431. showBoundingBox: boolean;
  76432. }
  76433. /**
  76434. * Component responsible of rendering the bounding box of the meshes in a scene.
  76435. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76436. */
  76437. export class BoundingBoxRenderer implements ISceneComponent {
  76438. /**
  76439. * The component name helpful to identify the component in the list of scene components.
  76440. */
  76441. readonly name: string;
  76442. /**
  76443. * The scene the component belongs to.
  76444. */
  76445. scene: Scene;
  76446. /**
  76447. * Color of the bounding box lines placed in front of an object
  76448. */
  76449. frontColor: Color3;
  76450. /**
  76451. * Color of the bounding box lines placed behind an object
  76452. */
  76453. backColor: Color3;
  76454. /**
  76455. * Defines if the renderer should show the back lines or not
  76456. */
  76457. showBackLines: boolean;
  76458. /**
  76459. * Observable raised before rendering a bounding box
  76460. */
  76461. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76462. /**
  76463. * Observable raised after rendering a bounding box
  76464. */
  76465. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76466. /**
  76467. * Observable raised after resources are created
  76468. */
  76469. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76470. /**
  76471. * When false, no bounding boxes will be rendered
  76472. */
  76473. enabled: boolean;
  76474. /**
  76475. * @hidden
  76476. */
  76477. renderList: SmartArray<BoundingBox>;
  76478. private _colorShader;
  76479. private _vertexBuffers;
  76480. private _indexBuffer;
  76481. private _fillIndexBuffer;
  76482. private _fillIndexData;
  76483. /**
  76484. * Instantiates a new bounding box renderer in a scene.
  76485. * @param scene the scene the renderer renders in
  76486. */
  76487. constructor(scene: Scene);
  76488. /**
  76489. * Registers the component in a given scene
  76490. */
  76491. register(): void;
  76492. private _evaluateSubMesh;
  76493. private _preActiveMesh;
  76494. private _prepareResources;
  76495. private _createIndexBuffer;
  76496. /**
  76497. * Rebuilds the elements related to this component in case of
  76498. * context lost for instance.
  76499. */
  76500. rebuild(): void;
  76501. /**
  76502. * @hidden
  76503. */
  76504. reset(): void;
  76505. /**
  76506. * Render the bounding boxes of a specific rendering group
  76507. * @param renderingGroupId defines the rendering group to render
  76508. */
  76509. render(renderingGroupId: number): void;
  76510. /**
  76511. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76512. * @param mesh Define the mesh to render the occlusion bounding box for
  76513. */
  76514. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76515. /**
  76516. * Dispose and release the resources attached to this renderer.
  76517. */
  76518. dispose(): void;
  76519. }
  76520. }
  76521. declare module BABYLON {
  76522. interface Scene {
  76523. /** @hidden (Backing field) */
  76524. _depthRenderer: {
  76525. [id: string]: DepthRenderer;
  76526. };
  76527. /**
  76528. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76529. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76530. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76531. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76532. * @returns the created depth renderer
  76533. */
  76534. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76535. /**
  76536. * Disables a depth renderer for a given camera
  76537. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76538. */
  76539. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76540. }
  76541. /**
  76542. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76543. * in several rendering techniques.
  76544. */
  76545. export class DepthRendererSceneComponent implements ISceneComponent {
  76546. /**
  76547. * The component name helpful to identify the component in the list of scene components.
  76548. */
  76549. readonly name: string;
  76550. /**
  76551. * The scene the component belongs to.
  76552. */
  76553. scene: Scene;
  76554. /**
  76555. * Creates a new instance of the component for the given scene
  76556. * @param scene Defines the scene to register the component in
  76557. */
  76558. constructor(scene: Scene);
  76559. /**
  76560. * Registers the component in a given scene
  76561. */
  76562. register(): void;
  76563. /**
  76564. * Rebuilds the elements related to this component in case of
  76565. * context lost for instance.
  76566. */
  76567. rebuild(): void;
  76568. /**
  76569. * Disposes the component and the associated resources
  76570. */
  76571. dispose(): void;
  76572. private _gatherRenderTargets;
  76573. private _gatherActiveCameraRenderTargets;
  76574. }
  76575. }
  76576. declare module BABYLON {
  76577. interface AbstractScene {
  76578. /** @hidden (Backing field) */
  76579. _prePassRenderer: Nullable<PrePassRenderer>;
  76580. /**
  76581. * Gets or Sets the current prepass renderer associated to the scene.
  76582. */
  76583. prePassRenderer: Nullable<PrePassRenderer>;
  76584. /**
  76585. * Enables the prepass and associates it with the scene
  76586. * @returns the PrePassRenderer
  76587. */
  76588. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76589. /**
  76590. * Disables the prepass associated with the scene
  76591. */
  76592. disablePrePassRenderer(): void;
  76593. }
  76594. interface RenderTargetTexture {
  76595. /** @hidden */
  76596. _prePassRenderTarget: PrePassRenderTarget;
  76597. }
  76598. /**
  76599. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76600. * in several rendering techniques.
  76601. */
  76602. export class PrePassRendererSceneComponent implements ISceneComponent {
  76603. /**
  76604. * The component name helpful to identify the component in the list of scene components.
  76605. */
  76606. readonly name: string;
  76607. /**
  76608. * The scene the component belongs to.
  76609. */
  76610. scene: Scene;
  76611. /**
  76612. * Creates a new instance of the component for the given scene
  76613. * @param scene Defines the scene to register the component in
  76614. */
  76615. constructor(scene: Scene);
  76616. /**
  76617. * Registers the component in a given scene
  76618. */
  76619. register(): void;
  76620. private _beforeRenderTargetDraw;
  76621. private _afterRenderTargetDraw;
  76622. private _beforeRenderTargetClearStage;
  76623. private _beforeCameraDraw;
  76624. private _afterCameraDraw;
  76625. private _beforeClearStage;
  76626. private _beforeRenderingMeshStage;
  76627. private _afterRenderingMeshStage;
  76628. /**
  76629. * Rebuilds the elements related to this component in case of
  76630. * context lost for instance.
  76631. */
  76632. rebuild(): void;
  76633. /**
  76634. * Disposes the component and the associated resources
  76635. */
  76636. dispose(): void;
  76637. }
  76638. }
  76639. declare module BABYLON {
  76640. /** @hidden */
  76641. export var fibonacci: {
  76642. name: string;
  76643. shader: string;
  76644. };
  76645. }
  76646. declare module BABYLON {
  76647. /** @hidden */
  76648. export var diffusionProfile: {
  76649. name: string;
  76650. shader: string;
  76651. };
  76652. }
  76653. declare module BABYLON {
  76654. /** @hidden */
  76655. export var subSurfaceScatteringPixelShader: {
  76656. name: string;
  76657. shader: string;
  76658. };
  76659. }
  76660. declare module BABYLON {
  76661. /**
  76662. * Sub surface scattering post process
  76663. */
  76664. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76665. /**
  76666. * Gets a string identifying the name of the class
  76667. * @returns "SubSurfaceScatteringPostProcess" string
  76668. */
  76669. getClassName(): string;
  76670. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76671. }
  76672. }
  76673. declare module BABYLON {
  76674. /**
  76675. * Contains all parameters needed for the prepass to perform
  76676. * screen space subsurface scattering
  76677. */
  76678. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76679. /** @hidden */
  76680. static _SceneComponentInitialization: (scene: Scene) => void;
  76681. private _ssDiffusionS;
  76682. private _ssFilterRadii;
  76683. private _ssDiffusionD;
  76684. /**
  76685. * Post process to attach for screen space subsurface scattering
  76686. */
  76687. postProcess: SubSurfaceScatteringPostProcess;
  76688. /**
  76689. * Diffusion profile color for subsurface scattering
  76690. */
  76691. get ssDiffusionS(): number[];
  76692. /**
  76693. * Diffusion profile max color channel value for subsurface scattering
  76694. */
  76695. get ssDiffusionD(): number[];
  76696. /**
  76697. * Diffusion profile filter radius for subsurface scattering
  76698. */
  76699. get ssFilterRadii(): number[];
  76700. /**
  76701. * Is subsurface enabled
  76702. */
  76703. enabled: boolean;
  76704. /**
  76705. * Does the output of this prepass need to go through imageprocessing
  76706. */
  76707. needsImageProcessing: boolean;
  76708. /**
  76709. * Name of the configuration
  76710. */
  76711. name: string;
  76712. /**
  76713. * Diffusion profile colors for subsurface scattering
  76714. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76715. * See ...
  76716. * Note that you can only store up to 5 of them
  76717. */
  76718. ssDiffusionProfileColors: Color3[];
  76719. /**
  76720. * Defines the ratio real world => scene units.
  76721. * Used for subsurface scattering
  76722. */
  76723. metersPerUnit: number;
  76724. /**
  76725. * Textures that should be present in the MRT for this effect to work
  76726. */
  76727. readonly texturesRequired: number[];
  76728. private _scene;
  76729. /**
  76730. * Builds a subsurface configuration object
  76731. * @param scene The scene
  76732. */
  76733. constructor(scene: Scene);
  76734. /**
  76735. * Adds a new diffusion profile.
  76736. * Useful for more realistic subsurface scattering on diverse materials.
  76737. * @param color The color of the diffusion profile. Should be the average color of the material.
  76738. * @return The index of the diffusion profile for the material subsurface configuration
  76739. */
  76740. addDiffusionProfile(color: Color3): number;
  76741. /**
  76742. * Creates the sss post process
  76743. * @return The created post process
  76744. */
  76745. createPostProcess(): SubSurfaceScatteringPostProcess;
  76746. /**
  76747. * Deletes all diffusion profiles.
  76748. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76749. */
  76750. clearAllDiffusionProfiles(): void;
  76751. /**
  76752. * Disposes this object
  76753. */
  76754. dispose(): void;
  76755. /**
  76756. * @hidden
  76757. * https://zero-radiance.github.io/post/sampling-diffusion/
  76758. *
  76759. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76760. * ------------------------------------------------------------------------------------
  76761. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76762. * PDF[r, phi, s] = r * R[r, phi, s]
  76763. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76764. * ------------------------------------------------------------------------------------
  76765. * We importance sample the color channel with the widest scattering distance.
  76766. */
  76767. getDiffusionProfileParameters(color: Color3): number;
  76768. /**
  76769. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76770. * 'u' is the random number (the value of the CDF): [0, 1).
  76771. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76772. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76773. */
  76774. private _sampleBurleyDiffusionProfile;
  76775. }
  76776. }
  76777. declare module BABYLON {
  76778. interface AbstractScene {
  76779. /** @hidden (Backing field) */
  76780. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76781. /**
  76782. * Gets or Sets the current prepass renderer associated to the scene.
  76783. */
  76784. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76785. /**
  76786. * Enables the subsurface effect for prepass
  76787. * @returns the SubSurfaceConfiguration
  76788. */
  76789. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76790. /**
  76791. * Disables the subsurface effect for prepass
  76792. */
  76793. disableSubSurfaceForPrePass(): void;
  76794. }
  76795. /**
  76796. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76797. * in several rendering techniques.
  76798. */
  76799. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76800. /**
  76801. * The component name helpful to identify the component in the list of scene components.
  76802. */
  76803. readonly name: string;
  76804. /**
  76805. * The scene the component belongs to.
  76806. */
  76807. scene: Scene;
  76808. /**
  76809. * Creates a new instance of the component for the given scene
  76810. * @param scene Defines the scene to register the component in
  76811. */
  76812. constructor(scene: Scene);
  76813. /**
  76814. * Registers the component in a given scene
  76815. */
  76816. register(): void;
  76817. /**
  76818. * Serializes the component data to the specified json object
  76819. * @param serializationObject The object to serialize to
  76820. */
  76821. serialize(serializationObject: any): void;
  76822. /**
  76823. * Adds all the elements from the container to the scene
  76824. * @param container the container holding the elements
  76825. */
  76826. addFromContainer(container: AbstractScene): void;
  76827. /**
  76828. * Removes all the elements in the container from the scene
  76829. * @param container contains the elements to remove
  76830. * @param dispose if the removed element should be disposed (default: false)
  76831. */
  76832. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76833. /**
  76834. * Rebuilds the elements related to this component in case of
  76835. * context lost for instance.
  76836. */
  76837. rebuild(): void;
  76838. /**
  76839. * Disposes the component and the associated resources
  76840. */
  76841. dispose(): void;
  76842. }
  76843. }
  76844. declare module BABYLON {
  76845. /** @hidden */
  76846. export var outlinePixelShader: {
  76847. name: string;
  76848. shader: string;
  76849. };
  76850. }
  76851. declare module BABYLON {
  76852. /** @hidden */
  76853. export var outlineVertexShader: {
  76854. name: string;
  76855. shader: string;
  76856. };
  76857. }
  76858. declare module BABYLON {
  76859. interface Scene {
  76860. /** @hidden */
  76861. _outlineRenderer: OutlineRenderer;
  76862. /**
  76863. * Gets the outline renderer associated with the scene
  76864. * @returns a OutlineRenderer
  76865. */
  76866. getOutlineRenderer(): OutlineRenderer;
  76867. }
  76868. interface AbstractMesh {
  76869. /** @hidden (Backing field) */
  76870. _renderOutline: boolean;
  76871. /**
  76872. * Gets or sets a boolean indicating if the outline must be rendered as well
  76873. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76874. */
  76875. renderOutline: boolean;
  76876. /** @hidden (Backing field) */
  76877. _renderOverlay: boolean;
  76878. /**
  76879. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76880. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76881. */
  76882. renderOverlay: boolean;
  76883. }
  76884. /**
  76885. * This class is responsible to draw the outline/overlay of meshes.
  76886. * It should not be used directly but through the available method on mesh.
  76887. */
  76888. export class OutlineRenderer implements ISceneComponent {
  76889. /**
  76890. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76891. */
  76892. private static _StencilReference;
  76893. /**
  76894. * The name of the component. Each component must have a unique name.
  76895. */
  76896. name: string;
  76897. /**
  76898. * The scene the component belongs to.
  76899. */
  76900. scene: Scene;
  76901. /**
  76902. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76903. */
  76904. zOffset: number;
  76905. private _engine;
  76906. private _effect;
  76907. private _cachedDefines;
  76908. private _savedDepthWrite;
  76909. /**
  76910. * Instantiates a new outline renderer. (There could be only one per scene).
  76911. * @param scene Defines the scene it belongs to
  76912. */
  76913. constructor(scene: Scene);
  76914. /**
  76915. * Register the component to one instance of a scene.
  76916. */
  76917. register(): void;
  76918. /**
  76919. * Rebuilds the elements related to this component in case of
  76920. * context lost for instance.
  76921. */
  76922. rebuild(): void;
  76923. /**
  76924. * Disposes the component and the associated resources.
  76925. */
  76926. dispose(): void;
  76927. /**
  76928. * Renders the outline in the canvas.
  76929. * @param subMesh Defines the sumesh to render
  76930. * @param batch Defines the batch of meshes in case of instances
  76931. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76932. */
  76933. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76934. /**
  76935. * Returns whether or not the outline renderer is ready for a given submesh.
  76936. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76937. * @param subMesh Defines the submesh to check readiness for
  76938. * @param useInstances Defines whether wee are trying to render instances or not
  76939. * @returns true if ready otherwise false
  76940. */
  76941. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76942. private _beforeRenderingMesh;
  76943. private _afterRenderingMesh;
  76944. }
  76945. }
  76946. declare module BABYLON {
  76947. /**
  76948. * Defines the basic options interface of a Sprite Frame Source Size.
  76949. */
  76950. export interface ISpriteJSONSpriteSourceSize {
  76951. /**
  76952. * number of the original width of the Frame
  76953. */
  76954. w: number;
  76955. /**
  76956. * number of the original height of the Frame
  76957. */
  76958. h: number;
  76959. }
  76960. /**
  76961. * Defines the basic options interface of a Sprite Frame Data.
  76962. */
  76963. export interface ISpriteJSONSpriteFrameData {
  76964. /**
  76965. * number of the x offset of the Frame
  76966. */
  76967. x: number;
  76968. /**
  76969. * number of the y offset of the Frame
  76970. */
  76971. y: number;
  76972. /**
  76973. * number of the width of the Frame
  76974. */
  76975. w: number;
  76976. /**
  76977. * number of the height of the Frame
  76978. */
  76979. h: number;
  76980. }
  76981. /**
  76982. * Defines the basic options interface of a JSON Sprite.
  76983. */
  76984. export interface ISpriteJSONSprite {
  76985. /**
  76986. * string name of the Frame
  76987. */
  76988. filename: string;
  76989. /**
  76990. * ISpriteJSONSpriteFrame basic object of the frame data
  76991. */
  76992. frame: ISpriteJSONSpriteFrameData;
  76993. /**
  76994. * boolean to flag is the frame was rotated.
  76995. */
  76996. rotated: boolean;
  76997. /**
  76998. * boolean to flag is the frame was trimmed.
  76999. */
  77000. trimmed: boolean;
  77001. /**
  77002. * ISpriteJSONSpriteFrame basic object of the source data
  77003. */
  77004. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77005. /**
  77006. * ISpriteJSONSpriteFrame basic object of the source data
  77007. */
  77008. sourceSize: ISpriteJSONSpriteSourceSize;
  77009. }
  77010. /**
  77011. * Defines the basic options interface of a JSON atlas.
  77012. */
  77013. export interface ISpriteJSONAtlas {
  77014. /**
  77015. * Array of objects that contain the frame data.
  77016. */
  77017. frames: Array<ISpriteJSONSprite>;
  77018. /**
  77019. * object basic object containing the sprite meta data.
  77020. */
  77021. meta?: object;
  77022. }
  77023. }
  77024. declare module BABYLON {
  77025. /** @hidden */
  77026. export var spriteMapPixelShader: {
  77027. name: string;
  77028. shader: string;
  77029. };
  77030. }
  77031. declare module BABYLON {
  77032. /** @hidden */
  77033. export var spriteMapVertexShader: {
  77034. name: string;
  77035. shader: string;
  77036. };
  77037. }
  77038. declare module BABYLON {
  77039. /**
  77040. * Defines the basic options interface of a SpriteMap
  77041. */
  77042. export interface ISpriteMapOptions {
  77043. /**
  77044. * Vector2 of the number of cells in the grid.
  77045. */
  77046. stageSize?: Vector2;
  77047. /**
  77048. * Vector2 of the size of the output plane in World Units.
  77049. */
  77050. outputSize?: Vector2;
  77051. /**
  77052. * Vector3 of the position of the output plane in World Units.
  77053. */
  77054. outputPosition?: Vector3;
  77055. /**
  77056. * Vector3 of the rotation of the output plane.
  77057. */
  77058. outputRotation?: Vector3;
  77059. /**
  77060. * number of layers that the system will reserve in resources.
  77061. */
  77062. layerCount?: number;
  77063. /**
  77064. * number of max animation frames a single cell will reserve in resources.
  77065. */
  77066. maxAnimationFrames?: number;
  77067. /**
  77068. * number cell index of the base tile when the system compiles.
  77069. */
  77070. baseTile?: number;
  77071. /**
  77072. * boolean flip the sprite after its been repositioned by the framing data.
  77073. */
  77074. flipU?: boolean;
  77075. /**
  77076. * Vector3 scalar of the global RGB values of the SpriteMap.
  77077. */
  77078. colorMultiply?: Vector3;
  77079. }
  77080. /**
  77081. * Defines the IDisposable interface in order to be cleanable from resources.
  77082. */
  77083. export interface ISpriteMap extends IDisposable {
  77084. /**
  77085. * String name of the SpriteMap.
  77086. */
  77087. name: string;
  77088. /**
  77089. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77090. */
  77091. atlasJSON: ISpriteJSONAtlas;
  77092. /**
  77093. * Texture of the SpriteMap.
  77094. */
  77095. spriteSheet: Texture;
  77096. /**
  77097. * The parameters to initialize the SpriteMap with.
  77098. */
  77099. options: ISpriteMapOptions;
  77100. }
  77101. /**
  77102. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77103. */
  77104. export class SpriteMap implements ISpriteMap {
  77105. /** The Name of the spriteMap */
  77106. name: string;
  77107. /** The JSON file with the frame and meta data */
  77108. atlasJSON: ISpriteJSONAtlas;
  77109. /** The systems Sprite Sheet Texture */
  77110. spriteSheet: Texture;
  77111. /** Arguments passed with the Constructor */
  77112. options: ISpriteMapOptions;
  77113. /** Public Sprite Storage array, parsed from atlasJSON */
  77114. sprites: Array<ISpriteJSONSprite>;
  77115. /** Returns the Number of Sprites in the System */
  77116. get spriteCount(): number;
  77117. /** Returns the Position of Output Plane*/
  77118. get position(): Vector3;
  77119. /** Returns the Position of Output Plane*/
  77120. set position(v: Vector3);
  77121. /** Returns the Rotation of Output Plane*/
  77122. get rotation(): Vector3;
  77123. /** Returns the Rotation of Output Plane*/
  77124. set rotation(v: Vector3);
  77125. /** Sets the AnimationMap*/
  77126. get animationMap(): RawTexture;
  77127. /** Sets the AnimationMap*/
  77128. set animationMap(v: RawTexture);
  77129. /** Scene that the SpriteMap was created in */
  77130. private _scene;
  77131. /** Texture Buffer of Float32 that holds tile frame data*/
  77132. private _frameMap;
  77133. /** Texture Buffers of Float32 that holds tileMap data*/
  77134. private _tileMaps;
  77135. /** Texture Buffer of Float32 that holds Animation Data*/
  77136. private _animationMap;
  77137. /** Custom ShaderMaterial Central to the System*/
  77138. private _material;
  77139. /** Custom ShaderMaterial Central to the System*/
  77140. private _output;
  77141. /** Systems Time Ticker*/
  77142. private _time;
  77143. /**
  77144. * Creates a new SpriteMap
  77145. * @param name defines the SpriteMaps Name
  77146. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77147. * @param spriteSheet is the Texture that the Sprites are on.
  77148. * @param options a basic deployment configuration
  77149. * @param scene The Scene that the map is deployed on
  77150. */
  77151. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77152. /**
  77153. * Returns tileID location
  77154. * @returns Vector2 the cell position ID
  77155. */
  77156. getTileID(): Vector2;
  77157. /**
  77158. * Gets the UV location of the mouse over the SpriteMap.
  77159. * @returns Vector2 the UV position of the mouse interaction
  77160. */
  77161. getMousePosition(): Vector2;
  77162. /**
  77163. * Creates the "frame" texture Buffer
  77164. * -------------------------------------
  77165. * Structure of frames
  77166. * "filename": "Falling-Water-2.png",
  77167. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77168. * "rotated": true,
  77169. * "trimmed": true,
  77170. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77171. * "sourceSize": {"w":32,"h":32}
  77172. * @returns RawTexture of the frameMap
  77173. */
  77174. private _createFrameBuffer;
  77175. /**
  77176. * Creates the tileMap texture Buffer
  77177. * @param buffer normally and array of numbers, or a false to generate from scratch
  77178. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77179. * @returns RawTexture of the tileMap
  77180. */
  77181. private _createTileBuffer;
  77182. /**
  77183. * Modifies the data of the tileMaps
  77184. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77185. * @param pos is the iVector2 Coordinates of the Tile
  77186. * @param tile The SpriteIndex of the new Tile
  77187. */
  77188. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77189. /**
  77190. * Creates the animationMap texture Buffer
  77191. * @param buffer normally and array of numbers, or a false to generate from scratch
  77192. * @returns RawTexture of the animationMap
  77193. */
  77194. private _createTileAnimationBuffer;
  77195. /**
  77196. * Modifies the data of the animationMap
  77197. * @param cellID is the Index of the Sprite
  77198. * @param _frame is the target Animation frame
  77199. * @param toCell is the Target Index of the next frame of the animation
  77200. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77201. * @param speed is a global scalar of the time variable on the map.
  77202. */
  77203. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77204. /**
  77205. * Exports the .tilemaps file
  77206. */
  77207. saveTileMaps(): void;
  77208. /**
  77209. * Imports the .tilemaps file
  77210. * @param url of the .tilemaps file
  77211. */
  77212. loadTileMaps(url: string): void;
  77213. /**
  77214. * Release associated resources
  77215. */
  77216. dispose(): void;
  77217. }
  77218. }
  77219. declare module BABYLON {
  77220. /**
  77221. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77222. * @see https://doc.babylonjs.com/babylon101/sprites
  77223. */
  77224. export class SpritePackedManager extends SpriteManager {
  77225. /** defines the packed manager's name */
  77226. name: string;
  77227. /**
  77228. * Creates a new sprite manager from a packed sprite sheet
  77229. * @param name defines the manager's name
  77230. * @param imgUrl defines the sprite sheet url
  77231. * @param capacity defines the maximum allowed number of sprites
  77232. * @param scene defines the hosting scene
  77233. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77234. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77235. * @param samplingMode defines the sampling mode to use with spritesheet
  77236. * @param fromPacked set to true; do not alter
  77237. */
  77238. constructor(
  77239. /** defines the packed manager's name */
  77240. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77241. }
  77242. }
  77243. declare module BABYLON {
  77244. /**
  77245. * Defines the list of states available for a task inside a AssetsManager
  77246. */
  77247. export enum AssetTaskState {
  77248. /**
  77249. * Initialization
  77250. */
  77251. INIT = 0,
  77252. /**
  77253. * Running
  77254. */
  77255. RUNNING = 1,
  77256. /**
  77257. * Done
  77258. */
  77259. DONE = 2,
  77260. /**
  77261. * Error
  77262. */
  77263. ERROR = 3
  77264. }
  77265. /**
  77266. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77267. */
  77268. export abstract class AbstractAssetTask {
  77269. /**
  77270. * Task name
  77271. */ name: string;
  77272. /**
  77273. * Callback called when the task is successful
  77274. */
  77275. onSuccess: (task: any) => void;
  77276. /**
  77277. * Callback called when the task is not successful
  77278. */
  77279. onError: (task: any, message?: string, exception?: any) => void;
  77280. /**
  77281. * Creates a new AssetsManager
  77282. * @param name defines the name of the task
  77283. */
  77284. constructor(
  77285. /**
  77286. * Task name
  77287. */ name: string);
  77288. private _isCompleted;
  77289. private _taskState;
  77290. private _errorObject;
  77291. /**
  77292. * Get if the task is completed
  77293. */
  77294. get isCompleted(): boolean;
  77295. /**
  77296. * Gets the current state of the task
  77297. */
  77298. get taskState(): AssetTaskState;
  77299. /**
  77300. * Gets the current error object (if task is in error)
  77301. */
  77302. get errorObject(): {
  77303. message?: string;
  77304. exception?: any;
  77305. };
  77306. /**
  77307. * Internal only
  77308. * @hidden
  77309. */
  77310. _setErrorObject(message?: string, exception?: any): void;
  77311. /**
  77312. * Execute the current task
  77313. * @param scene defines the scene where you want your assets to be loaded
  77314. * @param onSuccess is a callback called when the task is successfully executed
  77315. * @param onError is a callback called if an error occurs
  77316. */
  77317. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77318. /**
  77319. * Execute the current task
  77320. * @param scene defines the scene where you want your assets to be loaded
  77321. * @param onSuccess is a callback called when the task is successfully executed
  77322. * @param onError is a callback called if an error occurs
  77323. */
  77324. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77325. /**
  77326. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77327. * This can be used with failed tasks that have the reason for failure fixed.
  77328. */
  77329. reset(): void;
  77330. private onErrorCallback;
  77331. private onDoneCallback;
  77332. }
  77333. /**
  77334. * Define the interface used by progress events raised during assets loading
  77335. */
  77336. export interface IAssetsProgressEvent {
  77337. /**
  77338. * Defines the number of remaining tasks to process
  77339. */
  77340. remainingCount: number;
  77341. /**
  77342. * Defines the total number of tasks
  77343. */
  77344. totalCount: number;
  77345. /**
  77346. * Defines the task that was just processed
  77347. */
  77348. task: AbstractAssetTask;
  77349. }
  77350. /**
  77351. * Class used to share progress information about assets loading
  77352. */
  77353. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77354. /**
  77355. * Defines the number of remaining tasks to process
  77356. */
  77357. remainingCount: number;
  77358. /**
  77359. * Defines the total number of tasks
  77360. */
  77361. totalCount: number;
  77362. /**
  77363. * Defines the task that was just processed
  77364. */
  77365. task: AbstractAssetTask;
  77366. /**
  77367. * Creates a AssetsProgressEvent
  77368. * @param remainingCount defines the number of remaining tasks to process
  77369. * @param totalCount defines the total number of tasks
  77370. * @param task defines the task that was just processed
  77371. */
  77372. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77373. }
  77374. /**
  77375. * Define a task used by AssetsManager to load assets into a container
  77376. */
  77377. export class ContainerAssetTask extends AbstractAssetTask {
  77378. /**
  77379. * Defines the name of the task
  77380. */
  77381. name: string;
  77382. /**
  77383. * Defines the list of mesh's names you want to load
  77384. */
  77385. meshesNames: any;
  77386. /**
  77387. * Defines the root url to use as a base to load your meshes and associated resources
  77388. */
  77389. rootUrl: string;
  77390. /**
  77391. * Defines the filename or File of the scene to load from
  77392. */
  77393. sceneFilename: string | File;
  77394. /**
  77395. * Get the loaded asset container
  77396. */
  77397. loadedContainer: AssetContainer;
  77398. /**
  77399. * Gets the list of loaded meshes
  77400. */
  77401. loadedMeshes: Array<AbstractMesh>;
  77402. /**
  77403. * Gets the list of loaded particle systems
  77404. */
  77405. loadedParticleSystems: Array<IParticleSystem>;
  77406. /**
  77407. * Gets the list of loaded skeletons
  77408. */
  77409. loadedSkeletons: Array<Skeleton>;
  77410. /**
  77411. * Gets the list of loaded animation groups
  77412. */
  77413. loadedAnimationGroups: Array<AnimationGroup>;
  77414. /**
  77415. * Callback called when the task is successful
  77416. */
  77417. onSuccess: (task: ContainerAssetTask) => void;
  77418. /**
  77419. * Callback called when the task is successful
  77420. */
  77421. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77422. /**
  77423. * Creates a new ContainerAssetTask
  77424. * @param name defines the name of the task
  77425. * @param meshesNames defines the list of mesh's names you want to load
  77426. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77427. * @param sceneFilename defines the filename or File of the scene to load from
  77428. */
  77429. constructor(
  77430. /**
  77431. * Defines the name of the task
  77432. */
  77433. name: string,
  77434. /**
  77435. * Defines the list of mesh's names you want to load
  77436. */
  77437. meshesNames: any,
  77438. /**
  77439. * Defines the root url to use as a base to load your meshes and associated resources
  77440. */
  77441. rootUrl: string,
  77442. /**
  77443. * Defines the filename or File of the scene to load from
  77444. */
  77445. sceneFilename: string | File);
  77446. /**
  77447. * Execute the current task
  77448. * @param scene defines the scene where you want your assets to be loaded
  77449. * @param onSuccess is a callback called when the task is successfully executed
  77450. * @param onError is a callback called if an error occurs
  77451. */
  77452. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77453. }
  77454. /**
  77455. * Define a task used by AssetsManager to load meshes
  77456. */
  77457. export class MeshAssetTask extends AbstractAssetTask {
  77458. /**
  77459. * Defines the name of the task
  77460. */
  77461. name: string;
  77462. /**
  77463. * Defines the list of mesh's names you want to load
  77464. */
  77465. meshesNames: any;
  77466. /**
  77467. * Defines the root url to use as a base to load your meshes and associated resources
  77468. */
  77469. rootUrl: string;
  77470. /**
  77471. * Defines the filename or File of the scene to load from
  77472. */
  77473. sceneFilename: string | File;
  77474. /**
  77475. * Gets the list of loaded meshes
  77476. */
  77477. loadedMeshes: Array<AbstractMesh>;
  77478. /**
  77479. * Gets the list of loaded particle systems
  77480. */
  77481. loadedParticleSystems: Array<IParticleSystem>;
  77482. /**
  77483. * Gets the list of loaded skeletons
  77484. */
  77485. loadedSkeletons: Array<Skeleton>;
  77486. /**
  77487. * Gets the list of loaded animation groups
  77488. */
  77489. loadedAnimationGroups: Array<AnimationGroup>;
  77490. /**
  77491. * Callback called when the task is successful
  77492. */
  77493. onSuccess: (task: MeshAssetTask) => void;
  77494. /**
  77495. * Callback called when the task is successful
  77496. */
  77497. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77498. /**
  77499. * Creates a new MeshAssetTask
  77500. * @param name defines the name of the task
  77501. * @param meshesNames defines the list of mesh's names you want to load
  77502. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77503. * @param sceneFilename defines the filename or File of the scene to load from
  77504. */
  77505. constructor(
  77506. /**
  77507. * Defines the name of the task
  77508. */
  77509. name: string,
  77510. /**
  77511. * Defines the list of mesh's names you want to load
  77512. */
  77513. meshesNames: any,
  77514. /**
  77515. * Defines the root url to use as a base to load your meshes and associated resources
  77516. */
  77517. rootUrl: string,
  77518. /**
  77519. * Defines the filename or File of the scene to load from
  77520. */
  77521. sceneFilename: string | File);
  77522. /**
  77523. * Execute the current task
  77524. * @param scene defines the scene where you want your assets to be loaded
  77525. * @param onSuccess is a callback called when the task is successfully executed
  77526. * @param onError is a callback called if an error occurs
  77527. */
  77528. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77529. }
  77530. /**
  77531. * Define a task used by AssetsManager to load text content
  77532. */
  77533. export class TextFileAssetTask extends AbstractAssetTask {
  77534. /**
  77535. * Defines the name of the task
  77536. */
  77537. name: string;
  77538. /**
  77539. * Defines the location of the file to load
  77540. */
  77541. url: string;
  77542. /**
  77543. * Gets the loaded text string
  77544. */
  77545. text: string;
  77546. /**
  77547. * Callback called when the task is successful
  77548. */
  77549. onSuccess: (task: TextFileAssetTask) => void;
  77550. /**
  77551. * Callback called when the task is successful
  77552. */
  77553. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77554. /**
  77555. * Creates a new TextFileAssetTask object
  77556. * @param name defines the name of the task
  77557. * @param url defines the location of the file to load
  77558. */
  77559. constructor(
  77560. /**
  77561. * Defines the name of the task
  77562. */
  77563. name: string,
  77564. /**
  77565. * Defines the location of the file to load
  77566. */
  77567. url: string);
  77568. /**
  77569. * Execute the current task
  77570. * @param scene defines the scene where you want your assets to be loaded
  77571. * @param onSuccess is a callback called when the task is successfully executed
  77572. * @param onError is a callback called if an error occurs
  77573. */
  77574. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77575. }
  77576. /**
  77577. * Define a task used by AssetsManager to load binary data
  77578. */
  77579. export class BinaryFileAssetTask extends AbstractAssetTask {
  77580. /**
  77581. * Defines the name of the task
  77582. */
  77583. name: string;
  77584. /**
  77585. * Defines the location of the file to load
  77586. */
  77587. url: string;
  77588. /**
  77589. * Gets the lodaded data (as an array buffer)
  77590. */
  77591. data: ArrayBuffer;
  77592. /**
  77593. * Callback called when the task is successful
  77594. */
  77595. onSuccess: (task: BinaryFileAssetTask) => void;
  77596. /**
  77597. * Callback called when the task is successful
  77598. */
  77599. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77600. /**
  77601. * Creates a new BinaryFileAssetTask object
  77602. * @param name defines the name of the new task
  77603. * @param url defines the location of the file to load
  77604. */
  77605. constructor(
  77606. /**
  77607. * Defines the name of the task
  77608. */
  77609. name: string,
  77610. /**
  77611. * Defines the location of the file to load
  77612. */
  77613. url: string);
  77614. /**
  77615. * Execute the current task
  77616. * @param scene defines the scene where you want your assets to be loaded
  77617. * @param onSuccess is a callback called when the task is successfully executed
  77618. * @param onError is a callback called if an error occurs
  77619. */
  77620. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77621. }
  77622. /**
  77623. * Define a task used by AssetsManager to load images
  77624. */
  77625. export class ImageAssetTask extends AbstractAssetTask {
  77626. /**
  77627. * Defines the name of the task
  77628. */
  77629. name: string;
  77630. /**
  77631. * Defines the location of the image to load
  77632. */
  77633. url: string;
  77634. /**
  77635. * Gets the loaded images
  77636. */
  77637. image: HTMLImageElement;
  77638. /**
  77639. * Callback called when the task is successful
  77640. */
  77641. onSuccess: (task: ImageAssetTask) => void;
  77642. /**
  77643. * Callback called when the task is successful
  77644. */
  77645. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77646. /**
  77647. * Creates a new ImageAssetTask
  77648. * @param name defines the name of the task
  77649. * @param url defines the location of the image to load
  77650. */
  77651. constructor(
  77652. /**
  77653. * Defines the name of the task
  77654. */
  77655. name: string,
  77656. /**
  77657. * Defines the location of the image to load
  77658. */
  77659. url: string);
  77660. /**
  77661. * Execute the current task
  77662. * @param scene defines the scene where you want your assets to be loaded
  77663. * @param onSuccess is a callback called when the task is successfully executed
  77664. * @param onError is a callback called if an error occurs
  77665. */
  77666. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77667. }
  77668. /**
  77669. * Defines the interface used by texture loading tasks
  77670. */
  77671. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77672. /**
  77673. * Gets the loaded texture
  77674. */
  77675. texture: TEX;
  77676. }
  77677. /**
  77678. * Define a task used by AssetsManager to load 2D textures
  77679. */
  77680. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77681. /**
  77682. * Defines the name of the task
  77683. */
  77684. name: string;
  77685. /**
  77686. * Defines the location of the file to load
  77687. */
  77688. url: string;
  77689. /**
  77690. * Defines if mipmap should not be generated (default is false)
  77691. */
  77692. noMipmap?: boolean | undefined;
  77693. /**
  77694. * Defines if texture must be inverted on Y axis (default is true)
  77695. */
  77696. invertY: boolean;
  77697. /**
  77698. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77699. */
  77700. samplingMode: number;
  77701. /**
  77702. * Gets the loaded texture
  77703. */
  77704. texture: Texture;
  77705. /**
  77706. * Callback called when the task is successful
  77707. */
  77708. onSuccess: (task: TextureAssetTask) => void;
  77709. /**
  77710. * Callback called when the task is successful
  77711. */
  77712. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77713. /**
  77714. * Creates a new TextureAssetTask object
  77715. * @param name defines the name of the task
  77716. * @param url defines the location of the file to load
  77717. * @param noMipmap defines if mipmap should not be generated (default is false)
  77718. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77719. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77720. */
  77721. constructor(
  77722. /**
  77723. * Defines the name of the task
  77724. */
  77725. name: string,
  77726. /**
  77727. * Defines the location of the file to load
  77728. */
  77729. url: string,
  77730. /**
  77731. * Defines if mipmap should not be generated (default is false)
  77732. */
  77733. noMipmap?: boolean | undefined,
  77734. /**
  77735. * Defines if texture must be inverted on Y axis (default is true)
  77736. */
  77737. invertY?: boolean,
  77738. /**
  77739. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77740. */
  77741. samplingMode?: number);
  77742. /**
  77743. * Execute the current task
  77744. * @param scene defines the scene where you want your assets to be loaded
  77745. * @param onSuccess is a callback called when the task is successfully executed
  77746. * @param onError is a callback called if an error occurs
  77747. */
  77748. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77749. }
  77750. /**
  77751. * Define a task used by AssetsManager to load cube textures
  77752. */
  77753. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77754. /**
  77755. * Defines the name of the task
  77756. */
  77757. name: string;
  77758. /**
  77759. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77760. */
  77761. url: string;
  77762. /**
  77763. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77764. */
  77765. extensions?: string[] | undefined;
  77766. /**
  77767. * Defines if mipmaps should not be generated (default is false)
  77768. */
  77769. noMipmap?: boolean | undefined;
  77770. /**
  77771. * Defines the explicit list of files (undefined by default)
  77772. */
  77773. files?: string[] | undefined;
  77774. /**
  77775. * Gets the loaded texture
  77776. */
  77777. texture: CubeTexture;
  77778. /**
  77779. * Callback called when the task is successful
  77780. */
  77781. onSuccess: (task: CubeTextureAssetTask) => void;
  77782. /**
  77783. * Callback called when the task is successful
  77784. */
  77785. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77786. /**
  77787. * Creates a new CubeTextureAssetTask
  77788. * @param name defines the name of the task
  77789. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77790. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77791. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77792. * @param files defines the explicit list of files (undefined by default)
  77793. */
  77794. constructor(
  77795. /**
  77796. * Defines the name of the task
  77797. */
  77798. name: string,
  77799. /**
  77800. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77801. */
  77802. url: string,
  77803. /**
  77804. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77805. */
  77806. extensions?: string[] | undefined,
  77807. /**
  77808. * Defines if mipmaps should not be generated (default is false)
  77809. */
  77810. noMipmap?: boolean | undefined,
  77811. /**
  77812. * Defines the explicit list of files (undefined by default)
  77813. */
  77814. files?: string[] | undefined);
  77815. /**
  77816. * Execute the current task
  77817. * @param scene defines the scene where you want your assets to be loaded
  77818. * @param onSuccess is a callback called when the task is successfully executed
  77819. * @param onError is a callback called if an error occurs
  77820. */
  77821. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77822. }
  77823. /**
  77824. * Define a task used by AssetsManager to load HDR cube textures
  77825. */
  77826. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77827. /**
  77828. * Defines the name of the task
  77829. */
  77830. name: string;
  77831. /**
  77832. * Defines the location of the file to load
  77833. */
  77834. url: string;
  77835. /**
  77836. * Defines the desired size (the more it increases the longer the generation will be)
  77837. */
  77838. size: number;
  77839. /**
  77840. * Defines if mipmaps should not be generated (default is false)
  77841. */
  77842. noMipmap: boolean;
  77843. /**
  77844. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77845. */
  77846. generateHarmonics: boolean;
  77847. /**
  77848. * 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)
  77849. */
  77850. gammaSpace: boolean;
  77851. /**
  77852. * Internal Use Only
  77853. */
  77854. reserved: boolean;
  77855. /**
  77856. * Gets the loaded texture
  77857. */
  77858. texture: HDRCubeTexture;
  77859. /**
  77860. * Callback called when the task is successful
  77861. */
  77862. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77863. /**
  77864. * Callback called when the task is successful
  77865. */
  77866. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77867. /**
  77868. * Creates a new HDRCubeTextureAssetTask object
  77869. * @param name defines the name of the task
  77870. * @param url defines the location of the file to load
  77871. * @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.
  77872. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77873. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77874. * @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)
  77875. * @param reserved Internal use only
  77876. */
  77877. constructor(
  77878. /**
  77879. * Defines the name of the task
  77880. */
  77881. name: string,
  77882. /**
  77883. * Defines the location of the file to load
  77884. */
  77885. url: string,
  77886. /**
  77887. * Defines the desired size (the more it increases the longer the generation will be)
  77888. */
  77889. size: number,
  77890. /**
  77891. * Defines if mipmaps should not be generated (default is false)
  77892. */
  77893. noMipmap?: boolean,
  77894. /**
  77895. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77896. */
  77897. generateHarmonics?: boolean,
  77898. /**
  77899. * 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)
  77900. */
  77901. gammaSpace?: boolean,
  77902. /**
  77903. * Internal Use Only
  77904. */
  77905. reserved?: boolean);
  77906. /**
  77907. * Execute the current task
  77908. * @param scene defines the scene where you want your assets to be loaded
  77909. * @param onSuccess is a callback called when the task is successfully executed
  77910. * @param onError is a callback called if an error occurs
  77911. */
  77912. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77913. }
  77914. /**
  77915. * Define a task used by AssetsManager to load Equirectangular cube textures
  77916. */
  77917. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77918. /**
  77919. * Defines the name of the task
  77920. */
  77921. name: string;
  77922. /**
  77923. * Defines the location of the file to load
  77924. */
  77925. url: string;
  77926. /**
  77927. * Defines the desired size (the more it increases the longer the generation will be)
  77928. */
  77929. size: number;
  77930. /**
  77931. * Defines if mipmaps should not be generated (default is false)
  77932. */
  77933. noMipmap: boolean;
  77934. /**
  77935. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77936. * but the standard material would require them in Gamma space) (default is true)
  77937. */
  77938. gammaSpace: boolean;
  77939. /**
  77940. * Gets the loaded texture
  77941. */
  77942. texture: EquiRectangularCubeTexture;
  77943. /**
  77944. * Callback called when the task is successful
  77945. */
  77946. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77947. /**
  77948. * Callback called when the task is successful
  77949. */
  77950. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77951. /**
  77952. * Creates a new EquiRectangularCubeTextureAssetTask object
  77953. * @param name defines the name of the task
  77954. * @param url defines the location of the file to load
  77955. * @param size defines the desired size (the more it increases the longer the generation will be)
  77956. * If the size is omitted this implies you are using a preprocessed cubemap.
  77957. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77958. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77959. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77960. * (default is true)
  77961. */
  77962. constructor(
  77963. /**
  77964. * Defines the name of the task
  77965. */
  77966. name: string,
  77967. /**
  77968. * Defines the location of the file to load
  77969. */
  77970. url: string,
  77971. /**
  77972. * Defines the desired size (the more it increases the longer the generation will be)
  77973. */
  77974. size: number,
  77975. /**
  77976. * Defines if mipmaps should not be generated (default is false)
  77977. */
  77978. noMipmap?: boolean,
  77979. /**
  77980. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77981. * but the standard material would require them in Gamma space) (default is true)
  77982. */
  77983. gammaSpace?: boolean);
  77984. /**
  77985. * Execute the current task
  77986. * @param scene defines the scene where you want your assets to be loaded
  77987. * @param onSuccess is a callback called when the task is successfully executed
  77988. * @param onError is a callback called if an error occurs
  77989. */
  77990. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77991. }
  77992. /**
  77993. * This class can be used to easily import assets into a scene
  77994. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77995. */
  77996. export class AssetsManager {
  77997. private _scene;
  77998. private _isLoading;
  77999. protected _tasks: AbstractAssetTask[];
  78000. protected _waitingTasksCount: number;
  78001. protected _totalTasksCount: number;
  78002. /**
  78003. * Callback called when all tasks are processed
  78004. */
  78005. onFinish: (tasks: AbstractAssetTask[]) => void;
  78006. /**
  78007. * Callback called when a task is successful
  78008. */
  78009. onTaskSuccess: (task: AbstractAssetTask) => void;
  78010. /**
  78011. * Callback called when a task had an error
  78012. */
  78013. onTaskError: (task: AbstractAssetTask) => void;
  78014. /**
  78015. * Callback called when a task is done (whatever the result is)
  78016. */
  78017. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78018. /**
  78019. * Observable called when all tasks are processed
  78020. */
  78021. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78022. /**
  78023. * Observable called when a task had an error
  78024. */
  78025. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78026. /**
  78027. * Observable called when all tasks were executed
  78028. */
  78029. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78030. /**
  78031. * Observable called when a task is done (whatever the result is)
  78032. */
  78033. onProgressObservable: Observable<IAssetsProgressEvent>;
  78034. /**
  78035. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78036. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78037. */
  78038. useDefaultLoadingScreen: boolean;
  78039. /**
  78040. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78041. * when all assets have been downloaded.
  78042. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78043. */
  78044. autoHideLoadingUI: boolean;
  78045. /**
  78046. * Creates a new AssetsManager
  78047. * @param scene defines the scene to work on
  78048. */
  78049. constructor(scene: Scene);
  78050. /**
  78051. * Add a ContainerAssetTask to the list of active tasks
  78052. * @param taskName defines the name of the new task
  78053. * @param meshesNames defines the name of meshes to load
  78054. * @param rootUrl defines the root url to use to locate files
  78055. * @param sceneFilename defines the filename of the scene file
  78056. * @returns a new ContainerAssetTask object
  78057. */
  78058. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78059. /**
  78060. * Add a MeshAssetTask to the list of active tasks
  78061. * @param taskName defines the name of the new task
  78062. * @param meshesNames defines the name of meshes to load
  78063. * @param rootUrl defines the root url to use to locate files
  78064. * @param sceneFilename defines the filename of the scene file
  78065. * @returns a new MeshAssetTask object
  78066. */
  78067. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78068. /**
  78069. * Add a TextFileAssetTask to the list of active tasks
  78070. * @param taskName defines the name of the new task
  78071. * @param url defines the url of the file to load
  78072. * @returns a new TextFileAssetTask object
  78073. */
  78074. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78075. /**
  78076. * Add a BinaryFileAssetTask to the list of active tasks
  78077. * @param taskName defines the name of the new task
  78078. * @param url defines the url of the file to load
  78079. * @returns a new BinaryFileAssetTask object
  78080. */
  78081. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78082. /**
  78083. * Add a ImageAssetTask to the list of active tasks
  78084. * @param taskName defines the name of the new task
  78085. * @param url defines the url of the file to load
  78086. * @returns a new ImageAssetTask object
  78087. */
  78088. addImageTask(taskName: string, url: string): ImageAssetTask;
  78089. /**
  78090. * Add a TextureAssetTask to the list of active tasks
  78091. * @param taskName defines the name of the new task
  78092. * @param url defines the url of the file to load
  78093. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78094. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78095. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78096. * @returns a new TextureAssetTask object
  78097. */
  78098. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78099. /**
  78100. * Add a CubeTextureAssetTask to the list of active tasks
  78101. * @param taskName defines the name of the new task
  78102. * @param url defines the url of the file to load
  78103. * @param extensions defines the extension to use to load the cube map (can be null)
  78104. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78105. * @param files defines the list of files to load (can be null)
  78106. * @returns a new CubeTextureAssetTask object
  78107. */
  78108. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78109. /**
  78110. *
  78111. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78112. * @param taskName defines the name of the new task
  78113. * @param url defines the url of the file to load
  78114. * @param size defines the size you want for the cubemap (can be null)
  78115. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78116. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78117. * @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)
  78118. * @param reserved Internal use only
  78119. * @returns a new HDRCubeTextureAssetTask object
  78120. */
  78121. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78122. /**
  78123. *
  78124. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78125. * @param taskName defines the name of the new task
  78126. * @param url defines the url of the file to load
  78127. * @param size defines the size you want for the cubemap (can be null)
  78128. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78129. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78130. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78131. * @returns a new EquiRectangularCubeTextureAssetTask object
  78132. */
  78133. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78134. /**
  78135. * Remove a task from the assets manager.
  78136. * @param task the task to remove
  78137. */
  78138. removeTask(task: AbstractAssetTask): void;
  78139. private _decreaseWaitingTasksCount;
  78140. private _runTask;
  78141. /**
  78142. * Reset the AssetsManager and remove all tasks
  78143. * @return the current instance of the AssetsManager
  78144. */
  78145. reset(): AssetsManager;
  78146. /**
  78147. * Start the loading process
  78148. * @return the current instance of the AssetsManager
  78149. */
  78150. load(): AssetsManager;
  78151. /**
  78152. * Start the loading process as an async operation
  78153. * @return a promise returning the list of failed tasks
  78154. */
  78155. loadAsync(): Promise<void>;
  78156. }
  78157. }
  78158. declare module BABYLON {
  78159. /**
  78160. * Wrapper class for promise with external resolve and reject.
  78161. */
  78162. export class Deferred<T> {
  78163. /**
  78164. * The promise associated with this deferred object.
  78165. */
  78166. readonly promise: Promise<T>;
  78167. private _resolve;
  78168. private _reject;
  78169. /**
  78170. * The resolve method of the promise associated with this deferred object.
  78171. */
  78172. get resolve(): (value: T | PromiseLike<T>) => void;
  78173. /**
  78174. * The reject method of the promise associated with this deferred object.
  78175. */
  78176. get reject(): (reason?: any) => void;
  78177. /**
  78178. * Constructor for this deferred object.
  78179. */
  78180. constructor();
  78181. }
  78182. }
  78183. declare module BABYLON {
  78184. /**
  78185. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78186. */
  78187. export class MeshExploder {
  78188. private _centerMesh;
  78189. private _meshes;
  78190. private _meshesOrigins;
  78191. private _toCenterVectors;
  78192. private _scaledDirection;
  78193. private _newPosition;
  78194. private _centerPosition;
  78195. /**
  78196. * Explodes meshes from a center mesh.
  78197. * @param meshes The meshes to explode.
  78198. * @param centerMesh The mesh to be center of explosion.
  78199. */
  78200. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78201. private _setCenterMesh;
  78202. /**
  78203. * Get class name
  78204. * @returns "MeshExploder"
  78205. */
  78206. getClassName(): string;
  78207. /**
  78208. * "Exploded meshes"
  78209. * @returns Array of meshes with the centerMesh at index 0.
  78210. */
  78211. getMeshes(): Array<Mesh>;
  78212. /**
  78213. * Explodes meshes giving a specific direction
  78214. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78215. */
  78216. explode(direction?: number): void;
  78217. }
  78218. }
  78219. declare module BABYLON {
  78220. /**
  78221. * Class used to help managing file picking and drag'n'drop
  78222. */
  78223. export class FilesInput {
  78224. /**
  78225. * List of files ready to be loaded
  78226. */
  78227. static get FilesToLoad(): {
  78228. [key: string]: File;
  78229. };
  78230. /**
  78231. * Callback called when a file is processed
  78232. */
  78233. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  78234. /**
  78235. * Function used when loading the scene file
  78236. */
  78237. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  78238. private _engine;
  78239. private _currentScene;
  78240. private _sceneLoadedCallback;
  78241. private _progressCallback;
  78242. private _additionalRenderLoopLogicCallback;
  78243. private _textureLoadingCallback;
  78244. private _startingProcessingFilesCallback;
  78245. private _onReloadCallback;
  78246. private _errorCallback;
  78247. private _elementToMonitor;
  78248. private _sceneFileToLoad;
  78249. private _filesToLoad;
  78250. /**
  78251. * Creates a new FilesInput
  78252. * @param engine defines the rendering engine
  78253. * @param scene defines the hosting scene
  78254. * @param sceneLoadedCallback callback called when scene is loaded
  78255. * @param progressCallback callback called to track progress
  78256. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78257. * @param textureLoadingCallback callback called when a texture is loading
  78258. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78259. * @param onReloadCallback callback called when a reload is requested
  78260. * @param errorCallback callback call if an error occurs
  78261. */
  78262. constructor(engine: Engine, scene: Nullable<Scene>, sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>, progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>, additionalRenderLoopLogicCallback: Nullable<() => void>, textureLoadingCallback: Nullable<(remaining: number) => void>, startingProcessingFilesCallback: Nullable<(files?: File[]) => void>, onReloadCallback: Nullable<(sceneFile: File) => void>, errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>);
  78263. private _dragEnterHandler;
  78264. private _dragOverHandler;
  78265. private _dropHandler;
  78266. /**
  78267. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78268. * @param elementToMonitor defines the DOM element to track
  78269. */
  78270. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78271. /** Gets the current list of files to load */
  78272. get filesToLoad(): File[];
  78273. /**
  78274. * Release all associated resources
  78275. */
  78276. dispose(): void;
  78277. private renderFunction;
  78278. private drag;
  78279. private drop;
  78280. private _traverseFolder;
  78281. private _processFiles;
  78282. /**
  78283. * Load files from a drop event
  78284. * @param event defines the drop event to use as source
  78285. */
  78286. loadFiles(event: any): void;
  78287. private _processReload;
  78288. /**
  78289. * Reload the current scene from the loaded files
  78290. */
  78291. reload(): void;
  78292. }
  78293. }
  78294. declare module BABYLON {
  78295. /**
  78296. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78297. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78298. */
  78299. export class SceneOptimization {
  78300. /**
  78301. * Defines the priority of this optimization (0 by default which means first in the list)
  78302. */
  78303. priority: number;
  78304. /**
  78305. * Gets a string describing the action executed by the current optimization
  78306. * @returns description string
  78307. */
  78308. getDescription(): string;
  78309. /**
  78310. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78311. * @param scene defines the current scene where to apply this optimization
  78312. * @param optimizer defines the current optimizer
  78313. * @returns true if everything that can be done was applied
  78314. */
  78315. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78316. /**
  78317. * Creates the SceneOptimization object
  78318. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78319. * @param desc defines the description associated with the optimization
  78320. */
  78321. constructor(
  78322. /**
  78323. * Defines the priority of this optimization (0 by default which means first in the list)
  78324. */
  78325. priority?: number);
  78326. }
  78327. /**
  78328. * Defines an optimization used to reduce the size of render target textures
  78329. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78330. */
  78331. export class TextureOptimization extends SceneOptimization {
  78332. /**
  78333. * Defines the priority of this optimization (0 by default which means first in the list)
  78334. */
  78335. priority: number;
  78336. /**
  78337. * 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
  78338. */
  78339. maximumSize: number;
  78340. /**
  78341. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78342. */
  78343. step: number;
  78344. /**
  78345. * Gets a string describing the action executed by the current optimization
  78346. * @returns description string
  78347. */
  78348. getDescription(): string;
  78349. /**
  78350. * Creates the TextureOptimization object
  78351. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78352. * @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
  78353. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78354. */
  78355. constructor(
  78356. /**
  78357. * Defines the priority of this optimization (0 by default which means first in the list)
  78358. */
  78359. priority?: number,
  78360. /**
  78361. * 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
  78362. */
  78363. maximumSize?: number,
  78364. /**
  78365. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78366. */
  78367. step?: number);
  78368. /**
  78369. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78370. * @param scene defines the current scene where to apply this optimization
  78371. * @param optimizer defines the current optimizer
  78372. * @returns true if everything that can be done was applied
  78373. */
  78374. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78375. }
  78376. /**
  78377. * Defines an optimization used to increase or decrease the rendering resolution
  78378. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78379. */
  78380. export class HardwareScalingOptimization extends SceneOptimization {
  78381. /**
  78382. * Defines the priority of this optimization (0 by default which means first in the list)
  78383. */
  78384. priority: number;
  78385. /**
  78386. * Defines the maximum scale to use (2 by default)
  78387. */
  78388. maximumScale: number;
  78389. /**
  78390. * Defines the step to use between two passes (0.5 by default)
  78391. */
  78392. step: number;
  78393. private _currentScale;
  78394. private _directionOffset;
  78395. /**
  78396. * Gets a string describing the action executed by the current optimization
  78397. * @return description string
  78398. */
  78399. getDescription(): string;
  78400. /**
  78401. * Creates the HardwareScalingOptimization object
  78402. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78403. * @param maximumScale defines the maximum scale to use (2 by default)
  78404. * @param step defines the step to use between two passes (0.5 by default)
  78405. */
  78406. constructor(
  78407. /**
  78408. * Defines the priority of this optimization (0 by default which means first in the list)
  78409. */
  78410. priority?: number,
  78411. /**
  78412. * Defines the maximum scale to use (2 by default)
  78413. */
  78414. maximumScale?: number,
  78415. /**
  78416. * Defines the step to use between two passes (0.5 by default)
  78417. */
  78418. step?: number);
  78419. /**
  78420. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78421. * @param scene defines the current scene where to apply this optimization
  78422. * @param optimizer defines the current optimizer
  78423. * @returns true if everything that can be done was applied
  78424. */
  78425. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78426. }
  78427. /**
  78428. * Defines an optimization used to remove shadows
  78429. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78430. */
  78431. export class ShadowsOptimization extends SceneOptimization {
  78432. /**
  78433. * Gets a string describing the action executed by the current optimization
  78434. * @return description string
  78435. */
  78436. getDescription(): string;
  78437. /**
  78438. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78439. * @param scene defines the current scene where to apply this optimization
  78440. * @param optimizer defines the current optimizer
  78441. * @returns true if everything that can be done was applied
  78442. */
  78443. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78444. }
  78445. /**
  78446. * Defines an optimization used to turn post-processes off
  78447. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78448. */
  78449. export class PostProcessesOptimization extends SceneOptimization {
  78450. /**
  78451. * Gets a string describing the action executed by the current optimization
  78452. * @return description string
  78453. */
  78454. getDescription(): string;
  78455. /**
  78456. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78457. * @param scene defines the current scene where to apply this optimization
  78458. * @param optimizer defines the current optimizer
  78459. * @returns true if everything that can be done was applied
  78460. */
  78461. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78462. }
  78463. /**
  78464. * Defines an optimization used to turn lens flares off
  78465. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78466. */
  78467. export class LensFlaresOptimization extends SceneOptimization {
  78468. /**
  78469. * Gets a string describing the action executed by the current optimization
  78470. * @return description string
  78471. */
  78472. getDescription(): string;
  78473. /**
  78474. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78475. * @param scene defines the current scene where to apply this optimization
  78476. * @param optimizer defines the current optimizer
  78477. * @returns true if everything that can be done was applied
  78478. */
  78479. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78480. }
  78481. /**
  78482. * Defines an optimization based on user defined callback.
  78483. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78484. */
  78485. export class CustomOptimization extends SceneOptimization {
  78486. /**
  78487. * Callback called to apply the custom optimization.
  78488. */
  78489. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78490. /**
  78491. * Callback called to get custom description
  78492. */
  78493. onGetDescription: () => string;
  78494. /**
  78495. * Gets a string describing the action executed by the current optimization
  78496. * @returns description string
  78497. */
  78498. getDescription(): string;
  78499. /**
  78500. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78501. * @param scene defines the current scene where to apply this optimization
  78502. * @param optimizer defines the current optimizer
  78503. * @returns true if everything that can be done was applied
  78504. */
  78505. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78506. }
  78507. /**
  78508. * Defines an optimization used to turn particles off
  78509. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78510. */
  78511. export class ParticlesOptimization extends SceneOptimization {
  78512. /**
  78513. * Gets a string describing the action executed by the current optimization
  78514. * @return description string
  78515. */
  78516. getDescription(): string;
  78517. /**
  78518. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78519. * @param scene defines the current scene where to apply this optimization
  78520. * @param optimizer defines the current optimizer
  78521. * @returns true if everything that can be done was applied
  78522. */
  78523. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78524. }
  78525. /**
  78526. * Defines an optimization used to turn render targets off
  78527. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78528. */
  78529. export class RenderTargetsOptimization extends SceneOptimization {
  78530. /**
  78531. * Gets a string describing the action executed by the current optimization
  78532. * @return description string
  78533. */
  78534. getDescription(): string;
  78535. /**
  78536. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78537. * @param scene defines the current scene where to apply this optimization
  78538. * @param optimizer defines the current optimizer
  78539. * @returns true if everything that can be done was applied
  78540. */
  78541. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78542. }
  78543. /**
  78544. * Defines an optimization used to merge meshes with compatible materials
  78545. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78546. */
  78547. export class MergeMeshesOptimization extends SceneOptimization {
  78548. private static _UpdateSelectionTree;
  78549. /**
  78550. * Gets or sets a boolean which defines if optimization octree has to be updated
  78551. */
  78552. static get UpdateSelectionTree(): boolean;
  78553. /**
  78554. * Gets or sets a boolean which defines if optimization octree has to be updated
  78555. */
  78556. static set UpdateSelectionTree(value: boolean);
  78557. /**
  78558. * Gets a string describing the action executed by the current optimization
  78559. * @return description string
  78560. */
  78561. getDescription(): string;
  78562. private _canBeMerged;
  78563. /**
  78564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78565. * @param scene defines the current scene where to apply this optimization
  78566. * @param optimizer defines the current optimizer
  78567. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78568. * @returns true if everything that can be done was applied
  78569. */
  78570. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78571. }
  78572. /**
  78573. * Defines a list of options used by SceneOptimizer
  78574. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78575. */
  78576. export class SceneOptimizerOptions {
  78577. /**
  78578. * Defines the target frame rate to reach (60 by default)
  78579. */
  78580. targetFrameRate: number;
  78581. /**
  78582. * Defines the interval between two checks (2000ms by default)
  78583. */
  78584. trackerDuration: number;
  78585. /**
  78586. * Gets the list of optimizations to apply
  78587. */
  78588. optimizations: SceneOptimization[];
  78589. /**
  78590. * Creates a new list of options used by SceneOptimizer
  78591. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78592. * @param trackerDuration defines the interval between two checks (2000ms by default)
  78593. */
  78594. constructor(
  78595. /**
  78596. * Defines the target frame rate to reach (60 by default)
  78597. */
  78598. targetFrameRate?: number,
  78599. /**
  78600. * Defines the interval between two checks (2000ms by default)
  78601. */
  78602. trackerDuration?: number);
  78603. /**
  78604. * Add a new optimization
  78605. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78606. * @returns the current SceneOptimizerOptions
  78607. */
  78608. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78609. /**
  78610. * Add a new custom optimization
  78611. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78612. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78613. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78614. * @returns the current SceneOptimizerOptions
  78615. */
  78616. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78617. /**
  78618. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78619. * @param targetFrameRate defines the target frame rate (60 by default)
  78620. * @returns a SceneOptimizerOptions object
  78621. */
  78622. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78623. /**
  78624. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78625. * @param targetFrameRate defines the target frame rate (60 by default)
  78626. * @returns a SceneOptimizerOptions object
  78627. */
  78628. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78629. /**
  78630. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78631. * @param targetFrameRate defines the target frame rate (60 by default)
  78632. * @returns a SceneOptimizerOptions object
  78633. */
  78634. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78635. }
  78636. /**
  78637. * Class used to run optimizations in order to reach a target frame rate
  78638. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78639. */
  78640. export class SceneOptimizer implements IDisposable {
  78641. private _isRunning;
  78642. private _options;
  78643. private _scene;
  78644. private _currentPriorityLevel;
  78645. private _targetFrameRate;
  78646. private _trackerDuration;
  78647. private _currentFrameRate;
  78648. private _sceneDisposeObserver;
  78649. private _improvementMode;
  78650. /**
  78651. * Defines an observable called when the optimizer reaches the target frame rate
  78652. */
  78653. onSuccessObservable: Observable<SceneOptimizer>;
  78654. /**
  78655. * Defines an observable called when the optimizer enables an optimization
  78656. */
  78657. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78658. /**
  78659. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78660. */
  78661. onFailureObservable: Observable<SceneOptimizer>;
  78662. /**
  78663. * Gets a boolean indicating if the optimizer is in improvement mode
  78664. */
  78665. get isInImprovementMode(): boolean;
  78666. /**
  78667. * Gets the current priority level (0 at start)
  78668. */
  78669. get currentPriorityLevel(): number;
  78670. /**
  78671. * Gets the current frame rate checked by the SceneOptimizer
  78672. */
  78673. get currentFrameRate(): number;
  78674. /**
  78675. * Gets or sets the current target frame rate (60 by default)
  78676. */
  78677. get targetFrameRate(): number;
  78678. /**
  78679. * Gets or sets the current target frame rate (60 by default)
  78680. */
  78681. set targetFrameRate(value: number);
  78682. /**
  78683. * Gets or sets the current interval between two checks (every 2000ms by default)
  78684. */
  78685. get trackerDuration(): number;
  78686. /**
  78687. * Gets or sets the current interval between two checks (every 2000ms by default)
  78688. */
  78689. set trackerDuration(value: number);
  78690. /**
  78691. * Gets the list of active optimizations
  78692. */
  78693. get optimizations(): SceneOptimization[];
  78694. /**
  78695. * Creates a new SceneOptimizer
  78696. * @param scene defines the scene to work on
  78697. * @param options defines the options to use with the SceneOptimizer
  78698. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78699. * @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)
  78700. */
  78701. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78702. /**
  78703. * Stops the current optimizer
  78704. */
  78705. stop(): void;
  78706. /**
  78707. * Reset the optimizer to initial step (current priority level = 0)
  78708. */
  78709. reset(): void;
  78710. /**
  78711. * Start the optimizer. By default it will try to reach a specific framerate
  78712. * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate
  78713. */
  78714. start(): void;
  78715. private _checkCurrentState;
  78716. /**
  78717. * Release all resources
  78718. */
  78719. dispose(): void;
  78720. /**
  78721. * Helper function to create a SceneOptimizer with one single line of code
  78722. * @param scene defines the scene to work on
  78723. * @param options defines the options to use with the SceneOptimizer
  78724. * @param onSuccess defines a callback to call on success
  78725. * @param onFailure defines a callback to call on failure
  78726. * @returns the new SceneOptimizer object
  78727. */
  78728. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78729. }
  78730. }
  78731. declare module BABYLON {
  78732. /**
  78733. * Class used to serialize a scene into a string
  78734. */
  78735. export class SceneSerializer {
  78736. /**
  78737. * Clear cache used by a previous serialization
  78738. */
  78739. static ClearCache(): void;
  78740. /**
  78741. * Serialize a scene into a JSON compatible object
  78742. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  78743. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  78744. * @param scene defines the scene to serialize
  78745. * @returns a JSON compatible object
  78746. */
  78747. static Serialize(scene: Scene): any;
  78748. private static _Serialize;
  78749. /**
  78750. * Serialize a scene into a JSON compatible object
  78751. * @param scene defines the scene to serialize
  78752. * @returns a JSON promise compatible object
  78753. */
  78754. static SerializeAsync(scene: Scene): Promise<any>;
  78755. private static _CollectPromises;
  78756. /**
  78757. * Serialize a mesh into a JSON compatible object
  78758. * @param toSerialize defines the mesh to serialize
  78759. * @param withParents defines if parents must be serialized as well
  78760. * @param withChildren defines if children must be serialized as well
  78761. * @returns a JSON compatible object
  78762. */
  78763. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78764. }
  78765. }
  78766. declare module BABYLON {
  78767. /**
  78768. * This represents the different options available for the video capture.
  78769. */
  78770. export interface VideoRecorderOptions {
  78771. /** Defines the mime type of the video. */
  78772. mimeType: string;
  78773. /** Defines the FPS the video should be recorded at. */
  78774. fps: number;
  78775. /** Defines the chunk size for the recording data. */
  78776. recordChunckSize: number;
  78777. /** The audio tracks to attach to the recording. */
  78778. audioTracks?: MediaStreamTrack[];
  78779. }
  78780. /**
  78781. * This can help with recording videos from BabylonJS.
  78782. * This is based on the available WebRTC functionalities of the browser.
  78783. *
  78784. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78785. */
  78786. export class VideoRecorder {
  78787. private static readonly _defaultOptions;
  78788. /**
  78789. * Returns whether or not the VideoRecorder is available in your browser.
  78790. * @param engine Defines the Babylon Engine.
  78791. * @returns true if supported otherwise false.
  78792. */
  78793. static IsSupported(engine: Engine): boolean;
  78794. private readonly _options;
  78795. private _canvas;
  78796. private _mediaRecorder;
  78797. private _recordedChunks;
  78798. private _fileName;
  78799. private _resolve;
  78800. private _reject;
  78801. /**
  78802. * True when a recording is already in progress.
  78803. */
  78804. get isRecording(): boolean;
  78805. /**
  78806. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78807. * @param engine Defines the BabylonJS Engine you wish to record.
  78808. * @param options Defines options that can be used to customize the capture.
  78809. */
  78810. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78811. /**
  78812. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78813. */
  78814. stopRecording(): void;
  78815. /**
  78816. * Starts recording the canvas for a max duration specified in parameters.
  78817. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78818. * If null no automatic download will start and you can rely on the promise to get the data back.
  78819. * @param maxDuration Defines the maximum recording time in seconds.
  78820. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78821. * @return A promise callback at the end of the recording with the video data in Blob.
  78822. */
  78823. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78824. /**
  78825. * Releases internal resources used during the recording.
  78826. */
  78827. dispose(): void;
  78828. private _handleDataAvailable;
  78829. private _handleError;
  78830. private _handleStop;
  78831. }
  78832. }
  78833. declare module BABYLON {
  78834. /**
  78835. * Class containing a set of static utilities functions for screenshots
  78836. */
  78837. export class ScreenshotTools {
  78838. /**
  78839. * Captures a screenshot of the current rendering
  78840. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78841. * @param engine defines the rendering engine
  78842. * @param camera defines the source camera
  78843. * @param size This parameter can be set to a single number or to an object with the
  78844. * following (optional) properties: precision, width, height. If a single number is passed,
  78845. * it will be used for both width and height. If an object is passed, the screenshot size
  78846. * will be derived from the parameters. The precision property is a multiplier allowing
  78847. * rendering at a higher or lower resolution
  78848. * @param successCallback defines the callback receives a single parameter which contains the
  78849. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78850. * src parameter of an <img> to display it
  78851. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78852. * Check your browser for supported MIME types
  78853. * @param forceDownload force the system to download the image even if a successCallback is provided
  78854. */
  78855. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  78856. /**
  78857. * Captures a screenshot of the current rendering
  78858. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78859. * @param engine defines the rendering engine
  78860. * @param camera defines the source camera
  78861. * @param size This parameter can be set to a single number or to an object with the
  78862. * following (optional) properties: precision, width, height. If a single number is passed,
  78863. * it will be used for both width and height. If an object is passed, the screenshot size
  78864. * will be derived from the parameters. The precision property is a multiplier allowing
  78865. * rendering at a higher or lower resolution
  78866. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78867. * Check your browser for supported MIME types
  78868. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78869. * to the src parameter of an <img> to display it
  78870. */
  78871. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78872. /**
  78873. * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)
  78874. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78875. * @param engine defines the rendering engine
  78876. * @param camera defines the source camera
  78877. * @param width defines the expected width
  78878. * @param height defines the expected height
  78879. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78880. * Check your browser for supported MIME types
  78881. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78882. * to the src parameter of an <img> to display it
  78883. */
  78884. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  78885. /**
  78886. * Generates an image screenshot from the specified camera.
  78887. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78888. * @param engine The engine to use for rendering
  78889. * @param camera The camera to use for rendering
  78890. * @param size This parameter can be set to a single number or to an object with the
  78891. * following (optional) properties: precision, width, height. If a single number is passed,
  78892. * it will be used for both width and height. If an object is passed, the screenshot size
  78893. * will be derived from the parameters. The precision property is a multiplier allowing
  78894. * rendering at a higher or lower resolution
  78895. * @param successCallback The callback receives a single parameter which contains the
  78896. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78897. * src parameter of an <img> to display it
  78898. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78899. * Check your browser for supported MIME types
  78900. * @param samples Texture samples (default: 1)
  78901. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78902. * @param fileName A name for for the downloaded file.
  78903. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78904. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78905. */
  78906. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  78907. /**
  78908. * Generates an image screenshot from the specified camera.
  78909. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78910. * @param engine The engine to use for rendering
  78911. * @param camera The camera to use for rendering
  78912. * @param size This parameter can be set to a single number or to an object with the
  78913. * following (optional) properties: precision, width, height. If a single number is passed,
  78914. * it will be used for both width and height. If an object is passed, the screenshot size
  78915. * will be derived from the parameters. The precision property is a multiplier allowing
  78916. * rendering at a higher or lower resolution
  78917. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78918. * Check your browser for supported MIME types
  78919. * @param samples Texture samples (default: 1)
  78920. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78921. * @param fileName A name for for the downloaded file.
  78922. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78923. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78924. * to the src parameter of an <img> to display it
  78925. */
  78926. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78927. /**
  78928. * Gets height and width for screenshot size
  78929. * @private
  78930. */
  78931. private static _getScreenshotSize;
  78932. }
  78933. }
  78934. declare module BABYLON {
  78935. /**
  78936. * Interface for a data buffer
  78937. */
  78938. export interface IDataBuffer {
  78939. /**
  78940. * Reads bytes from the data buffer.
  78941. * @param byteOffset The byte offset to read
  78942. * @param byteLength The byte length to read
  78943. * @returns A promise that resolves when the bytes are read
  78944. */
  78945. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78946. /**
  78947. * The byte length of the buffer.
  78948. */
  78949. readonly byteLength: number;
  78950. }
  78951. /**
  78952. * Utility class for reading from a data buffer
  78953. */
  78954. export class DataReader {
  78955. /**
  78956. * The data buffer associated with this data reader.
  78957. */
  78958. readonly buffer: IDataBuffer;
  78959. /**
  78960. * The current byte offset from the beginning of the data buffer.
  78961. */
  78962. byteOffset: number;
  78963. private _dataView;
  78964. private _dataByteOffset;
  78965. /**
  78966. * Constructor
  78967. * @param buffer The buffer to read
  78968. */
  78969. constructor(buffer: IDataBuffer);
  78970. /**
  78971. * Loads the given byte length.
  78972. * @param byteLength The byte length to load
  78973. * @returns A promise that resolves when the load is complete
  78974. */
  78975. loadAsync(byteLength: number): Promise<void>;
  78976. /**
  78977. * Read a unsigned 32-bit integer from the currently loaded data range.
  78978. * @returns The 32-bit integer read
  78979. */
  78980. readUint32(): number;
  78981. /**
  78982. * Read a byte array from the currently loaded data range.
  78983. * @param byteLength The byte length to read
  78984. * @returns The byte array read
  78985. */
  78986. readUint8Array(byteLength: number): Uint8Array;
  78987. /**
  78988. * Read a string from the currently loaded data range.
  78989. * @param byteLength The byte length to read
  78990. * @returns The string read
  78991. */
  78992. readString(byteLength: number): string;
  78993. /**
  78994. * Skips the given byte length the currently loaded data range.
  78995. * @param byteLength The byte length to skip
  78996. */
  78997. skipBytes(byteLength: number): void;
  78998. }
  78999. }
  79000. declare module BABYLON {
  79001. /**
  79002. * Class for storing data to local storage if available or in-memory storage otherwise
  79003. */
  79004. export class DataStorage {
  79005. private static _Storage;
  79006. private static _GetStorage;
  79007. /**
  79008. * Reads a string from the data storage
  79009. * @param key The key to read
  79010. * @param defaultValue The value if the key doesn't exist
  79011. * @returns The string value
  79012. */
  79013. static ReadString(key: string, defaultValue: string): string;
  79014. /**
  79015. * Writes a string to the data storage
  79016. * @param key The key to write
  79017. * @param value The value to write
  79018. */
  79019. static WriteString(key: string, value: string): void;
  79020. /**
  79021. * Reads a boolean from the data storage
  79022. * @param key The key to read
  79023. * @param defaultValue The value if the key doesn't exist
  79024. * @returns The boolean value
  79025. */
  79026. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79027. /**
  79028. * Writes a boolean to the data storage
  79029. * @param key The key to write
  79030. * @param value The value to write
  79031. */
  79032. static WriteBoolean(key: string, value: boolean): void;
  79033. /**
  79034. * Reads a number from the data storage
  79035. * @param key The key to read
  79036. * @param defaultValue The value if the key doesn't exist
  79037. * @returns The number value
  79038. */
  79039. static ReadNumber(key: string, defaultValue: number): number;
  79040. /**
  79041. * Writes a number to the data storage
  79042. * @param key The key to write
  79043. * @param value The value to write
  79044. */
  79045. static WriteNumber(key: string, value: number): void;
  79046. }
  79047. }
  79048. declare module BABYLON {
  79049. /**
  79050. * Class used to record delta files between 2 scene states
  79051. */
  79052. export class SceneRecorder {
  79053. private _trackedScene;
  79054. private _savedJSON;
  79055. /**
  79056. * Track a given scene. This means the current scene state will be considered the original state
  79057. * @param scene defines the scene to track
  79058. */
  79059. track(scene: Scene): void;
  79060. /**
  79061. * Get the delta between current state and original state
  79062. * @returns a any containing the delta
  79063. */
  79064. getDelta(): any;
  79065. private _compareArray;
  79066. private _compareObjects;
  79067. private _compareCollections;
  79068. private static GetShadowGeneratorById;
  79069. /**
  79070. * Apply a given delta to a given scene
  79071. * @param deltaJSON defines the JSON containing the delta
  79072. * @param scene defines the scene to apply the delta to
  79073. */
  79074. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79075. private static _ApplyPropertiesToEntity;
  79076. private static _ApplyDeltaForEntity;
  79077. }
  79078. }
  79079. declare module BABYLON {
  79080. /**
  79081. * A 3D trajectory consisting of an order list of vectors describing a
  79082. * path of motion through 3D space.
  79083. */
  79084. export class Trajectory {
  79085. private _points;
  79086. private readonly _segmentLength;
  79087. /**
  79088. * Serialize to JSON.
  79089. * @returns serialized JSON string
  79090. */
  79091. serialize(): string;
  79092. /**
  79093. * Deserialize from JSON.
  79094. * @param json serialized JSON string
  79095. * @returns deserialized Trajectory
  79096. */
  79097. static Deserialize(json: string): Trajectory;
  79098. /**
  79099. * Create a new empty Trajectory.
  79100. * @param segmentLength radius of discretization for Trajectory points
  79101. */
  79102. constructor(segmentLength?: number);
  79103. /**
  79104. * Get the length of the Trajectory.
  79105. * @returns length of the Trajectory
  79106. */
  79107. getLength(): number;
  79108. /**
  79109. * Append a new point to the Trajectory.
  79110. * NOTE: This implementation has many allocations.
  79111. * @param point point to append to the Trajectory
  79112. */
  79113. add(point: DeepImmutable<Vector3>): void;
  79114. /**
  79115. * Create a new Trajectory with a segment length chosen to make it
  79116. * probable that the new Trajectory will have a specified number of
  79117. * segments. This operation is imprecise.
  79118. * @param targetResolution number of segments desired
  79119. * @returns new Trajectory with approximately the requested number of segments
  79120. */
  79121. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79122. /**
  79123. * Convert Trajectory segments into tokenized representation. This
  79124. * representation is an array of numbers where each nth number is the
  79125. * index of the token which is most similar to the nth segment of the
  79126. * Trajectory.
  79127. * @param tokens list of vectors which serve as discrete tokens
  79128. * @returns list of indices of most similar token per segment
  79129. */
  79130. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79131. private static _forwardDir;
  79132. private static _inverseFromVec;
  79133. private static _upDir;
  79134. private static _fromToVec;
  79135. private static _lookMatrix;
  79136. /**
  79137. * Transform the rotation (i.e., direction) of a segment to isolate
  79138. * the relative transformation represented by the segment. This operation
  79139. * may or may not succeed due to singularities in the equations that define
  79140. * motion relativity in this context.
  79141. * @param priorVec the origin of the prior segment
  79142. * @param fromVec the origin of the current segment
  79143. * @param toVec the destination of the current segment
  79144. * @param result reference to output variable
  79145. * @returns whether or not transformation was successful
  79146. */
  79147. private static _transformSegmentDirToRef;
  79148. private static _bestMatch;
  79149. private static _score;
  79150. private static _bestScore;
  79151. /**
  79152. * Determine which token vector is most similar to the
  79153. * segment vector.
  79154. * @param segment segment vector
  79155. * @param tokens token vector list
  79156. * @returns index of the most similar token to the segment
  79157. */
  79158. private static _tokenizeSegment;
  79159. }
  79160. /**
  79161. * Class representing a set of known, named trajectories to which Trajectories can be
  79162. * added and using which Trajectories can be recognized.
  79163. */
  79164. export class TrajectoryClassifier {
  79165. private _maximumAllowableMatchCost;
  79166. private _vector3Alphabet;
  79167. private _levenshteinAlphabet;
  79168. private _nameToDescribedTrajectory;
  79169. /**
  79170. * Serialize to JSON.
  79171. * @returns JSON serialization
  79172. */
  79173. serialize(): string;
  79174. /**
  79175. * Deserialize from JSON.
  79176. * @param json JSON serialization
  79177. * @returns deserialized TrajectorySet
  79178. */
  79179. static Deserialize(json: string): TrajectoryClassifier;
  79180. /**
  79181. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79182. * VERY naive, need to be generating these things from known
  79183. * sets. Better version later, probably eliminating this one.
  79184. * @returns auto-generated TrajectorySet
  79185. */
  79186. static Generate(): TrajectoryClassifier;
  79187. private constructor();
  79188. /**
  79189. * Add a new Trajectory to the set with a given name.
  79190. * @param trajectory new Trajectory to be added
  79191. * @param classification name to which to add the Trajectory
  79192. */
  79193. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79194. /**
  79195. * Remove a known named trajectory and all Trajectories associated with it.
  79196. * @param classification name to remove
  79197. * @returns whether anything was removed
  79198. */
  79199. deleteClassification(classification: string): boolean;
  79200. /**
  79201. * Attempt to recognize a Trajectory from among all the classifications
  79202. * already known to the classifier.
  79203. * @param trajectory Trajectory to be recognized
  79204. * @returns classification of Trajectory if recognized, null otherwise
  79205. */
  79206. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79207. }
  79208. }
  79209. declare module BABYLON {
  79210. /**
  79211. * An interface for all Hit test features
  79212. */
  79213. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79214. /**
  79215. * Triggered when new babylon (transformed) hit test results are available
  79216. */
  79217. onHitTestResultObservable: Observable<T[]>;
  79218. }
  79219. /**
  79220. * Options used for hit testing
  79221. */
  79222. export interface IWebXRLegacyHitTestOptions {
  79223. /**
  79224. * Only test when user interacted with the scene. Default - hit test every frame
  79225. */
  79226. testOnPointerDownOnly?: boolean;
  79227. /**
  79228. * The node to use to transform the local results to world coordinates
  79229. */
  79230. worldParentNode?: TransformNode;
  79231. }
  79232. /**
  79233. * Interface defining the babylon result of raycasting/hit-test
  79234. */
  79235. export interface IWebXRLegacyHitResult {
  79236. /**
  79237. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79238. */
  79239. transformationMatrix: Matrix;
  79240. /**
  79241. * The native hit test result
  79242. */
  79243. xrHitResult: XRHitResult | XRHitTestResult;
  79244. }
  79245. /**
  79246. * The currently-working hit-test module.
  79247. * Hit test (or Ray-casting) is used to interact with the real world.
  79248. * For further information read here - https://github.com/immersive-web/hit-test
  79249. */
  79250. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79251. /**
  79252. * options to use when constructing this feature
  79253. */
  79254. readonly options: IWebXRLegacyHitTestOptions;
  79255. private _direction;
  79256. private _mat;
  79257. private _onSelectEnabled;
  79258. private _origin;
  79259. /**
  79260. * The module's name
  79261. */
  79262. static readonly Name: string;
  79263. /**
  79264. * The (Babylon) version of this module.
  79265. * This is an integer representing the implementation version.
  79266. * This number does not correspond to the WebXR specs version
  79267. */
  79268. static readonly Version: number;
  79269. /**
  79270. * Populated with the last native XR Hit Results
  79271. */
  79272. lastNativeXRHitResults: XRHitResult[];
  79273. /**
  79274. * Triggered when new babylon (transformed) hit test results are available
  79275. */
  79276. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79277. /**
  79278. * Creates a new instance of the (legacy version) hit test feature
  79279. * @param _xrSessionManager an instance of WebXRSessionManager
  79280. * @param options options to use when constructing this feature
  79281. */
  79282. constructor(_xrSessionManager: WebXRSessionManager,
  79283. /**
  79284. * options to use when constructing this feature
  79285. */
  79286. options?: IWebXRLegacyHitTestOptions);
  79287. /**
  79288. * execute a hit test with an XR Ray
  79289. *
  79290. * @param xrSession a native xrSession that will execute this hit test
  79291. * @param xrRay the ray (position and direction) to use for ray-casting
  79292. * @param referenceSpace native XR reference space to use for the hit-test
  79293. * @param filter filter function that will filter the results
  79294. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79295. */
  79296. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79297. /**
  79298. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79299. * @param event the (select) event to use to select with
  79300. * @param referenceSpace the reference space to use for this hit test
  79301. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79302. */
  79303. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79304. /**
  79305. * attach this feature
  79306. * Will usually be called by the features manager
  79307. *
  79308. * @returns true if successful.
  79309. */
  79310. attach(): boolean;
  79311. /**
  79312. * detach this feature.
  79313. * Will usually be called by the features manager
  79314. *
  79315. * @returns true if successful.
  79316. */
  79317. detach(): boolean;
  79318. /**
  79319. * Dispose this feature and all of the resources attached
  79320. */
  79321. dispose(): void;
  79322. protected _onXRFrame(frame: XRFrame): void;
  79323. private _onHitTestResults;
  79324. private _onSelect;
  79325. }
  79326. }
  79327. declare module BABYLON {
  79328. /**
  79329. * Options used for hit testing (version 2)
  79330. */
  79331. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79332. /**
  79333. * Do not create a permanent hit test. Will usually be used when only
  79334. * transient inputs are needed.
  79335. */
  79336. disablePermanentHitTest?: boolean;
  79337. /**
  79338. * Enable transient (for example touch-based) hit test inspections
  79339. */
  79340. enableTransientHitTest?: boolean;
  79341. /**
  79342. * Offset ray for the permanent hit test
  79343. */
  79344. offsetRay?: Vector3;
  79345. /**
  79346. * Offset ray for the transient hit test
  79347. */
  79348. transientOffsetRay?: Vector3;
  79349. /**
  79350. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79351. */
  79352. useReferenceSpace?: boolean;
  79353. /**
  79354. * Override the default entity type(s) of the hit-test result
  79355. */
  79356. entityTypes?: XRHitTestTrackableType[];
  79357. }
  79358. /**
  79359. * Interface defining the babylon result of hit-test
  79360. */
  79361. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79362. /**
  79363. * The input source that generated this hit test (if transient)
  79364. */
  79365. inputSource?: XRInputSource;
  79366. /**
  79367. * Is this a transient hit test
  79368. */
  79369. isTransient?: boolean;
  79370. /**
  79371. * Position of the hit test result
  79372. */
  79373. position: Vector3;
  79374. /**
  79375. * Rotation of the hit test result
  79376. */
  79377. rotationQuaternion: Quaternion;
  79378. /**
  79379. * The native hit test result
  79380. */
  79381. xrHitResult: XRHitTestResult;
  79382. }
  79383. /**
  79384. * The currently-working hit-test module.
  79385. * Hit test (or Ray-casting) is used to interact with the real world.
  79386. * For further information read here - https://github.com/immersive-web/hit-test
  79387. *
  79388. * Tested on chrome (mobile) 80.
  79389. */
  79390. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79391. /**
  79392. * options to use when constructing this feature
  79393. */
  79394. readonly options: IWebXRHitTestOptions;
  79395. private _tmpMat;
  79396. private _tmpPos;
  79397. private _tmpQuat;
  79398. private _transientXrHitTestSource;
  79399. private _xrHitTestSource;
  79400. private initHitTestSource;
  79401. /**
  79402. * The module's name
  79403. */
  79404. static readonly Name: string;
  79405. /**
  79406. * The (Babylon) version of this module.
  79407. * This is an integer representing the implementation version.
  79408. * This number does not correspond to the WebXR specs version
  79409. */
  79410. static readonly Version: number;
  79411. /**
  79412. * When set to true, each hit test will have its own position/rotation objects
  79413. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79414. * the developers will clone them or copy them as they see fit.
  79415. */
  79416. autoCloneTransformation: boolean;
  79417. /**
  79418. * Triggered when new babylon (transformed) hit test results are available
  79419. * Note - this will be called when results come back from the device. It can be an empty array!!
  79420. */
  79421. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79422. /**
  79423. * Use this to temporarily pause hit test checks.
  79424. */
  79425. paused: boolean;
  79426. /**
  79427. * Creates a new instance of the hit test feature
  79428. * @param _xrSessionManager an instance of WebXRSessionManager
  79429. * @param options options to use when constructing this feature
  79430. */
  79431. constructor(_xrSessionManager: WebXRSessionManager,
  79432. /**
  79433. * options to use when constructing this feature
  79434. */
  79435. options?: IWebXRHitTestOptions);
  79436. /**
  79437. * attach this feature
  79438. * Will usually be called by the features manager
  79439. *
  79440. * @returns true if successful.
  79441. */
  79442. attach(): boolean;
  79443. /**
  79444. * detach this feature.
  79445. * Will usually be called by the features manager
  79446. *
  79447. * @returns true if successful.
  79448. */
  79449. detach(): boolean;
  79450. /**
  79451. * Dispose this feature and all of the resources attached
  79452. */
  79453. dispose(): void;
  79454. protected _onXRFrame(frame: XRFrame): void;
  79455. private _processWebXRHitTestResult;
  79456. }
  79457. }
  79458. declare module BABYLON {
  79459. /**
  79460. * Configuration options of the anchor system
  79461. */
  79462. export interface IWebXRAnchorSystemOptions {
  79463. /**
  79464. * a node that will be used to convert local to world coordinates
  79465. */
  79466. worldParentNode?: TransformNode;
  79467. /**
  79468. * If set to true a reference of the created anchors will be kept until the next session starts
  79469. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79470. */
  79471. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79472. }
  79473. /**
  79474. * A babylon container for an XR Anchor
  79475. */
  79476. export interface IWebXRAnchor {
  79477. /**
  79478. * A babylon-assigned ID for this anchor
  79479. */
  79480. id: number;
  79481. /**
  79482. * Transformation matrix to apply to an object attached to this anchor
  79483. */
  79484. transformationMatrix: Matrix;
  79485. /**
  79486. * The native anchor object
  79487. */
  79488. xrAnchor: XRAnchor;
  79489. /**
  79490. * if defined, this object will be constantly updated by the anchor's position and rotation
  79491. */
  79492. attachedNode?: TransformNode;
  79493. /**
  79494. * Remove this anchor from the scene
  79495. */
  79496. remove(): void;
  79497. }
  79498. /**
  79499. * An implementation of the anchor system for WebXR.
  79500. * For further information see https://github.com/immersive-web/anchors/
  79501. */
  79502. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79503. private _options;
  79504. private _lastFrameDetected;
  79505. private _trackedAnchors;
  79506. private _referenceSpaceForFrameAnchors;
  79507. private _futureAnchors;
  79508. /**
  79509. * The module's name
  79510. */
  79511. static readonly Name: string;
  79512. /**
  79513. * The (Babylon) version of this module.
  79514. * This is an integer representing the implementation version.
  79515. * This number does not correspond to the WebXR specs version
  79516. */
  79517. static readonly Version: number;
  79518. /**
  79519. * Observers registered here will be executed when a new anchor was added to the session
  79520. */
  79521. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79522. /**
  79523. * Observers registered here will be executed when an anchor was removed from the session
  79524. */
  79525. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79526. /**
  79527. * Observers registered here will be executed when an existing anchor updates
  79528. * This can execute N times every frame
  79529. */
  79530. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79531. /**
  79532. * Set the reference space to use for anchor creation, when not using a hit test.
  79533. * Will default to the session's reference space if not defined
  79534. */
  79535. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79536. /**
  79537. * constructs a new anchor system
  79538. * @param _xrSessionManager an instance of WebXRSessionManager
  79539. * @param _options configuration object for this feature
  79540. */
  79541. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79542. private _tmpVector;
  79543. private _tmpQuaternion;
  79544. private _populateTmpTransformation;
  79545. /**
  79546. * Create a new anchor point using a hit test result at a specific point in the scene
  79547. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79548. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79549. *
  79550. * @param hitTestResult The hit test result to use for this anchor creation
  79551. * @param position an optional position offset for this anchor
  79552. * @param rotationQuaternion an optional rotation offset for this anchor
  79553. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79554. */
  79555. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  79556. /**
  79557. * Add a new anchor at a specific position and rotation
  79558. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79559. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79560. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79561. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79562. *
  79563. * @param position the position in which to add an anchor
  79564. * @param rotationQuaternion an optional rotation for the anchor transformation
  79565. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79566. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79567. */
  79568. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79569. /**
  79570. * Get the list of anchors currently being tracked by the system
  79571. */
  79572. get anchors(): IWebXRAnchor[];
  79573. /**
  79574. * detach this feature.
  79575. * Will usually be called by the features manager
  79576. *
  79577. * @returns true if successful.
  79578. */
  79579. detach(): boolean;
  79580. /**
  79581. * Dispose this feature and all of the resources attached
  79582. */
  79583. dispose(): void;
  79584. protected _onXRFrame(frame: XRFrame): void;
  79585. /**
  79586. * avoiding using Array.find for global support.
  79587. * @param xrAnchor the plane to find in the array
  79588. */
  79589. private _findIndexInAnchorArray;
  79590. private _updateAnchorWithXRFrame;
  79591. private _createAnchorAtTransformation;
  79592. }
  79593. }
  79594. declare module BABYLON {
  79595. /**
  79596. * Options used in the plane detector module
  79597. */
  79598. export interface IWebXRPlaneDetectorOptions {
  79599. /**
  79600. * The node to use to transform the local results to world coordinates
  79601. */
  79602. worldParentNode?: TransformNode;
  79603. /**
  79604. * If set to true a reference of the created planes will be kept until the next session starts
  79605. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79606. */
  79607. doNotRemovePlanesOnSessionEnded?: boolean;
  79608. /**
  79609. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79610. */
  79611. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79612. }
  79613. /**
  79614. * A babylon interface for a WebXR plane.
  79615. * A Plane is actually a polygon, built from N points in space
  79616. *
  79617. * Supported in chrome 79, not supported in canary 81 ATM
  79618. */
  79619. export interface IWebXRPlane {
  79620. /**
  79621. * a babylon-assigned ID for this polygon
  79622. */
  79623. id: number;
  79624. /**
  79625. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79626. */
  79627. polygonDefinition: Array<Vector3>;
  79628. /**
  79629. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79630. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79631. */
  79632. transformationMatrix: Matrix;
  79633. /**
  79634. * the native xr-plane object
  79635. */
  79636. xrPlane: XRPlane;
  79637. }
  79638. /**
  79639. * The plane detector is used to detect planes in the real world when in AR
  79640. * For more information see https://github.com/immersive-web/real-world-geometry/
  79641. */
  79642. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79643. private _options;
  79644. private _detectedPlanes;
  79645. private _enabled;
  79646. private _lastFrameDetected;
  79647. /**
  79648. * The module's name
  79649. */
  79650. static readonly Name: string;
  79651. /**
  79652. * The (Babylon) version of this module.
  79653. * This is an integer representing the implementation version.
  79654. * This number does not correspond to the WebXR specs version
  79655. */
  79656. static readonly Version: number;
  79657. /**
  79658. * Observers registered here will be executed when a new plane was added to the session
  79659. */
  79660. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79661. /**
  79662. * Observers registered here will be executed when a plane is no longer detected in the session
  79663. */
  79664. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79665. /**
  79666. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79667. * This can execute N times every frame
  79668. */
  79669. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79670. /**
  79671. * construct a new Plane Detector
  79672. * @param _xrSessionManager an instance of xr Session manager
  79673. * @param _options configuration to use when constructing this feature
  79674. */
  79675. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79676. /**
  79677. * detach this feature.
  79678. * Will usually be called by the features manager
  79679. *
  79680. * @returns true if successful.
  79681. */
  79682. detach(): boolean;
  79683. /**
  79684. * Dispose this feature and all of the resources attached
  79685. */
  79686. dispose(): void;
  79687. /**
  79688. * Check if the needed objects are defined.
  79689. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79690. */
  79691. isCompatible(): boolean;
  79692. protected _onXRFrame(frame: XRFrame): void;
  79693. private _init;
  79694. private _updatePlaneWithXRPlane;
  79695. /**
  79696. * avoiding using Array.find for global support.
  79697. * @param xrPlane the plane to find in the array
  79698. */
  79699. private _findIndexInPlaneArray;
  79700. }
  79701. }
  79702. declare module BABYLON {
  79703. /**
  79704. * Options interface for the background remover plugin
  79705. */
  79706. export interface IWebXRBackgroundRemoverOptions {
  79707. /**
  79708. * Further background meshes to disable when entering AR
  79709. */
  79710. backgroundMeshes?: AbstractMesh[];
  79711. /**
  79712. * flags to configure the removal of the environment helper.
  79713. * If not set, the entire background will be removed. If set, flags should be set as well.
  79714. */
  79715. environmentHelperRemovalFlags?: {
  79716. /**
  79717. * Should the skybox be removed (default false)
  79718. */
  79719. skyBox?: boolean;
  79720. /**
  79721. * Should the ground be removed (default false)
  79722. */
  79723. ground?: boolean;
  79724. };
  79725. /**
  79726. * don't disable the environment helper
  79727. */
  79728. ignoreEnvironmentHelper?: boolean;
  79729. }
  79730. /**
  79731. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79732. */
  79733. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79734. /**
  79735. * read-only options to be used in this module
  79736. */
  79737. readonly options: IWebXRBackgroundRemoverOptions;
  79738. /**
  79739. * The module's name
  79740. */
  79741. static readonly Name: string;
  79742. /**
  79743. * The (Babylon) version of this module.
  79744. * This is an integer representing the implementation version.
  79745. * This number does not correspond to the WebXR specs version
  79746. */
  79747. static readonly Version: number;
  79748. /**
  79749. * registered observers will be triggered when the background state changes
  79750. */
  79751. onBackgroundStateChangedObservable: Observable<boolean>;
  79752. /**
  79753. * constructs a new background remover module
  79754. * @param _xrSessionManager the session manager for this module
  79755. * @param options read-only options to be used in this module
  79756. */
  79757. constructor(_xrSessionManager: WebXRSessionManager,
  79758. /**
  79759. * read-only options to be used in this module
  79760. */
  79761. options?: IWebXRBackgroundRemoverOptions);
  79762. /**
  79763. * attach this feature
  79764. * Will usually be called by the features manager
  79765. *
  79766. * @returns true if successful.
  79767. */
  79768. attach(): boolean;
  79769. /**
  79770. * detach this feature.
  79771. * Will usually be called by the features manager
  79772. *
  79773. * @returns true if successful.
  79774. */
  79775. detach(): boolean;
  79776. /**
  79777. * Dispose this feature and all of the resources attached
  79778. */
  79779. dispose(): void;
  79780. protected _onXRFrame(_xrFrame: XRFrame): void;
  79781. private _setBackgroundState;
  79782. }
  79783. }
  79784. declare module BABYLON {
  79785. /**
  79786. * Options for the controller physics feature
  79787. */
  79788. export class IWebXRControllerPhysicsOptions {
  79789. /**
  79790. * Should the headset get its own impostor
  79791. */
  79792. enableHeadsetImpostor?: boolean;
  79793. /**
  79794. * Optional parameters for the headset impostor
  79795. */
  79796. headsetImpostorParams?: {
  79797. /**
  79798. * The type of impostor to create. Default is sphere
  79799. */
  79800. impostorType: number;
  79801. /**
  79802. * the size of the impostor. Defaults to 10cm
  79803. */
  79804. impostorSize?: number | {
  79805. width: number;
  79806. height: number;
  79807. depth: number;
  79808. };
  79809. /**
  79810. * Friction definitions
  79811. */
  79812. friction?: number;
  79813. /**
  79814. * Restitution
  79815. */
  79816. restitution?: number;
  79817. };
  79818. /**
  79819. * The physics properties of the future impostors
  79820. */
  79821. physicsProperties?: {
  79822. /**
  79823. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79824. * Note that this requires a physics engine that supports mesh impostors!
  79825. */
  79826. useControllerMesh?: boolean;
  79827. /**
  79828. * The type of impostor to create. Default is sphere
  79829. */
  79830. impostorType?: number;
  79831. /**
  79832. * the size of the impostor. Defaults to 10cm
  79833. */
  79834. impostorSize?: number | {
  79835. width: number;
  79836. height: number;
  79837. depth: number;
  79838. };
  79839. /**
  79840. * Friction definitions
  79841. */
  79842. friction?: number;
  79843. /**
  79844. * Restitution
  79845. */
  79846. restitution?: number;
  79847. };
  79848. /**
  79849. * the xr input to use with this pointer selection
  79850. */
  79851. xrInput: WebXRInput;
  79852. }
  79853. /**
  79854. * Add physics impostor to your webxr controllers,
  79855. * including naive calculation of their linear and angular velocity
  79856. */
  79857. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79858. private readonly _options;
  79859. private _attachController;
  79860. private _controllers;
  79861. private _debugMode;
  79862. private _delta;
  79863. private _headsetImpostor?;
  79864. private _headsetMesh?;
  79865. private _lastTimestamp;
  79866. private _tmpQuaternion;
  79867. private _tmpVector;
  79868. /**
  79869. * The module's name
  79870. */
  79871. static readonly Name: string;
  79872. /**
  79873. * The (Babylon) version of this module.
  79874. * This is an integer representing the implementation version.
  79875. * This number does not correspond to the webxr specs version
  79876. */
  79877. static readonly Version: number;
  79878. /**
  79879. * Construct a new Controller Physics Feature
  79880. * @param _xrSessionManager the corresponding xr session manager
  79881. * @param _options options to create this feature with
  79882. */
  79883. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79884. /**
  79885. * @hidden
  79886. * enable debugging - will show console outputs and the impostor mesh
  79887. */
  79888. _enablePhysicsDebug(): void;
  79889. /**
  79890. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79891. * @param xrController the controller to add
  79892. */
  79893. addController(xrController: WebXRInputSource): void;
  79894. /**
  79895. * attach this feature
  79896. * Will usually be called by the features manager
  79897. *
  79898. * @returns true if successful.
  79899. */
  79900. attach(): boolean;
  79901. /**
  79902. * detach this feature.
  79903. * Will usually be called by the features manager
  79904. *
  79905. * @returns true if successful.
  79906. */
  79907. detach(): boolean;
  79908. /**
  79909. * Get the headset impostor, if enabled
  79910. * @returns the impostor
  79911. */
  79912. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79913. /**
  79914. * Get the physics impostor of a specific controller.
  79915. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79916. * @param controller the controller or the controller id of which to get the impostor
  79917. * @returns the impostor or null
  79918. */
  79919. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79920. /**
  79921. * Update the physics properties provided in the constructor
  79922. * @param newProperties the new properties object
  79923. */
  79924. setPhysicsProperties(newProperties: {
  79925. impostorType?: number;
  79926. impostorSize?: number | {
  79927. width: number;
  79928. height: number;
  79929. depth: number;
  79930. };
  79931. friction?: number;
  79932. restitution?: number;
  79933. }): void;
  79934. protected _onXRFrame(_xrFrame: any): void;
  79935. private _detachController;
  79936. }
  79937. }
  79938. declare module BABYLON {
  79939. /**
  79940. * A babylon interface for a "WebXR" feature point.
  79941. * Represents the position and confidence value of a given feature point.
  79942. */
  79943. export interface IWebXRFeaturePoint {
  79944. /**
  79945. * Represents the position of the feature point in world space.
  79946. */
  79947. position: Vector3;
  79948. /**
  79949. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79950. */
  79951. confidenceValue: number;
  79952. }
  79953. /**
  79954. * The feature point system is used to detect feature points from real world geometry.
  79955. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79956. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79957. */
  79958. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79959. private _enabled;
  79960. private _featurePointCloud;
  79961. /**
  79962. * The module's name
  79963. */
  79964. static readonly Name: string;
  79965. /**
  79966. * The (Babylon) version of this module.
  79967. * This is an integer representing the implementation version.
  79968. * This number does not correspond to the WebXR specs version
  79969. */
  79970. static readonly Version: number;
  79971. /**
  79972. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79973. * Will notify the observers about which feature points have been added.
  79974. */
  79975. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79976. /**
  79977. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79978. * Will notify the observers about which feature points have been updated.
  79979. */
  79980. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79981. /**
  79982. * The current feature point cloud maintained across frames.
  79983. */
  79984. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79985. /**
  79986. * construct the feature point system
  79987. * @param _xrSessionManager an instance of xr Session manager
  79988. */
  79989. constructor(_xrSessionManager: WebXRSessionManager);
  79990. /**
  79991. * Detach this feature.
  79992. * Will usually be called by the features manager
  79993. *
  79994. * @returns true if successful.
  79995. */
  79996. detach(): boolean;
  79997. /**
  79998. * Dispose this feature and all of the resources attached
  79999. */
  80000. dispose(): void;
  80001. /**
  80002. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80003. */
  80004. protected _onXRFrame(frame: XRFrame): void;
  80005. /**
  80006. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80007. */
  80008. private _init;
  80009. }
  80010. }
  80011. declare module BABYLON {
  80012. /**
  80013. * Configuration interface for the hand tracking feature
  80014. */
  80015. export interface IWebXRHandTrackingOptions {
  80016. /**
  80017. * The xrInput that will be used as source for new hands
  80018. */
  80019. xrInput: WebXRInput;
  80020. /**
  80021. * Configuration object for the joint meshes
  80022. */
  80023. jointMeshes?: {
  80024. /**
  80025. * Should the meshes created be invisible (defaults to false)
  80026. */
  80027. invisible?: boolean;
  80028. /**
  80029. * A source mesh to be used to create instances. Defaults to a sphere.
  80030. * This mesh will be the source for all other (25) meshes.
  80031. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80032. */
  80033. sourceMesh?: Mesh;
  80034. /**
  80035. * This function will be called after a mesh was created for a specific joint.
  80036. * Using this function you can either manipulate the instance or return a new mesh.
  80037. * When returning a new mesh the instance created before will be disposed
  80038. */
  80039. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80040. /**
  80041. * Should the source mesh stay visible. Defaults to false
  80042. */
  80043. keepOriginalVisible?: boolean;
  80044. /**
  80045. * Scale factor for all instances (defaults to 2)
  80046. */
  80047. scaleFactor?: number;
  80048. /**
  80049. * Should each instance have its own physics impostor
  80050. */
  80051. enablePhysics?: boolean;
  80052. /**
  80053. * If enabled, override default physics properties
  80054. */
  80055. physicsProps?: {
  80056. friction?: number;
  80057. restitution?: number;
  80058. impostorType?: number;
  80059. };
  80060. /**
  80061. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  80062. */
  80063. disableDefaultHandMesh?: boolean;
  80064. /**
  80065. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  80066. */
  80067. handMeshes?: {
  80068. right: AbstractMesh;
  80069. left: AbstractMesh;
  80070. };
  80071. /**
  80072. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  80073. */
  80074. rigMapping?: {
  80075. right: string[];
  80076. left: string[];
  80077. };
  80078. };
  80079. }
  80080. /**
  80081. * Parts of the hands divided to writs and finger names
  80082. */
  80083. export const enum HandPart {
  80084. /**
  80085. * HandPart - Wrist
  80086. */
  80087. WRIST = "wrist",
  80088. /**
  80089. * HandPart - The Thumb
  80090. */
  80091. THUMB = "thumb",
  80092. /**
  80093. * HandPart - Index finger
  80094. */
  80095. INDEX = "index",
  80096. /**
  80097. * HandPart - Middle finger
  80098. */
  80099. MIDDLE = "middle",
  80100. /**
  80101. * HandPart - Ring finger
  80102. */
  80103. RING = "ring",
  80104. /**
  80105. * HandPart - Little finger
  80106. */
  80107. LITTLE = "little"
  80108. }
  80109. /**
  80110. * Representing a single hand (with its corresponding native XRHand object)
  80111. */
  80112. export class WebXRHand implements IDisposable {
  80113. /** the controller to which the hand correlates */
  80114. readonly xrController: WebXRInputSource;
  80115. /** the meshes to be used to track the hand joints */
  80116. readonly trackedMeshes: AbstractMesh[];
  80117. private _handMesh?;
  80118. private _rigMapping?;
  80119. private _scene;
  80120. private _defaultHandMesh;
  80121. private _transformNodeMapping;
  80122. /**
  80123. * Hand-parts definition (key is HandPart)
  80124. */
  80125. handPartsDefinition: {
  80126. [key: string]: number[];
  80127. };
  80128. /**
  80129. * Observers will be triggered when the mesh for this hand was initialized.
  80130. */
  80131. onHandMeshReadyObservable: Observable<WebXRHand>;
  80132. /**
  80133. * Populate the HandPartsDefinition object.
  80134. * This is called as a side effect since certain browsers don't have XRHand defined.
  80135. */
  80136. private generateHandPartsDefinition;
  80137. /**
  80138. * Construct a new hand object
  80139. * @param xrController the controller to which the hand correlates
  80140. * @param trackedMeshes the meshes to be used to track the hand joints
  80141. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  80142. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  80143. * @param disableDefaultHandMesh should the default mesh creation be disabled
  80144. */
  80145. constructor(
  80146. /** the controller to which the hand correlates */
  80147. xrController: WebXRInputSource,
  80148. /** the meshes to be used to track the hand joints */
  80149. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  80150. /**
  80151. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  80152. */
  80153. get handMesh(): AbstractMesh | undefined;
  80154. /**
  80155. * Update this hand from the latest xr frame
  80156. * @param xrFrame xrFrame to update from
  80157. * @param referenceSpace The current viewer reference space
  80158. * @param scaleFactor optional scale factor for the meshes
  80159. */
  80160. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80161. /**
  80162. * Get meshes of part of the hand
  80163. * @param part the part of hand to get
  80164. * @returns An array of meshes that correlate to the hand part requested
  80165. */
  80166. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80167. /**
  80168. * Dispose this Hand object
  80169. */
  80170. dispose(): void;
  80171. private _generateDefaultHandMesh;
  80172. }
  80173. /**
  80174. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80175. */
  80176. export class WebXRHandTracking extends WebXRAbstractFeature {
  80177. /**
  80178. * options to use when constructing this feature
  80179. */
  80180. readonly options: IWebXRHandTrackingOptions;
  80181. private static _idCounter;
  80182. /**
  80183. * The module's name
  80184. */
  80185. static readonly Name: string;
  80186. /**
  80187. * The (Babylon) version of this module.
  80188. * This is an integer representing the implementation version.
  80189. * This number does not correspond to the WebXR specs version
  80190. */
  80191. static readonly Version: number;
  80192. /**
  80193. * This observable will notify registered observers when a new hand object was added and initialized
  80194. */
  80195. onHandAddedObservable: Observable<WebXRHand>;
  80196. /**
  80197. * This observable will notify its observers right before the hand object is disposed
  80198. */
  80199. onHandRemovedObservable: Observable<WebXRHand>;
  80200. private _hands;
  80201. /**
  80202. * Creates a new instance of the hit test feature
  80203. * @param _xrSessionManager an instance of WebXRSessionManager
  80204. * @param options options to use when constructing this feature
  80205. */
  80206. constructor(_xrSessionManager: WebXRSessionManager,
  80207. /**
  80208. * options to use when constructing this feature
  80209. */
  80210. options: IWebXRHandTrackingOptions);
  80211. /**
  80212. * Check if the needed objects are defined.
  80213. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80214. */
  80215. isCompatible(): boolean;
  80216. /**
  80217. * attach this feature
  80218. * Will usually be called by the features manager
  80219. *
  80220. * @returns true if successful.
  80221. */
  80222. attach(): boolean;
  80223. /**
  80224. * detach this feature.
  80225. * Will usually be called by the features manager
  80226. *
  80227. * @returns true if successful.
  80228. */
  80229. detach(): boolean;
  80230. /**
  80231. * Dispose this feature and all of the resources attached
  80232. */
  80233. dispose(): void;
  80234. /**
  80235. * Get the hand object according to the controller id
  80236. * @param controllerId the controller id to which we want to get the hand
  80237. * @returns null if not found or the WebXRHand object if found
  80238. */
  80239. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80240. /**
  80241. * Get a hand object according to the requested handedness
  80242. * @param handedness the handedness to request
  80243. * @returns null if not found or the WebXRHand object if found
  80244. */
  80245. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80246. protected _onXRFrame(_xrFrame: XRFrame): void;
  80247. private _attachHand;
  80248. private _detachHand;
  80249. }
  80250. }
  80251. declare module BABYLON {
  80252. /**
  80253. * Options used in the mesh detector module
  80254. */
  80255. export interface IWebXRMeshDetectorOptions {
  80256. /**
  80257. * The node to use to transform the local results to world coordinates
  80258. */
  80259. worldParentNode?: TransformNode;
  80260. /**
  80261. * If set to true a reference of the created meshes will be kept until the next session starts
  80262. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  80263. */
  80264. doNotRemoveMeshesOnSessionEnded?: boolean;
  80265. /**
  80266. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80267. */
  80268. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80269. /**
  80270. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  80271. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  80272. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  80273. */
  80274. convertCoordinateSystems?: boolean;
  80275. }
  80276. /**
  80277. * A babylon interface for a XR mesh's vertex data.
  80278. *
  80279. * Currently not supported by WebXR, available only with BabylonNative
  80280. */
  80281. export interface IWebXRVertexData {
  80282. /**
  80283. * A babylon-assigned ID for this mesh
  80284. */
  80285. id: number;
  80286. /**
  80287. * Data required for constructing a mesh in Babylon.js.
  80288. */
  80289. xrMesh: XRMesh;
  80290. /**
  80291. * The node to use to transform the local results to world coordinates.
  80292. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  80293. */
  80294. worldParentNode?: TransformNode;
  80295. /**
  80296. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  80297. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80298. */
  80299. positions?: Float32Array;
  80300. /**
  80301. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  80302. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80303. */
  80304. indices?: Uint32Array;
  80305. /**
  80306. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  80307. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  80308. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  80309. */
  80310. normals?: Float32Array;
  80311. /**
  80312. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  80313. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  80314. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80315. */
  80316. transformationMatrix?: Matrix;
  80317. }
  80318. /**
  80319. * The mesh detector is used to detect meshes in the real world when in AR
  80320. */
  80321. export class WebXRMeshDetector extends WebXRAbstractFeature {
  80322. private _options;
  80323. private _detectedMeshes;
  80324. /**
  80325. * The module's name
  80326. */
  80327. static readonly Name: string;
  80328. /**
  80329. * The (Babylon) version of this module.
  80330. * This is an integer representing the implementation version.
  80331. * This number does not correspond to the WebXR specs version
  80332. */
  80333. static readonly Version: number;
  80334. /**
  80335. * Observers registered here will be executed when a new mesh was added to the session
  80336. */
  80337. onMeshAddedObservable: Observable<IWebXRVertexData>;
  80338. /**
  80339. * Observers registered here will be executed when a mesh is no longer detected in the session
  80340. */
  80341. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  80342. /**
  80343. * Observers registered here will be executed when an existing mesh updates
  80344. */
  80345. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  80346. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  80347. detach(): boolean;
  80348. dispose(): void;
  80349. protected _onXRFrame(frame: XRFrame): void;
  80350. private _init;
  80351. private _updateVertexDataWithXRMesh;
  80352. }
  80353. }
  80354. declare module BABYLON {
  80355. /**
  80356. * Options interface for the background remover plugin
  80357. */
  80358. export interface IWebXRImageTrackingOptions {
  80359. /**
  80360. * A required array with images to track
  80361. */
  80362. images: {
  80363. /**
  80364. * The source of the image. can be a URL or an image bitmap
  80365. */
  80366. src: string | ImageBitmap;
  80367. /**
  80368. * The estimated width in the real world (in meters)
  80369. */
  80370. estimatedRealWorldWidth: number;
  80371. }[];
  80372. }
  80373. /**
  80374. * An object representing an image tracked by the system
  80375. */
  80376. export interface IWebXRTrackedImage {
  80377. /**
  80378. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  80379. */
  80380. id: number;
  80381. /**
  80382. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  80383. */
  80384. emulated?: boolean;
  80385. /**
  80386. * Just in case it is needed - the image bitmap that is being tracked
  80387. */
  80388. originalBitmap: ImageBitmap;
  80389. /**
  80390. * The native XR result image tracking result, untouched
  80391. */
  80392. xrTrackingResult?: XRImageTrackingResult;
  80393. /**
  80394. * Width in real world (meters)
  80395. */
  80396. realWorldWidth?: number;
  80397. /**
  80398. * A transformation matrix of this current image in the current reference space.
  80399. */
  80400. transformationMatrix: Matrix;
  80401. /**
  80402. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  80403. */
  80404. ratio?: number;
  80405. }
  80406. /**
  80407. * Image tracking for immersive AR sessions.
  80408. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  80409. */
  80410. export class WebXRImageTracking extends WebXRAbstractFeature {
  80411. /**
  80412. * read-only options to be used in this module
  80413. */
  80414. readonly options: IWebXRImageTrackingOptions;
  80415. /**
  80416. * The module's name
  80417. */
  80418. static readonly Name: string;
  80419. /**
  80420. * The (Babylon) version of this module.
  80421. * This is an integer representing the implementation version.
  80422. * This number does not correspond to the WebXR specs version
  80423. */
  80424. static readonly Version: number;
  80425. /**
  80426. * This will be triggered if the underlying system deems an image untrackable.
  80427. * The index is the index of the image from the array used to initialize the feature.
  80428. */
  80429. onUntrackableImageFoundObservable: Observable<number>;
  80430. /**
  80431. * An image was deemed trackable, and the system will start tracking it.
  80432. */
  80433. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  80434. /**
  80435. * The image was found and its state was updated.
  80436. */
  80437. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  80438. private _trackedImages;
  80439. private _originalTrackingRequest;
  80440. /**
  80441. * constructs the image tracking feature
  80442. * @param _xrSessionManager the session manager for this module
  80443. * @param options read-only options to be used in this module
  80444. */
  80445. constructor(_xrSessionManager: WebXRSessionManager,
  80446. /**
  80447. * read-only options to be used in this module
  80448. */
  80449. options: IWebXRImageTrackingOptions);
  80450. /**
  80451. * attach this feature
  80452. * Will usually be called by the features manager
  80453. *
  80454. * @returns true if successful.
  80455. */
  80456. attach(): boolean;
  80457. /**
  80458. * detach this feature.
  80459. * Will usually be called by the features manager
  80460. *
  80461. * @returns true if successful.
  80462. */
  80463. detach(): boolean;
  80464. /**
  80465. * Check if the needed objects are defined.
  80466. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80467. */
  80468. isCompatible(): boolean;
  80469. /**
  80470. * Get a tracked image by its ID.
  80471. *
  80472. * @param id the id of the image to load (position in the init array)
  80473. * @returns a trackable image, if exists in this location
  80474. */
  80475. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  80476. /**
  80477. * Dispose this feature and all of the resources attached
  80478. */
  80479. dispose(): void;
  80480. /**
  80481. * Extends the session init object if needed
  80482. * @returns augmentation object fo the xr session init object.
  80483. */
  80484. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  80485. protected _onXRFrame(_xrFrame: XRFrame): void;
  80486. private _init;
  80487. }
  80488. }
  80489. declare module BABYLON {
  80490. /**
  80491. * The motion controller class for all microsoft mixed reality controllers
  80492. */
  80493. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80494. protected readonly _mapping: {
  80495. defaultButton: {
  80496. valueNodeName: string;
  80497. unpressedNodeName: string;
  80498. pressedNodeName: string;
  80499. };
  80500. defaultAxis: {
  80501. valueNodeName: string;
  80502. minNodeName: string;
  80503. maxNodeName: string;
  80504. };
  80505. buttons: {
  80506. "xr-standard-trigger": {
  80507. rootNodeName: string;
  80508. componentProperty: string;
  80509. states: string[];
  80510. };
  80511. "xr-standard-squeeze": {
  80512. rootNodeName: string;
  80513. componentProperty: string;
  80514. states: string[];
  80515. };
  80516. "xr-standard-touchpad": {
  80517. rootNodeName: string;
  80518. labelAnchorNodeName: string;
  80519. touchPointNodeName: string;
  80520. };
  80521. "xr-standard-thumbstick": {
  80522. rootNodeName: string;
  80523. componentProperty: string;
  80524. states: string[];
  80525. };
  80526. };
  80527. axes: {
  80528. "xr-standard-touchpad": {
  80529. "x-axis": {
  80530. rootNodeName: string;
  80531. };
  80532. "y-axis": {
  80533. rootNodeName: string;
  80534. };
  80535. };
  80536. "xr-standard-thumbstick": {
  80537. "x-axis": {
  80538. rootNodeName: string;
  80539. };
  80540. "y-axis": {
  80541. rootNodeName: string;
  80542. };
  80543. };
  80544. };
  80545. };
  80546. /**
  80547. * The base url used to load the left and right controller models
  80548. */
  80549. static MODEL_BASE_URL: string;
  80550. /**
  80551. * The name of the left controller model file
  80552. */
  80553. static MODEL_LEFT_FILENAME: string;
  80554. /**
  80555. * The name of the right controller model file
  80556. */
  80557. static MODEL_RIGHT_FILENAME: string;
  80558. profileId: string;
  80559. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80560. protected _getFilenameAndPath(): {
  80561. filename: string;
  80562. path: string;
  80563. };
  80564. protected _getModelLoadingConstraints(): boolean;
  80565. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80566. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80567. protected _updateModel(): void;
  80568. }
  80569. }
  80570. declare module BABYLON {
  80571. /**
  80572. * The motion controller class for oculus touch (quest, rift).
  80573. * This class supports legacy mapping as well the standard xr mapping
  80574. */
  80575. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80576. private _forceLegacyControllers;
  80577. private _modelRootNode;
  80578. /**
  80579. * The base url used to load the left and right controller models
  80580. */
  80581. static MODEL_BASE_URL: string;
  80582. /**
  80583. * The name of the left controller model file
  80584. */
  80585. static MODEL_LEFT_FILENAME: string;
  80586. /**
  80587. * The name of the right controller model file
  80588. */
  80589. static MODEL_RIGHT_FILENAME: string;
  80590. /**
  80591. * Base Url for the Quest controller model.
  80592. */
  80593. static QUEST_MODEL_BASE_URL: string;
  80594. profileId: string;
  80595. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80596. protected _getFilenameAndPath(): {
  80597. filename: string;
  80598. path: string;
  80599. };
  80600. protected _getModelLoadingConstraints(): boolean;
  80601. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80602. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80603. protected _updateModel(): void;
  80604. /**
  80605. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80606. * between the touch and touch 2.
  80607. */
  80608. private _isQuest;
  80609. }
  80610. }
  80611. declare module BABYLON {
  80612. /**
  80613. * The motion controller class for the standard HTC-Vive controllers
  80614. */
  80615. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80616. private _modelRootNode;
  80617. /**
  80618. * The base url used to load the left and right controller models
  80619. */
  80620. static MODEL_BASE_URL: string;
  80621. /**
  80622. * File name for the controller model.
  80623. */
  80624. static MODEL_FILENAME: string;
  80625. profileId: string;
  80626. /**
  80627. * Create a new Vive motion controller object
  80628. * @param scene the scene to use to create this controller
  80629. * @param gamepadObject the corresponding gamepad object
  80630. * @param handedness the handedness of the controller
  80631. */
  80632. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80633. protected _getFilenameAndPath(): {
  80634. filename: string;
  80635. path: string;
  80636. };
  80637. protected _getModelLoadingConstraints(): boolean;
  80638. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80639. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80640. protected _updateModel(): void;
  80641. }
  80642. }
  80643. declare module BABYLON {
  80644. /**
  80645. * A cursor which tracks a point on a path
  80646. */
  80647. export class PathCursor {
  80648. private path;
  80649. /**
  80650. * Stores path cursor callbacks for when an onchange event is triggered
  80651. */
  80652. private _onchange;
  80653. /**
  80654. * The value of the path cursor
  80655. */
  80656. value: number;
  80657. /**
  80658. * The animation array of the path cursor
  80659. */
  80660. animations: Animation[];
  80661. /**
  80662. * Initializes the path cursor
  80663. * @param path The path to track
  80664. */
  80665. constructor(path: Path2);
  80666. /**
  80667. * Gets the cursor point on the path
  80668. * @returns A point on the path cursor at the cursor location
  80669. */
  80670. getPoint(): Vector3;
  80671. /**
  80672. * Moves the cursor ahead by the step amount
  80673. * @param step The amount to move the cursor forward
  80674. * @returns This path cursor
  80675. */
  80676. moveAhead(step?: number): PathCursor;
  80677. /**
  80678. * Moves the cursor behind by the step amount
  80679. * @param step The amount to move the cursor back
  80680. * @returns This path cursor
  80681. */
  80682. moveBack(step?: number): PathCursor;
  80683. /**
  80684. * Moves the cursor by the step amount
  80685. * If the step amount is greater than one, an exception is thrown
  80686. * @param step The amount to move the cursor
  80687. * @returns This path cursor
  80688. */
  80689. move(step: number): PathCursor;
  80690. /**
  80691. * Ensures that the value is limited between zero and one
  80692. * @returns This path cursor
  80693. */
  80694. private ensureLimits;
  80695. /**
  80696. * Runs onchange callbacks on change (used by the animation engine)
  80697. * @returns This path cursor
  80698. */
  80699. private raiseOnChange;
  80700. /**
  80701. * Executes a function on change
  80702. * @param f A path cursor onchange callback
  80703. * @returns This path cursor
  80704. */
  80705. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80706. }
  80707. }
  80708. declare module BABYLON {
  80709. /** @hidden */
  80710. export var blurPixelShader: {
  80711. name: string;
  80712. shader: string;
  80713. };
  80714. }
  80715. declare module BABYLON {
  80716. /** @hidden */
  80717. export var pointCloudVertexDeclaration: {
  80718. name: string;
  80719. shader: string;
  80720. };
  80721. }
  80722. // Mixins
  80723. interface Window {
  80724. mozIndexedDB: IDBFactory;
  80725. webkitIndexedDB: IDBFactory;
  80726. msIndexedDB: IDBFactory;
  80727. webkitURL: typeof URL;
  80728. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80729. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80730. WebGLRenderingContext: WebGLRenderingContext;
  80731. MSGesture: MSGesture;
  80732. CANNON: any;
  80733. AudioContext: AudioContext;
  80734. webkitAudioContext: AudioContext;
  80735. PointerEvent: any;
  80736. Math: Math;
  80737. Uint8Array: Uint8ArrayConstructor;
  80738. Float32Array: Float32ArrayConstructor;
  80739. mozURL: typeof URL;
  80740. msURL: typeof URL;
  80741. VRFrameData: any; // WebVR, from specs 1.1
  80742. DracoDecoderModule: any;
  80743. setImmediate(handler: (...args: any[]) => void): number;
  80744. }
  80745. interface HTMLCanvasElement {
  80746. requestPointerLock(): void;
  80747. msRequestPointerLock?(): void;
  80748. mozRequestPointerLock?(): void;
  80749. webkitRequestPointerLock?(): void;
  80750. /** Track whether a record is in progress */
  80751. isRecording: boolean;
  80752. /** Capture Stream method defined by some browsers */
  80753. captureStream(fps?: number): MediaStream;
  80754. }
  80755. interface CanvasRenderingContext2D {
  80756. msImageSmoothingEnabled: boolean;
  80757. }
  80758. interface MouseEvent {
  80759. mozMovementX: number;
  80760. mozMovementY: number;
  80761. webkitMovementX: number;
  80762. webkitMovementY: number;
  80763. msMovementX: number;
  80764. msMovementY: number;
  80765. }
  80766. interface Navigator {
  80767. mozGetVRDevices: (any: any) => any;
  80768. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80769. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80770. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80771. webkitGetGamepads(): Gamepad[];
  80772. msGetGamepads(): Gamepad[];
  80773. webkitGamepads(): Gamepad[];
  80774. }
  80775. interface HTMLVideoElement {
  80776. mozSrcObject: any;
  80777. }
  80778. interface Math {
  80779. fround(x: number): number;
  80780. imul(a: number, b: number): number;
  80781. log2(x: number): number;
  80782. }
  80783. interface WebGLRenderingContext {
  80784. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80785. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80786. vertexAttribDivisor(index: number, divisor: number): void;
  80787. createVertexArray(): any;
  80788. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80789. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80790. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80791. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80792. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80793. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80794. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80795. // Queries
  80796. createQuery(): WebGLQuery;
  80797. deleteQuery(query: WebGLQuery): void;
  80798. beginQuery(target: number, query: WebGLQuery): void;
  80799. endQuery(target: number): void;
  80800. getQueryParameter(query: WebGLQuery, pname: number): any;
  80801. getQuery(target: number, pname: number): any;
  80802. MAX_SAMPLES: number;
  80803. RGBA8: number;
  80804. READ_FRAMEBUFFER: number;
  80805. DRAW_FRAMEBUFFER: number;
  80806. UNIFORM_BUFFER: number;
  80807. HALF_FLOAT_OES: number;
  80808. RGBA16F: number;
  80809. RGBA32F: number;
  80810. R32F: number;
  80811. RG32F: number;
  80812. RGB32F: number;
  80813. R16F: number;
  80814. RG16F: number;
  80815. RGB16F: number;
  80816. RED: number;
  80817. RG: number;
  80818. R8: number;
  80819. RG8: number;
  80820. UNSIGNED_INT_24_8: number;
  80821. DEPTH24_STENCIL8: number;
  80822. MIN: number;
  80823. MAX: number;
  80824. /* Multiple Render Targets */
  80825. drawBuffers(buffers: number[]): void;
  80826. readBuffer(src: number): void;
  80827. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80828. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80829. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  80830. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  80831. // Occlusion Query
  80832. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  80833. ANY_SAMPLES_PASSED: number;
  80834. QUERY_RESULT_AVAILABLE: number;
  80835. QUERY_RESULT: number;
  80836. }
  80837. interface WebGLProgram {
  80838. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  80839. }
  80840. interface EXT_disjoint_timer_query {
  80841. QUERY_COUNTER_BITS_EXT: number;
  80842. TIME_ELAPSED_EXT: number;
  80843. TIMESTAMP_EXT: number;
  80844. GPU_DISJOINT_EXT: number;
  80845. QUERY_RESULT_EXT: number;
  80846. QUERY_RESULT_AVAILABLE_EXT: number;
  80847. queryCounterEXT(query: WebGLQuery, target: number): void;
  80848. createQueryEXT(): WebGLQuery;
  80849. beginQueryEXT(target: number, query: WebGLQuery): void;
  80850. endQueryEXT(target: number): void;
  80851. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  80852. deleteQueryEXT(query: WebGLQuery): void;
  80853. }
  80854. interface WebGLUniformLocation {
  80855. _currentState: any;
  80856. }
  80857. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  80858. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  80859. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  80860. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  80861. interface WebGLRenderingContext {
  80862. readonly RASTERIZER_DISCARD: number;
  80863. readonly DEPTH_COMPONENT24: number;
  80864. readonly TEXTURE_3D: number;
  80865. readonly TEXTURE_2D_ARRAY: number;
  80866. readonly TEXTURE_COMPARE_FUNC: number;
  80867. readonly TEXTURE_COMPARE_MODE: number;
  80868. readonly COMPARE_REF_TO_TEXTURE: number;
  80869. readonly TEXTURE_WRAP_R: number;
  80870. readonly HALF_FLOAT: number;
  80871. readonly RGB8: number;
  80872. readonly RED_INTEGER: number;
  80873. readonly RG_INTEGER: number;
  80874. readonly RGB_INTEGER: number;
  80875. readonly RGBA_INTEGER: number;
  80876. readonly R8_SNORM: number;
  80877. readonly RG8_SNORM: number;
  80878. readonly RGB8_SNORM: number;
  80879. readonly RGBA8_SNORM: number;
  80880. readonly R8I: number;
  80881. readonly RG8I: number;
  80882. readonly RGB8I: number;
  80883. readonly RGBA8I: number;
  80884. readonly R8UI: number;
  80885. readonly RG8UI: number;
  80886. readonly RGB8UI: number;
  80887. readonly RGBA8UI: number;
  80888. readonly R16I: number;
  80889. readonly RG16I: number;
  80890. readonly RGB16I: number;
  80891. readonly RGBA16I: number;
  80892. readonly R16UI: number;
  80893. readonly RG16UI: number;
  80894. readonly RGB16UI: number;
  80895. readonly RGBA16UI: number;
  80896. readonly R32I: number;
  80897. readonly RG32I: number;
  80898. readonly RGB32I: number;
  80899. readonly RGBA32I: number;
  80900. readonly R32UI: number;
  80901. readonly RG32UI: number;
  80902. readonly RGB32UI: number;
  80903. readonly RGBA32UI: number;
  80904. readonly RGB10_A2UI: number;
  80905. readonly R11F_G11F_B10F: number;
  80906. readonly RGB9_E5: number;
  80907. readonly RGB10_A2: number;
  80908. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  80909. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  80910. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  80911. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80912. readonly DEPTH_COMPONENT32F: number;
  80913. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  80914. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  80915. 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;
  80916. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  80917. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  80918. readonly TRANSFORM_FEEDBACK: number;
  80919. readonly INTERLEAVED_ATTRIBS: number;
  80920. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  80921. createTransformFeedback(): WebGLTransformFeedback;
  80922. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  80923. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  80924. beginTransformFeedback(primitiveMode: number): void;
  80925. endTransformFeedback(): void;
  80926. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  80927. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80928. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80929. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80930. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  80931. }
  80932. interface ImageBitmap {
  80933. readonly width: number;
  80934. readonly height: number;
  80935. close(): void;
  80936. }
  80937. interface WebGLQuery extends WebGLObject {
  80938. }
  80939. declare var WebGLQuery: {
  80940. prototype: WebGLQuery;
  80941. new(): WebGLQuery;
  80942. };
  80943. interface WebGLSampler extends WebGLObject {
  80944. }
  80945. declare var WebGLSampler: {
  80946. prototype: WebGLSampler;
  80947. new(): WebGLSampler;
  80948. };
  80949. interface WebGLSync extends WebGLObject {
  80950. }
  80951. declare var WebGLSync: {
  80952. prototype: WebGLSync;
  80953. new(): WebGLSync;
  80954. };
  80955. interface WebGLTransformFeedback extends WebGLObject {
  80956. }
  80957. declare var WebGLTransformFeedback: {
  80958. prototype: WebGLTransformFeedback;
  80959. new(): WebGLTransformFeedback;
  80960. };
  80961. interface WebGLVertexArrayObject extends WebGLObject {
  80962. }
  80963. declare var WebGLVertexArrayObject: {
  80964. prototype: WebGLVertexArrayObject;
  80965. new(): WebGLVertexArrayObject;
  80966. };
  80967. interface Navigator {
  80968. readonly gpu: GPU | undefined;
  80969. }
  80970. interface GPUColorDict {
  80971. a: number;
  80972. b: number;
  80973. g: number;
  80974. r: number;
  80975. }
  80976. type GPUColor = [number, number, number, number] | GPUColorDict;
  80977. interface GPUOrigin2DDict {
  80978. x?: number;
  80979. y?: number;
  80980. }
  80981. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  80982. interface GPUOrigin3DDict {
  80983. x?: number;
  80984. y?: number;
  80985. z?: number;
  80986. }
  80987. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  80988. interface GPUExtent3DDict {
  80989. width: number;
  80990. height: number;
  80991. depth: number;
  80992. }
  80993. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  80994. type GPUBindingResource =
  80995. | GPUSampler
  80996. | GPUTextureView
  80997. | GPUBufferBinding;
  80998. type GPUExtensionName =
  80999. | "texture-compression-bc"
  81000. | "timestamp-query"
  81001. | "pipeline-statistics-query"
  81002. | "depth-clamping"
  81003. | "depth24unorm-stencil8"
  81004. | "depth32float-stencil8";
  81005. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  81006. type GPUBindingType =
  81007. | "uniform-buffer"
  81008. | "storage-buffer"
  81009. | "readonly-storage-buffer"
  81010. | "sampler"
  81011. | "comparison-sampler"
  81012. | "sampled-texture"
  81013. | "readonly-storage-texture"
  81014. | "writeonly-storage-texture";
  81015. type GPUBlendFactor =
  81016. | "zero"
  81017. | "one"
  81018. | "src-color"
  81019. | "one-minus-src-color"
  81020. | "src-alpha"
  81021. | "one-minus-src-alpha"
  81022. | "dst-color"
  81023. | "one-minus-dst-color"
  81024. | "dst-alpha"
  81025. | "one-minus-dst-alpha"
  81026. | "src-alpha-saturated"
  81027. | "blend-color"
  81028. | "one-minus-blend-color";
  81029. type GPUBlendOperation =
  81030. | "add"
  81031. | "subtract"
  81032. | "reverse-subtract"
  81033. | "min"
  81034. | "max";
  81035. type GPUCompareFunction =
  81036. | "never"
  81037. | "less"
  81038. | "equal"
  81039. | "less-equal"
  81040. | "greater"
  81041. | "not-equal"
  81042. | "greater-equal"
  81043. | "always";
  81044. type GPUCullMode = "none" | "front" | "back";
  81045. type GPUFilterMode = "nearest" | "linear";
  81046. type GPUFrontFace = "ccw" | "cw";
  81047. type GPUIndexFormat = "uint16" | "uint32";
  81048. type GPUInputStepMode = "vertex" | "instance";
  81049. type GPULoadOp = "load";
  81050. type GPUPrimitiveTopology =
  81051. | "point-list"
  81052. | "line-list"
  81053. | "line-strip"
  81054. | "triangle-list"
  81055. | "triangle-strip";
  81056. type GPUStencilOperation =
  81057. | "keep"
  81058. | "zero"
  81059. | "replace"
  81060. | "invert"
  81061. | "increment-clamp"
  81062. | "decrement-clamp"
  81063. | "increment-wrap"
  81064. | "decrement-wrap";
  81065. type GPUStoreOp = "store" | "clear";
  81066. type GPUTextureDimension = "1d" | "2d" | "3d";
  81067. type GPUTextureFormat =
  81068. | "r8unorm"
  81069. | "r8snorm"
  81070. | "r8uint"
  81071. | "r8sint"
  81072. | "r16uint"
  81073. | "r16sint"
  81074. | "r16float"
  81075. | "rg8unorm"
  81076. | "rg8snorm"
  81077. | "rg8uint"
  81078. | "rg8sint"
  81079. | "r32uint"
  81080. | "r32sint"
  81081. | "r32float"
  81082. | "rg16uint"
  81083. | "rg16sint"
  81084. | "rg16float"
  81085. | "rgba8unorm"
  81086. | "rgba8unorm-srgb"
  81087. | "rgba8snorm"
  81088. | "rgba8uint"
  81089. | "rgba8sint"
  81090. | "bgra8unorm"
  81091. | "bgra8unorm-srgb"
  81092. | "rgb9e5ufloat"
  81093. | "rgb10a2unorm"
  81094. | "rg11b10ufloat"
  81095. | "rg32uint"
  81096. | "rg32sint"
  81097. | "rg32float"
  81098. | "rgba16uint"
  81099. | "rgba16sint"
  81100. | "rgba16float"
  81101. | "rgba32uint"
  81102. | "rgba32sint"
  81103. | "rgba32float"
  81104. | "stencil8"
  81105. | "depth16unorm"
  81106. | "depth24plus"
  81107. | "depth24plus-stencil8"
  81108. | "depth32float"
  81109. | "bc1-rgba-unorm"
  81110. | "bc1-rgba-unorm-srgb"
  81111. | "bc2-rgba-unorm"
  81112. | "bc2-rgba-unorm-srgb"
  81113. | "bc3-rgba-unorm"
  81114. | "bc3-rgba-unorm-srgb"
  81115. | "bc4-r-unorm"
  81116. | "bc4-r-snorm"
  81117. | "bc5-rg-unorm"
  81118. | "bc5-rg-snorm"
  81119. | "bc6h-rgb-ufloat"
  81120. | "bc6h-rgb-float"
  81121. | "bc7-rgba-unorm"
  81122. | "bc7-rgba-unorm-srgb"
  81123. | "depth24unorm-stencil8"
  81124. | "depth32float-stencil8";
  81125. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  81126. type GPUTextureViewDimension =
  81127. | "1d"
  81128. | "2d"
  81129. | "2d-array"
  81130. | "cube"
  81131. | "cube-array"
  81132. | "3d";
  81133. type GPUVertexFormat =
  81134. | "uchar2"
  81135. | "uchar4"
  81136. | "char2"
  81137. | "char4"
  81138. | "uchar2norm"
  81139. | "uchar4norm"
  81140. | "char2norm"
  81141. | "char4norm"
  81142. | "ushort2"
  81143. | "ushort4"
  81144. | "short2"
  81145. | "short4"
  81146. | "ushort2norm"
  81147. | "ushort4norm"
  81148. | "short2norm"
  81149. | "short4norm"
  81150. | "half2"
  81151. | "half4"
  81152. | "float"
  81153. | "float2"
  81154. | "float3"
  81155. | "float4"
  81156. | "uint"
  81157. | "uint2"
  81158. | "uint3"
  81159. | "uint4"
  81160. | "int"
  81161. | "int2"
  81162. | "int3"
  81163. | "int4";
  81164. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  81165. type GPUBufferUsageFlags = number;
  81166. type GPUColorWriteFlags = number;
  81167. type GPUShaderStageFlags = number;
  81168. type GPUTextureUsageFlags = number;
  81169. type GPUMapModeFlags = number;
  81170. interface GPUBindGroupEntry {
  81171. binding: number;
  81172. resource: GPUBindingResource;
  81173. }
  81174. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  81175. layout: GPUBindGroupLayout;
  81176. entries: Iterable<GPUBindGroupEntry>;
  81177. }
  81178. interface GPUBindGroupLayoutEntry {
  81179. binding: number;
  81180. visibility: GPUShaderStageFlags;
  81181. type: GPUBindingType;
  81182. hasDynamicOffset?: boolean;
  81183. minBufferBindingSize?: number;
  81184. viewDimension?: GPUTextureViewDimension;
  81185. textureComponentType?: GPUTextureComponentType;
  81186. storageTextureFormat?: GPUTextureFormat;
  81187. }
  81188. interface GPUBindGroupLayoutDescriptor
  81189. extends GPUObjectDescriptorBase {
  81190. entries: Iterable<GPUBindGroupLayoutEntry>;
  81191. }
  81192. interface GPUBlendDescriptor {
  81193. dstFactor?: GPUBlendFactor;
  81194. operation?: GPUBlendOperation;
  81195. srcFactor?: GPUBlendFactor;
  81196. }
  81197. interface GPUColorStateDescriptor {
  81198. format: GPUTextureFormat;
  81199. alphaBlend?: GPUBlendDescriptor;
  81200. colorBlend?: GPUBlendDescriptor;
  81201. writeMask?: GPUColorWriteFlags;
  81202. }
  81203. interface GPUBufferBinding {
  81204. buffer: GPUBuffer;
  81205. offset?: number;
  81206. size?: number;
  81207. }
  81208. interface GPUTextureDataLayout {
  81209. offset?: number;
  81210. bytesPerRow: number;
  81211. rowsPerImage?: number;
  81212. }
  81213. interface GPUBufferCopyView extends GPUTextureDataLayout {
  81214. buffer: GPUBuffer;
  81215. }
  81216. interface GPUTextureCopyView {
  81217. texture: GPUTexture;
  81218. mipLevel?: number;
  81219. origin?: GPUOrigin3D;
  81220. }
  81221. interface GPUImageBitmapCopyView {
  81222. imageBitmap: ImageBitmap;
  81223. origin?: GPUOrigin2D;
  81224. }
  81225. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  81226. size: number;
  81227. usage: GPUBufferUsageFlags;
  81228. mappedAtCreation?: boolean;
  81229. }
  81230. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  81231. label?: string;
  81232. measureExecutionTime?: boolean;
  81233. }
  81234. interface GPUComputePipelineDescriptor
  81235. extends GPUPipelineDescriptorBase {
  81236. computeStage: GPUProgrammableStageDescriptor;
  81237. }
  81238. interface GPUDepthStencilStateDescriptor {
  81239. format: GPUTextureFormat;
  81240. depthWriteEnabled?: boolean;
  81241. depthCompare?: GPUCompareFunction;
  81242. stencilFront?: GPUStencilStateFaceDescriptor;
  81243. stencilBack?: GPUStencilStateFaceDescriptor;
  81244. stencilReadMask?: number;
  81245. stencilWriteMask?: number;
  81246. }
  81247. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  81248. extensions?: Iterable<GPUExtensionName>;
  81249. limits?: GPULimits;
  81250. }
  81251. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  81252. initialValue?: number;
  81253. label?: string;
  81254. signalQueue?: GPUQueue;
  81255. }
  81256. interface GPUVertexAttributeDescriptor {
  81257. format: GPUVertexFormat;
  81258. offset: number;
  81259. shaderLocation: number;
  81260. }
  81261. interface GPUVertexBufferLayoutDescriptor {
  81262. arrayStride: number;
  81263. stepMode?: GPUInputStepMode;
  81264. attributes: Iterable<GPUVertexAttributeDescriptor>;
  81265. }
  81266. interface GPUVertexStateDescriptor {
  81267. indexFormat?: GPUIndexFormat;
  81268. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  81269. }
  81270. interface GPULimits {
  81271. maxBindGroups?: number;
  81272. maxDynamicUniformBuffersPerPipelineLayout?: number;
  81273. maxDynamicStorageBuffersPerPipelineLayout?: number;
  81274. maxSampledTexturesPerShaderStage?: number;
  81275. maxSamplersPerShaderStage?: number;
  81276. maxStorageBuffersPerShaderStage?: number;
  81277. maxStorageTexturesPerShaderStage?: number;
  81278. maxUniformBuffersPerShaderStage?: number;
  81279. maxUniformBufferBindingSize?: number;
  81280. }
  81281. interface GPUPipelineDescriptorBase {
  81282. label?: string;
  81283. layout?: GPUPipelineLayout;
  81284. }
  81285. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  81286. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  81287. }
  81288. interface GPUProgrammableStageDescriptor {
  81289. module: GPUShaderModule;
  81290. entryPoint: string;
  81291. }
  81292. interface GPURasterizationStateDescriptor {
  81293. frontFace?: GPUFrontFace;
  81294. cullMode?: GPUCullMode;
  81295. clampDepth?: boolean;
  81296. depthBias?: number;
  81297. depthBiasSlopeScale?: number;
  81298. depthBiasClamp?: number;
  81299. }
  81300. interface GPURenderPassColorAttachmentDescriptor {
  81301. attachment: GPUTextureView;
  81302. resolveTarget?: GPUTextureView;
  81303. loadValue: GPULoadOp | GPUColor;
  81304. storeOp?: GPUStoreOp;
  81305. }
  81306. interface GPURenderPassDepthStencilAttachmentDescriptor {
  81307. attachment: GPUTextureView;
  81308. depthLoadValue: GPULoadOp | number;
  81309. depthStoreOp: GPUStoreOp;
  81310. depthReadOnly?: boolean;
  81311. stencilLoadValue: GPULoadOp | number;
  81312. stencilStoreOp: GPUStoreOp;
  81313. stencilReadOnly?: boolean;
  81314. }
  81315. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  81316. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  81317. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  81318. }
  81319. interface GPURenderPipelineDescriptor
  81320. extends GPUPipelineDescriptorBase {
  81321. vertexStage: GPUProgrammableStageDescriptor;
  81322. fragmentStage?: GPUProgrammableStageDescriptor;
  81323. primitiveTopology: GPUPrimitiveTopology;
  81324. rasterizationState?: GPURasterizationStateDescriptor;
  81325. colorStates: Iterable<GPUColorStateDescriptor>;
  81326. depthStencilState?: GPUDepthStencilStateDescriptor;
  81327. vertexState?: GPUVertexStateDescriptor;
  81328. sampleCount?: number;
  81329. sampleMask?: number;
  81330. alphaToCoverageEnabled?: boolean;
  81331. }
  81332. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  81333. addressModeU?: GPUAddressMode;
  81334. addressModeV?: GPUAddressMode;
  81335. addressModeW?: GPUAddressMode;
  81336. magFilter?: GPUFilterMode;
  81337. minFilter?: GPUFilterMode;
  81338. mipmapFilter?: GPUFilterMode;
  81339. lodMinClamp?: number;
  81340. lodMaxClamp?: number;
  81341. compare?: GPUCompareFunction;
  81342. maxAnisotropy?: number;
  81343. }
  81344. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  81345. code: Uint32Array | string;
  81346. label?: string;
  81347. sourceMap?: object;
  81348. }
  81349. interface GPUStencilStateFaceDescriptor {
  81350. compare?: GPUCompareFunction;
  81351. depthFailOp?: GPUStencilOperation;
  81352. passOp?: GPUStencilOperation;
  81353. failOp?: GPUStencilOperation;
  81354. }
  81355. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  81356. device: GPUDevice;
  81357. format: GPUTextureFormat;
  81358. usage?: GPUTextureUsageFlags;
  81359. }
  81360. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  81361. size: GPUExtent3D;
  81362. mipLevelCount?: number;
  81363. sampleCount?: number;
  81364. dimension?: GPUTextureDimension;
  81365. format: GPUTextureFormat;
  81366. usage: GPUTextureUsageFlags;
  81367. }
  81368. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  81369. format?: GPUTextureFormat;
  81370. dimension?: GPUTextureViewDimension;
  81371. aspect?: GPUTextureAspect;
  81372. baseArrayLayer?: number;
  81373. baseMipLevel?: number;
  81374. arrayLayerCount?: number;
  81375. mipLevelCount?: number;
  81376. }
  81377. declare class GPUAdapter {
  81378. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  81379. private __brand: void;
  81380. readonly name: string;
  81381. readonly extensions: GPUExtensionName[];
  81382. readonly limits: Required<GPULimits>;
  81383. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  81384. }
  81385. declare class GPUBindGroup implements GPUObjectBase {
  81386. private __brand: void;
  81387. label: string | undefined;
  81388. }
  81389. declare class GPUBindGroupLayout implements GPUObjectBase {
  81390. private __brand: void;
  81391. label: string | undefined;
  81392. }
  81393. declare class GPUBuffer implements GPUObjectBase {
  81394. private __brand: void;
  81395. label: string | undefined;
  81396. destroy(): void;
  81397. unmap(): void;
  81398. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  81399. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  81400. }
  81401. declare class GPUCommandBuffer implements GPUObjectBase {
  81402. private __brand: void;
  81403. label: string | undefined;
  81404. readonly executionTime: Promise<number>;
  81405. }
  81406. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  81407. declare class GPUCommandEncoder implements GPUObjectBase {
  81408. private __brand: void;
  81409. label: string | undefined;
  81410. beginComputePass(
  81411. descriptor?: GPUComputePassDescriptor
  81412. ): GPUComputePassEncoder;
  81413. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  81414. copyBufferToBuffer(
  81415. source: GPUBuffer,
  81416. sourceOffset: number,
  81417. destination: GPUBuffer,
  81418. destinationOffset: number,
  81419. size: number
  81420. ): void;
  81421. copyBufferToTexture(
  81422. source: GPUBufferCopyView,
  81423. destination: GPUTextureCopyView,
  81424. copySize: GPUExtent3D
  81425. ): void;
  81426. copyTextureToBuffer(
  81427. source: GPUTextureCopyView,
  81428. destination: GPUBufferCopyView,
  81429. copySize: GPUExtent3D
  81430. ): void;
  81431. copyTextureToTexture(
  81432. source: GPUTextureCopyView,
  81433. destination: GPUTextureCopyView,
  81434. copySize: GPUExtent3D
  81435. ): void;
  81436. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  81437. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81438. popDebugGroup(): void;
  81439. pushDebugGroup(groupLabel: string): void;
  81440. insertDebugMarker(markerLabel: string): void;
  81441. }
  81442. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  81443. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  81444. private __brand: void;
  81445. label: string | undefined;
  81446. setBindGroup(
  81447. index: number,
  81448. bindGroup: GPUBindGroup,
  81449. dynamicOffsets?: Iterable<number>
  81450. ): void;
  81451. popDebugGroup(): void;
  81452. pushDebugGroup(groupLabel: string): void;
  81453. insertDebugMarker(markerLabel: string): void;
  81454. setPipeline(pipeline: GPUComputePipeline): void;
  81455. dispatch(x: number, y?: number, z?: number): void;
  81456. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81457. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81458. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81459. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81460. endPass(): void;
  81461. }
  81462. declare class GPUComputePipeline implements GPUPipelineBase {
  81463. private __brand: void;
  81464. label: string | undefined;
  81465. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81466. }
  81467. interface GPUObjectBase {
  81468. label: string | undefined;
  81469. }
  81470. interface GPUObjectDescriptorBase {
  81471. label?: string;
  81472. }
  81473. // SwapChain / CanvasContext
  81474. declare class GPUCanvasContext {
  81475. private __brand: void;
  81476. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  81477. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  81478. }
  81479. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  81480. private __brand: void;
  81481. label: string | undefined;
  81482. readonly adapter: GPUAdapter;
  81483. readonly extensions: GPUExtensionName[];
  81484. readonly limits: Required<GPULimits>;
  81485. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  81486. createBindGroupLayout(
  81487. descriptor: GPUBindGroupLayoutDescriptor
  81488. ): GPUBindGroupLayout;
  81489. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  81490. createPipelineLayout(
  81491. descriptor: GPUPipelineLayoutDescriptor
  81492. ): GPUPipelineLayout;
  81493. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  81494. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  81495. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  81496. createComputePipeline(
  81497. descriptor: GPUComputePipelineDescriptor
  81498. ): GPUComputePipeline;
  81499. createRenderPipeline(
  81500. descriptor: GPURenderPipelineDescriptor
  81501. ): GPURenderPipeline;
  81502. createReadyComputePipeline(
  81503. descriptor: GPUComputePipelineDescriptor
  81504. ): Promise<GPUComputePipeline>;
  81505. createReadyRenderPipeline(
  81506. descriptor: GPURenderPipelineDescriptor
  81507. ): Promise<GPURenderPipeline>;
  81508. createCommandEncoder(
  81509. descriptor?: GPUCommandEncoderDescriptor
  81510. ): GPUCommandEncoder;
  81511. createRenderBundleEncoder(
  81512. descriptor: GPURenderBundleEncoderDescriptor
  81513. ): GPURenderBundleEncoder;
  81514. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  81515. defaultQueue: GPUQueue;
  81516. pushErrorScope(filter: GPUErrorFilter): void;
  81517. popErrorScope(): Promise<GPUError | null>;
  81518. onuncapturederror: Event | undefined;
  81519. readonly lost: Promise<GPUDeviceLostInfo>;
  81520. }
  81521. declare class GPUFence implements GPUObjectBase {
  81522. private __brand: void;
  81523. label: string | undefined;
  81524. getCompletedValue(): number;
  81525. onCompletion(completionValue: number): Promise<void>;
  81526. }
  81527. interface GPUPipelineBase extends GPUObjectBase {
  81528. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81529. }
  81530. declare class GPUPipelineLayout implements GPUObjectBase {
  81531. private __brand: void;
  81532. label: string | undefined;
  81533. }
  81534. interface GPUProgrammablePassEncoder {
  81535. setBindGroup(
  81536. index: number,
  81537. bindGroup: GPUBindGroup,
  81538. dynamicOffsets?: Iterable<number>
  81539. ): void;
  81540. popDebugGroup(): void;
  81541. pushDebugGroup(groupLabel: string): void;
  81542. insertDebugMarker(markerLabel: string): void;
  81543. }
  81544. declare class GPUQueue implements GPUObjectBase {
  81545. private __brand: void;
  81546. label: string | undefined;
  81547. signal(fence: GPUFence, signalValue: number): void;
  81548. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  81549. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  81550. writeBuffer(buffer: GPUBuffer,
  81551. bufferOffset: number,
  81552. data: BufferSource | ArrayBuffer,
  81553. dataOffset?: number,
  81554. size?: number): void;
  81555. writeTexture(destination: GPUTextureCopyView,
  81556. data: BufferSource | ArrayBuffer,
  81557. dataLayout: GPUTextureDataLayout,
  81558. size: GPUExtent3D): void;
  81559. copyImageBitmapToTexture(
  81560. source: GPUImageBitmapCopyView,
  81561. destination: GPUTextureCopyView,
  81562. copySize: GPUExtent3D
  81563. ): void;
  81564. }
  81565. type GPUQueryType =
  81566. | "occlusion"
  81567. | "timestamp"
  81568. | "pipeline-statistics";
  81569. type GPUPipelineStatisticName =
  81570. | "vertex-shader-invocations"
  81571. | "clipper-invocations"
  81572. | "clipper-primitives-out"
  81573. | "fragment-shader-invocations"
  81574. | "compute-shader-invocations";
  81575. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  81576. type: GPUQueryType;
  81577. count: number;
  81578. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  81579. }
  81580. declare class GPUQuerySet implements GPUObjectBase {
  81581. private __brand: void;
  81582. label: string | undefined;
  81583. destroy(): void;
  81584. }
  81585. interface GPURenderEncoderBase {
  81586. setPipeline(pipeline: GPURenderPipeline): void;
  81587. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  81588. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81589. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  81590. draw(
  81591. vertexCount: number,
  81592. instanceCount?: number,
  81593. firstVertex?: number,
  81594. firstInstance?: number
  81595. ): void;
  81596. drawIndexed(
  81597. indexCount: number,
  81598. instanceCount?: number,
  81599. firstIndex?: number,
  81600. baseVertex?: number,
  81601. firstInstance?: number
  81602. ): void;
  81603. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81604. drawIndexedIndirect(
  81605. indirectBuffer: GPUBuffer,
  81606. indirectOffset: number
  81607. ): void;
  81608. }
  81609. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  81610. private __brand: void;
  81611. label: string | undefined;
  81612. setBindGroup(
  81613. index: number,
  81614. bindGroup: GPUBindGroup,
  81615. dynamicOffsets?: Iterable<number>
  81616. ): void;
  81617. popDebugGroup(): void;
  81618. pushDebugGroup(groupLabel: string): void;
  81619. insertDebugMarker(markerLabel: string): void;
  81620. setPipeline(pipeline: GPURenderPipeline): void;
  81621. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81622. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81623. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81624. draw(
  81625. vertexCount: number,
  81626. instanceCount?: number,
  81627. firstVertex?: number,
  81628. firstInstance?: number
  81629. ): void;
  81630. drawIndexed(
  81631. indexCount: number,
  81632. instanceCount?: number,
  81633. firstIndex?: number,
  81634. baseVertex?: number,
  81635. firstInstance?: number
  81636. ): void;
  81637. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81638. drawIndexedIndirect(
  81639. indirectBuffer: GPUBuffer,
  81640. indirectOffset: number
  81641. ): void;
  81642. setViewport(
  81643. x: number,
  81644. y: number,
  81645. width: number,
  81646. height: number,
  81647. minDepth: number,
  81648. maxDepth: number
  81649. ): void;
  81650. setScissorRect(x: number, y: number, width: number, height: number): void;
  81651. setBlendColor(color: GPUColor): void;
  81652. setStencilReference(reference: number): void;
  81653. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81654. beginOcclusionQuery(queryIndex: number): void;
  81655. endOcclusionQuery(): void;
  81656. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81657. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81658. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  81659. endPass(): void;
  81660. }
  81661. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  81662. declare class GPURenderBundle implements GPUObjectBase {
  81663. private __brand: void;
  81664. label: string | undefined;
  81665. }
  81666. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  81667. private __brand: void;
  81668. label: string | undefined;
  81669. setBindGroup(
  81670. index: number,
  81671. bindGroup: GPUBindGroup,
  81672. dynamicOffsets?: Iterable<number>
  81673. ): void;
  81674. popDebugGroup(): void;
  81675. pushDebugGroup(groupLabel: string): void;
  81676. insertDebugMarker(markerLabel: string): void;
  81677. setPipeline(pipeline: GPURenderPipeline): void;
  81678. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81679. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81680. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81681. draw(
  81682. vertexCount: number,
  81683. instanceCount?: number,
  81684. firstVertex?: number,
  81685. firstInstance?: number
  81686. ): void;
  81687. drawIndexed(
  81688. indexCount: number,
  81689. instanceCount?: number,
  81690. firstIndex?: number,
  81691. baseVertex?: number,
  81692. firstInstance?: number
  81693. ): void;
  81694. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81695. drawIndexedIndirect(
  81696. indirectBuffer: GPUBuffer,
  81697. indirectOffset: number
  81698. ): void;
  81699. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  81700. }
  81701. interface GPURenderBundleEncoderDescriptor
  81702. extends GPUObjectDescriptorBase {
  81703. colorFormats: Iterable<GPUTextureFormat>;
  81704. depthStencilFormat?: GPUTextureFormat;
  81705. sampleCount?: number;
  81706. }
  81707. declare class GPURenderPipeline implements GPUPipelineBase {
  81708. private __brand: void;
  81709. label: string | undefined;
  81710. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81711. }
  81712. declare class GPUSampler implements GPUObjectBase {
  81713. private __brand: void;
  81714. label: string | undefined;
  81715. }
  81716. type GPUCompilationMessageType =
  81717. | "error"
  81718. | "warning"
  81719. | "info";
  81720. interface GPUCompilationMessage {
  81721. readonly message: string;
  81722. readonly type: GPUCompilationMessageType;
  81723. readonly lineNum: number;
  81724. readonly linePos: number;
  81725. }
  81726. interface GPUCompilationInfo {
  81727. readonly messages: readonly GPUCompilationMessage[];
  81728. }
  81729. declare class GPUShaderModule implements GPUObjectBase {
  81730. private __brand: void;
  81731. label: string | undefined;
  81732. compilationInfo(): Promise<GPUCompilationInfo>;
  81733. }
  81734. declare class GPUSwapChain implements GPUObjectBase {
  81735. private __brand: void;
  81736. label: string | undefined;
  81737. getCurrentTexture(): GPUTexture;
  81738. }
  81739. declare class GPUTexture implements GPUObjectBase {
  81740. private __brand: void;
  81741. label: string | undefined;
  81742. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81743. destroy(): void;
  81744. }
  81745. declare class GPUTextureView implements GPUObjectBase {
  81746. private __brand: void;
  81747. label: string | undefined;
  81748. }
  81749. type GPUPowerPreference = "low-power" | "high-performance";
  81750. interface GPURequestAdapterOptions {
  81751. powerPreference?: GPUPowerPreference;
  81752. }
  81753. declare class GPU {
  81754. private __brand: void;
  81755. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81756. }
  81757. // ****************************************************************************
  81758. // ERROR SCOPES
  81759. // ****************************************************************************
  81760. type GPUErrorFilter = "out-of-memory" | "validation";
  81761. declare class GPUOutOfMemoryError {
  81762. private __brand: void;
  81763. constructor();
  81764. }
  81765. declare class GPUValidationError {
  81766. private __brand: void;
  81767. constructor(message: string);
  81768. readonly message: string;
  81769. }
  81770. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81771. // ****************************************************************************
  81772. // TELEMETRY
  81773. // ****************************************************************************
  81774. declare class GPUUncapturedErrorEvent extends Event {
  81775. private __brand: void;
  81776. constructor(
  81777. type: string,
  81778. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81779. );
  81780. readonly error: GPUError;
  81781. }
  81782. interface GPUUncapturedErrorEventInit extends EventInit {
  81783. error: GPUError;
  81784. }
  81785. declare class GPUDeviceLostInfo {
  81786. private __brand: void;
  81787. readonly message: string;
  81788. }
  81789. // Type definitions for WebVR API
  81790. // Project: https://w3c.github.io/webvr/
  81791. // Definitions by: six a <https://github.com/lostfictions>
  81792. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81793. interface VRDisplay extends EventTarget {
  81794. /**
  81795. * Dictionary of capabilities describing the VRDisplay.
  81796. */
  81797. readonly capabilities: VRDisplayCapabilities;
  81798. /**
  81799. * z-depth defining the far plane of the eye view frustum
  81800. * enables mapping of values in the render target depth
  81801. * attachment to scene coordinates. Initially set to 10000.0.
  81802. */
  81803. depthFar: number;
  81804. /**
  81805. * z-depth defining the near plane of the eye view frustum
  81806. * enables mapping of values in the render target depth
  81807. * attachment to scene coordinates. Initially set to 0.01.
  81808. */
  81809. depthNear: number;
  81810. /**
  81811. * An identifier for this distinct VRDisplay. Used as an
  81812. * association point in the Gamepad API.
  81813. */
  81814. readonly displayId: number;
  81815. /**
  81816. * A display name, a user-readable name identifying it.
  81817. */
  81818. readonly displayName: string;
  81819. readonly isConnected: boolean;
  81820. readonly isPresenting: boolean;
  81821. /**
  81822. * If this VRDisplay supports room-scale experiences, the optional
  81823. * stage attribute contains details on the room-scale parameters.
  81824. */
  81825. readonly stageParameters: VRStageParameters | null;
  81826. /**
  81827. * Passing the value returned by `requestAnimationFrame` to
  81828. * `cancelAnimationFrame` will unregister the callback.
  81829. * @param handle Define the hanle of the request to cancel
  81830. */
  81831. cancelAnimationFrame(handle: number): void;
  81832. /**
  81833. * Stops presenting to the VRDisplay.
  81834. * @returns a promise to know when it stopped
  81835. */
  81836. exitPresent(): Promise<void>;
  81837. /**
  81838. * Return the current VREyeParameters for the given eye.
  81839. * @param whichEye Define the eye we want the parameter for
  81840. * @returns the eye parameters
  81841. */
  81842. getEyeParameters(whichEye: string): VREyeParameters;
  81843. /**
  81844. * Populates the passed VRFrameData with the information required to render
  81845. * the current frame.
  81846. * @param frameData Define the data structure to populate
  81847. * @returns true if ok otherwise false
  81848. */
  81849. getFrameData(frameData: VRFrameData): boolean;
  81850. /**
  81851. * Get the layers currently being presented.
  81852. * @returns the list of VR layers
  81853. */
  81854. getLayers(): VRLayer[];
  81855. /**
  81856. * Return a VRPose containing the future predicted pose of the VRDisplay
  81857. * when the current frame will be presented. The value returned will not
  81858. * change until JavaScript has returned control to the browser.
  81859. *
  81860. * The VRPose will contain the position, orientation, velocity,
  81861. * and acceleration of each of these properties.
  81862. * @returns the pose object
  81863. */
  81864. getPose(): VRPose;
  81865. /**
  81866. * Return the current instantaneous pose of the VRDisplay, with no
  81867. * prediction applied.
  81868. * @returns the current instantaneous pose
  81869. */
  81870. getImmediatePose(): VRPose;
  81871. /**
  81872. * The callback passed to `requestAnimationFrame` will be called
  81873. * any time a new frame should be rendered. When the VRDisplay is
  81874. * presenting the callback will be called at the native refresh
  81875. * rate of the HMD. When not presenting this function acts
  81876. * identically to how window.requestAnimationFrame acts. Content should
  81877. * make no assumptions of frame rate or vsync behavior as the HMD runs
  81878. * asynchronously from other displays and at differing refresh rates.
  81879. * @param callback Define the action to run next frame
  81880. * @returns the request handle it
  81881. */
  81882. requestAnimationFrame(callback: FrameRequestCallback): number;
  81883. /**
  81884. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  81885. * Repeat calls while already presenting will update the VRLayers being displayed.
  81886. * @param layers Define the list of layer to present
  81887. * @returns a promise to know when the request has been fulfilled
  81888. */
  81889. requestPresent(layers: VRLayer[]): Promise<void>;
  81890. /**
  81891. * Reset the pose for this display, treating its current position and
  81892. * orientation as the "origin/zero" values. VRPose.position,
  81893. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  81894. * updated when calling resetPose(). This should be called in only
  81895. * sitting-space experiences.
  81896. */
  81897. resetPose(): void;
  81898. /**
  81899. * The VRLayer provided to the VRDisplay will be captured and presented
  81900. * in the HMD. Calling this function has the same effect on the source
  81901. * canvas as any other operation that uses its source image, and canvases
  81902. * created without preserveDrawingBuffer set to true will be cleared.
  81903. * @param pose Define the pose to submit
  81904. */
  81905. submitFrame(pose?: VRPose): void;
  81906. }
  81907. declare var VRDisplay: {
  81908. prototype: VRDisplay;
  81909. new(): VRDisplay;
  81910. };
  81911. interface VRLayer {
  81912. leftBounds?: number[] | Float32Array | null;
  81913. rightBounds?: number[] | Float32Array | null;
  81914. source?: HTMLCanvasElement | null;
  81915. }
  81916. interface VRDisplayCapabilities {
  81917. readonly canPresent: boolean;
  81918. readonly hasExternalDisplay: boolean;
  81919. readonly hasOrientation: boolean;
  81920. readonly hasPosition: boolean;
  81921. readonly maxLayers: number;
  81922. }
  81923. interface VREyeParameters {
  81924. /** @deprecated */
  81925. readonly fieldOfView: VRFieldOfView;
  81926. readonly offset: Float32Array;
  81927. readonly renderHeight: number;
  81928. readonly renderWidth: number;
  81929. }
  81930. interface VRFieldOfView {
  81931. readonly downDegrees: number;
  81932. readonly leftDegrees: number;
  81933. readonly rightDegrees: number;
  81934. readonly upDegrees: number;
  81935. }
  81936. interface VRFrameData {
  81937. readonly leftProjectionMatrix: Float32Array;
  81938. readonly leftViewMatrix: Float32Array;
  81939. readonly pose: VRPose;
  81940. readonly rightProjectionMatrix: Float32Array;
  81941. readonly rightViewMatrix: Float32Array;
  81942. readonly timestamp: number;
  81943. }
  81944. interface VRPose {
  81945. readonly angularAcceleration: Float32Array | null;
  81946. readonly angularVelocity: Float32Array | null;
  81947. readonly linearAcceleration: Float32Array | null;
  81948. readonly linearVelocity: Float32Array | null;
  81949. readonly orientation: Float32Array | null;
  81950. readonly position: Float32Array | null;
  81951. readonly timestamp: number;
  81952. }
  81953. interface VRStageParameters {
  81954. sittingToStandingTransform?: Float32Array;
  81955. sizeX?: number;
  81956. sizeY?: number;
  81957. }
  81958. interface Navigator {
  81959. getVRDisplays(): Promise<VRDisplay[]>;
  81960. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  81961. }
  81962. interface Window {
  81963. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  81964. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  81965. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  81966. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81967. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81968. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  81969. }
  81970. interface Gamepad {
  81971. readonly displayId: number;
  81972. }
  81973. /**
  81974. * Available session modes
  81975. */
  81976. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  81977. /**
  81978. * Reference space types
  81979. */
  81980. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  81981. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  81982. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  81983. /**
  81984. * Handedness types
  81985. */
  81986. type XRHandedness = "none" | "left" | "right";
  81987. /**
  81988. * InputSource target ray modes
  81989. */
  81990. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  81991. /**
  81992. * Eye types
  81993. */
  81994. type XREye = "none" | "left" | "right";
  81995. /**
  81996. * Type of XR events available
  81997. */
  81998. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  81999. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  82000. type XRPlaneSet = Set<XRPlane>;
  82001. type XRAnchorSet = Set<XRAnchor>;
  82002. type XREventHandler = (callback: any) => void;
  82003. interface XRLayer extends EventTarget {}
  82004. interface XRSessionInit {
  82005. optionalFeatures?: string[];
  82006. requiredFeatures?: string[];
  82007. trackedImages?: XRTrackedImageInit[];
  82008. }
  82009. interface XRSessionEvent extends Event {
  82010. readonly session: XRSession;
  82011. }
  82012. interface XRSystem {
  82013. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  82014. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  82015. }
  82016. interface XRViewport {
  82017. readonly x: number;
  82018. readonly y: number;
  82019. readonly width: number;
  82020. readonly height: number;
  82021. }
  82022. interface XRWebGLLayerInit {
  82023. antialias?: boolean;
  82024. depth?: boolean;
  82025. stencil?: boolean;
  82026. alpha?: boolean;
  82027. multiview?: boolean;
  82028. framebufferScaleFactor?: number;
  82029. }
  82030. declare class XRWebGLLayer {
  82031. static getNativeFramebufferScaleFactor(session: XRSession): number;
  82032. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  82033. readonly antialias: boolean;
  82034. readonly framebuffer: WebGLFramebuffer;
  82035. readonly framebufferWidth: number;
  82036. readonly framebufferHeight: number;
  82037. readonly ignoreDepthValues: boolean;
  82038. getViewport: (view: XRView) => XRViewport;
  82039. }
  82040. // tslint:disable-next-line no-empty-interface
  82041. interface XRSpace extends EventTarget {}
  82042. interface XRRenderState {
  82043. readonly baseLayer?: XRWebGLLayer;
  82044. readonly depthFar: number;
  82045. readonly depthNear: number;
  82046. readonly inlineVerticalFieldOfView?: number;
  82047. }
  82048. interface XRRenderStateInit extends XRRenderState {
  82049. baseLayer: XRWebGLLayer;
  82050. depthFar: number;
  82051. depthNear: number;
  82052. inlineVerticalFieldOfView?: number;
  82053. layers?: XRLayer[];
  82054. }
  82055. interface XRReferenceSpace extends XRSpace {
  82056. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  82057. onreset: XREventHandler;
  82058. }
  82059. interface XRBoundedReferenceSpace extends XRSpace {
  82060. readonly boundsGeometry: DOMPointReadOnly[];
  82061. }
  82062. interface XRInputSource {
  82063. readonly handedness: XRHandedness;
  82064. readonly targetRayMode: XRTargetRayMode;
  82065. readonly targetRaySpace: XRSpace;
  82066. readonly gripSpace?: XRSpace;
  82067. readonly gamepad?: Gamepad;
  82068. readonly profiles: Array<string>;
  82069. readonly hand?: XRHand;
  82070. }
  82071. interface XRPose {
  82072. readonly transform: XRRigidTransform;
  82073. readonly emulatedPosition: boolean;
  82074. }
  82075. interface XRWorldInformation {
  82076. detectedPlanes?: XRPlaneSet;
  82077. }
  82078. interface XRFrame {
  82079. readonly session: XRSession;
  82080. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  82081. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  82082. // AR
  82083. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  82084. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  82085. // Anchors
  82086. trackedAnchors?: XRAnchorSet;
  82087. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  82088. // World geometries
  82089. worldInformation?: XRWorldInformation;
  82090. // Hand tracking
  82091. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  82092. // Image tracking
  82093. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  82094. }
  82095. interface XRInputSourceEvent extends Event {
  82096. readonly frame: XRFrame;
  82097. readonly inputSource: XRInputSource;
  82098. }
  82099. type XRInputSourceArray = XRInputSource[];
  82100. interface XRSession {
  82101. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  82102. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  82103. /**
  82104. * Returns a list of this session's XRInputSources, each representing an input device
  82105. * used to control the camera and/or scene.
  82106. */
  82107. readonly inputSources: Array<XRInputSource>;
  82108. /**
  82109. * object which contains options affecting how the imagery is rendered.
  82110. * This includes things such as the near and far clipping planes
  82111. */
  82112. readonly renderState: XRRenderState;
  82113. readonly visibilityState: XRVisibilityState;
  82114. /**
  82115. * Removes a callback from the animation frame painting callback from
  82116. * XRSession's set of animation frame rendering callbacks, given the
  82117. * identifying handle returned by a previous call to requestAnimationFrame().
  82118. */
  82119. cancelAnimationFrame: (handle: number) => void;
  82120. /**
  82121. * Ends the WebXR session. Returns a promise which resolves when the
  82122. * session has been shut down.
  82123. */
  82124. end(): Promise<void>;
  82125. /**
  82126. * Schedules the specified method to be called the next time the user agent
  82127. * is working on rendering an animation frame for the WebXR device. Returns an
  82128. * integer value which can be used to identify the request for the purposes of
  82129. * canceling the callback using cancelAnimationFrame(). This method is comparable
  82130. * to the Window.requestAnimationFrame() method.
  82131. */
  82132. requestAnimationFrame: XRFrameRequestCallback;
  82133. /**
  82134. * Requests that a new XRReferenceSpace of the specified type be created.
  82135. * Returns a promise which resolves with the XRReferenceSpace or
  82136. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  82137. * the requested space type isn't supported by the device.
  82138. */
  82139. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  82140. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  82141. onend: XREventHandler;
  82142. oninputsourceschange: XREventHandler;
  82143. onselect: XREventHandler;
  82144. onselectstart: XREventHandler;
  82145. onselectend: XREventHandler;
  82146. onsqueeze: XREventHandler;
  82147. onsqueezestart: XREventHandler;
  82148. onsqueezeend: XREventHandler;
  82149. onvisibilitychange: XREventHandler;
  82150. // hit test
  82151. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  82152. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  82153. // legacy AR hit test
  82154. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  82155. // legacy plane detection
  82156. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  82157. // image tracking
  82158. getTrackedImageScores?(): XRImageTrackingScore[];
  82159. }
  82160. interface XRViewerPose extends XRPose {
  82161. readonly views: Array<XRView>;
  82162. }
  82163. declare class XRRigidTransform {
  82164. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  82165. position: DOMPointReadOnly;
  82166. orientation: DOMPointReadOnly;
  82167. matrix: Float32Array;
  82168. inverse: XRRigidTransform;
  82169. }
  82170. interface XRView {
  82171. readonly eye: XREye;
  82172. readonly projectionMatrix: Float32Array;
  82173. readonly transform: XRRigidTransform;
  82174. readonly recommendedViewportScale?: number;
  82175. requestViewportScale(scale: number): void;
  82176. }
  82177. interface XRInputSourceChangeEvent extends Event {
  82178. session: XRSession;
  82179. removed: Array<XRInputSource>;
  82180. added: Array<XRInputSource>;
  82181. }
  82182. // Experimental/Draft features
  82183. declare class XRRay {
  82184. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  82185. origin: DOMPointReadOnly;
  82186. direction: DOMPointReadOnly;
  82187. matrix: Float32Array;
  82188. }
  82189. declare enum XRHitTestTrackableType {
  82190. "point",
  82191. "plane",
  82192. "mesh",
  82193. }
  82194. interface XRHitResult {
  82195. hitMatrix: Float32Array;
  82196. }
  82197. interface XRTransientInputHitTestResult {
  82198. readonly inputSource: XRInputSource;
  82199. readonly results: Array<XRHitTestResult>;
  82200. }
  82201. interface XRHitTestResult {
  82202. getPose(baseSpace: XRSpace): XRPose | undefined;
  82203. // When anchor system is enabled
  82204. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  82205. }
  82206. interface XRHitTestSource {
  82207. cancel(): void;
  82208. }
  82209. interface XRTransientInputHitTestSource {
  82210. cancel(): void;
  82211. }
  82212. interface XRHitTestOptionsInit {
  82213. space: XRSpace;
  82214. entityTypes?: Array<XRHitTestTrackableType>;
  82215. offsetRay?: XRRay;
  82216. }
  82217. interface XRTransientInputHitTestOptionsInit {
  82218. profile: string;
  82219. entityTypes?: Array<XRHitTestTrackableType>;
  82220. offsetRay?: XRRay;
  82221. }
  82222. interface XRAnchor {
  82223. anchorSpace: XRSpace;
  82224. delete(): void;
  82225. }
  82226. interface XRPlane {
  82227. orientation: "Horizontal" | "Vertical";
  82228. planeSpace: XRSpace;
  82229. polygon: Array<DOMPointReadOnly>;
  82230. lastChangedTime: number;
  82231. }
  82232. interface XRJointSpace extends XRSpace {}
  82233. interface XRJointPose extends XRPose {
  82234. radius: number | undefined;
  82235. }
  82236. interface XRHand extends Iterable<XRJointSpace> {
  82237. readonly length: number;
  82238. [index: number]: XRJointSpace;
  82239. readonly WRIST: number;
  82240. readonly THUMB_METACARPAL: number;
  82241. readonly THUMB_PHALANX_PROXIMAL: number;
  82242. readonly THUMB_PHALANX_DISTAL: number;
  82243. readonly THUMB_PHALANX_TIP: number;
  82244. readonly INDEX_METACARPAL: number;
  82245. readonly INDEX_PHALANX_PROXIMAL: number;
  82246. readonly INDEX_PHALANX_INTERMEDIATE: number;
  82247. readonly INDEX_PHALANX_DISTAL: number;
  82248. readonly INDEX_PHALANX_TIP: number;
  82249. readonly MIDDLE_METACARPAL: number;
  82250. readonly MIDDLE_PHALANX_PROXIMAL: number;
  82251. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  82252. readonly MIDDLE_PHALANX_DISTAL: number;
  82253. readonly MIDDLE_PHALANX_TIP: number;
  82254. readonly RING_METACARPAL: number;
  82255. readonly RING_PHALANX_PROXIMAL: number;
  82256. readonly RING_PHALANX_INTERMEDIATE: number;
  82257. readonly RING_PHALANX_DISTAL: number;
  82258. readonly RING_PHALANX_TIP: number;
  82259. readonly LITTLE_METACARPAL: number;
  82260. readonly LITTLE_PHALANX_PROXIMAL: number;
  82261. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  82262. readonly LITTLE_PHALANX_DISTAL: number;
  82263. readonly LITTLE_PHALANX_TIP: number;
  82264. }
  82265. type XRImageTrackingState = "tracked" | "emulated";
  82266. type XRImageTrackingScore = "untrackable" | "trackable";
  82267. interface XRTrackedImageInit {
  82268. image: ImageBitmap;
  82269. widthInMeters: number;
  82270. }
  82271. interface XRImageTrackingResult {
  82272. readonly imageSpace: XRSpace;
  82273. readonly index: number;
  82274. readonly trackingState: XRImageTrackingState;
  82275. readonly measuredWidthInMeters: number;
  82276. }
  82277. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  82278. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  82279. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  82280. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  82281. interface XRSceneObject {
  82282. type: XRSceneObjectType;
  82283. }
  82284. interface XRFieldOfView {
  82285. angleLeft: number;
  82286. angleRight: number;
  82287. angleUp: number;
  82288. angleDown: number;
  82289. }
  82290. interface XRFrustum {
  82291. position: DOMPointReadOnly;
  82292. orientation: DOMPointReadOnly;
  82293. fieldOfView: XRFieldOfView;
  82294. farDistance: number;
  82295. }
  82296. interface XRPlane {
  82297. parentSceneObject?: XRSceneObject;
  82298. }
  82299. interface XRMesh {
  82300. meshSpace: XRSpace;
  82301. positions: Float32Array;
  82302. indices: Uint32Array;
  82303. normals?: Float32Array;
  82304. lastChangedTime: number;
  82305. parentSceneObject?: XRSceneObject;
  82306. }
  82307. interface XRFrustumDetectionBoundary {
  82308. type: "frustum";
  82309. frustum: XRFrustum;
  82310. }
  82311. interface XRSphereDetectionBoundary {
  82312. type: "sphere";
  82313. radius: number;
  82314. }
  82315. interface XRBoxDetectionBoundary {
  82316. type: "box";
  82317. extent: DOMPointReadOnly;
  82318. }
  82319. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  82320. interface XRGeometryDetectorOptions {
  82321. detectionBoundary?: XRDetectionBoundary;
  82322. updateInterval?: number;
  82323. }
  82324. interface XRSession {
  82325. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  82326. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82327. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  82328. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82329. }
  82330. interface XRFrame {
  82331. featurePointCloud?: Array<number>;
  82332. }
  82333. type XRMeshSet = Set<XRMesh>;
  82334. interface XRWorldInformation {
  82335. detectedMeshes?: XRMeshSet;
  82336. }
  82337. /**
  82338. * @ignore
  82339. */
  82340. declare module BABYLON.GLTF2.Exporter {
  82341. }
  82342. /**
  82343. * @ignore
  82344. */
  82345. declare module BABYLON.GLTF1 {
  82346. }
  82347. declare module BABYLON.GUI {
  82348. /**
  82349. * Interface used to define a control that can receive focus
  82350. */
  82351. export interface IFocusableControl {
  82352. /**
  82353. * Function called when the control receives the focus
  82354. */
  82355. onFocus(): void;
  82356. /**
  82357. * Function called when the control loses the focus
  82358. */
  82359. onBlur(): void;
  82360. /**
  82361. * Function called to let the control handle keyboard events
  82362. * @param evt defines the current keyboard event
  82363. */
  82364. processKeyboard(evt: KeyboardEvent): void;
  82365. /**
  82366. * Function called to get the list of controls that should not steal the focus from this control
  82367. * @returns an array of controls
  82368. */
  82369. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  82370. /**
  82371. * Function to focus the control programmatically
  82372. */
  82373. focus(): void;
  82374. /**
  82375. * Function to unfocus the control programmatically
  82376. */
  82377. blur(): void;
  82378. }
  82379. }
  82380. declare module BABYLON.GUI {
  82381. /**
  82382. * Class used to specific a value and its associated unit
  82383. */
  82384. export class ValueAndUnit {
  82385. /** defines the unit to store */
  82386. unit: number;
  82387. /** defines a boolean indicating if the value can be negative */
  82388. negativeValueAllowed: boolean;
  82389. private _value;
  82390. private _originalUnit;
  82391. /**
  82392. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  82393. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82394. */
  82395. ignoreAdaptiveScaling: boolean;
  82396. /**
  82397. * Creates a new ValueAndUnit
  82398. * @param value defines the value to store
  82399. * @param unit defines the unit to store
  82400. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  82401. */
  82402. constructor(value: number,
  82403. /** defines the unit to store */
  82404. unit?: number,
  82405. /** defines a boolean indicating if the value can be negative */
  82406. negativeValueAllowed?: boolean);
  82407. /** Gets a boolean indicating if the value is a percentage */
  82408. get isPercentage(): boolean;
  82409. /** Gets a boolean indicating if the value is store as pixel */
  82410. get isPixel(): boolean;
  82411. /** Gets direct internal value */
  82412. get internalValue(): number;
  82413. /**
  82414. * Gets value as pixel
  82415. * @param host defines the root host
  82416. * @param refValue defines the reference value for percentages
  82417. * @returns the value as pixel
  82418. */
  82419. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  82420. /**
  82421. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  82422. * @param value defines the value to store
  82423. * @param unit defines the unit to store
  82424. * @returns the current ValueAndUnit
  82425. */
  82426. updateInPlace(value: number, unit?: number): ValueAndUnit;
  82427. /**
  82428. * Gets the value accordingly to its unit
  82429. * @param host defines the root host
  82430. * @returns the value
  82431. */
  82432. getValue(host: AdvancedDynamicTexture): number;
  82433. /**
  82434. * Gets a string representation of the value
  82435. * @param host defines the root host
  82436. * @param decimals defines an optional number of decimals to display
  82437. * @returns a string
  82438. */
  82439. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  82440. /**
  82441. * Store a value parsed from a string
  82442. * @param source defines the source string
  82443. * @returns true if the value was successfully parsed
  82444. */
  82445. fromString(source: string | number): boolean;
  82446. private static _Regex;
  82447. private static _UNITMODE_PERCENTAGE;
  82448. private static _UNITMODE_PIXEL;
  82449. /** UNITMODE_PERCENTAGE */
  82450. static get UNITMODE_PERCENTAGE(): number;
  82451. /** UNITMODE_PIXEL */
  82452. static get UNITMODE_PIXEL(): number;
  82453. }
  82454. }
  82455. declare module BABYLON.GUI {
  82456. /**
  82457. * Define a style used by control to automatically setup properties based on a template.
  82458. * Only support font related properties so far
  82459. */
  82460. export class Style implements BABYLON.IDisposable {
  82461. private _fontFamily;
  82462. private _fontStyle;
  82463. private _fontWeight;
  82464. /** @hidden */
  82465. _host: AdvancedDynamicTexture;
  82466. /** @hidden */
  82467. _fontSize: ValueAndUnit;
  82468. /**
  82469. * BABYLON.Observable raised when the style values are changed
  82470. */
  82471. onChangedObservable: BABYLON.Observable<Style>;
  82472. /**
  82473. * Creates a new style object
  82474. * @param host defines the AdvancedDynamicTexture which hosts this style
  82475. */
  82476. constructor(host: AdvancedDynamicTexture);
  82477. /**
  82478. * Gets or sets the font size
  82479. */
  82480. get fontSize(): string | number;
  82481. set fontSize(value: string | number);
  82482. /**
  82483. * Gets or sets the font family
  82484. */
  82485. get fontFamily(): string;
  82486. set fontFamily(value: string);
  82487. /**
  82488. * Gets or sets the font style
  82489. */
  82490. get fontStyle(): string;
  82491. set fontStyle(value: string);
  82492. /** Gets or sets font weight */
  82493. get fontWeight(): string;
  82494. set fontWeight(value: string);
  82495. /** Dispose all associated resources */
  82496. dispose(): void;
  82497. }
  82498. }
  82499. declare module BABYLON.GUI {
  82500. /**
  82501. * Class used to transport BABYLON.Vector2 information for pointer events
  82502. */
  82503. export class Vector2WithInfo extends BABYLON.Vector2 {
  82504. /** defines the current mouse button index */
  82505. buttonIndex: number;
  82506. /**
  82507. * Creates a new Vector2WithInfo
  82508. * @param source defines the vector2 data to transport
  82509. * @param buttonIndex defines the current mouse button index
  82510. */
  82511. constructor(source: BABYLON.Vector2,
  82512. /** defines the current mouse button index */
  82513. buttonIndex?: number);
  82514. }
  82515. /** Class used to provide 2D matrix features */
  82516. export class Matrix2D {
  82517. /** Gets the internal array of 6 floats used to store matrix data */
  82518. m: Float32Array;
  82519. /**
  82520. * Creates a new matrix
  82521. * @param m00 defines value for (0, 0)
  82522. * @param m01 defines value for (0, 1)
  82523. * @param m10 defines value for (1, 0)
  82524. * @param m11 defines value for (1, 1)
  82525. * @param m20 defines value for (2, 0)
  82526. * @param m21 defines value for (2, 1)
  82527. */
  82528. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  82529. /**
  82530. * Fills the matrix from direct values
  82531. * @param m00 defines value for (0, 0)
  82532. * @param m01 defines value for (0, 1)
  82533. * @param m10 defines value for (1, 0)
  82534. * @param m11 defines value for (1, 1)
  82535. * @param m20 defines value for (2, 0)
  82536. * @param m21 defines value for (2, 1)
  82537. * @returns the current modified matrix
  82538. */
  82539. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  82540. /**
  82541. * Gets matrix determinant
  82542. * @returns the determinant
  82543. */
  82544. determinant(): number;
  82545. /**
  82546. * Inverses the matrix and stores it in a target matrix
  82547. * @param result defines the target matrix
  82548. * @returns the current matrix
  82549. */
  82550. invertToRef(result: Matrix2D): Matrix2D;
  82551. /**
  82552. * Multiplies the current matrix with another one
  82553. * @param other defines the second operand
  82554. * @param result defines the target matrix
  82555. * @returns the current matrix
  82556. */
  82557. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  82558. /**
  82559. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  82560. * @param x defines the x coordinate to transform
  82561. * @param y defines the x coordinate to transform
  82562. * @param result defines the target vector2
  82563. * @returns the current matrix
  82564. */
  82565. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  82566. /**
  82567. * Creates an identity matrix
  82568. * @returns a new matrix
  82569. */
  82570. static Identity(): Matrix2D;
  82571. /**
  82572. * Creates a translation matrix and stores it in a target matrix
  82573. * @param x defines the x coordinate of the translation
  82574. * @param y defines the y coordinate of the translation
  82575. * @param result defines the target matrix
  82576. */
  82577. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  82578. /**
  82579. * Creates a scaling matrix and stores it in a target matrix
  82580. * @param x defines the x coordinate of the scaling
  82581. * @param y defines the y coordinate of the scaling
  82582. * @param result defines the target matrix
  82583. */
  82584. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  82585. /**
  82586. * Creates a rotation matrix and stores it in a target matrix
  82587. * @param angle defines the rotation angle
  82588. * @param result defines the target matrix
  82589. */
  82590. static RotationToRef(angle: number, result: Matrix2D): void;
  82591. private static _TempPreTranslationMatrix;
  82592. private static _TempPostTranslationMatrix;
  82593. private static _TempRotationMatrix;
  82594. private static _TempScalingMatrix;
  82595. private static _TempCompose0;
  82596. private static _TempCompose1;
  82597. private static _TempCompose2;
  82598. /**
  82599. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  82600. * @param tx defines the x coordinate of the translation
  82601. * @param ty defines the y coordinate of the translation
  82602. * @param angle defines the rotation angle
  82603. * @param scaleX defines the x coordinate of the scaling
  82604. * @param scaleY defines the y coordinate of the scaling
  82605. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  82606. * @param result defines the target matrix
  82607. */
  82608. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  82609. }
  82610. }
  82611. declare module BABYLON.GUI {
  82612. /**
  82613. * Class used to store 2D control sizes
  82614. */
  82615. export class Measure {
  82616. /** defines left coordinate */
  82617. left: number;
  82618. /** defines top coordinate */
  82619. top: number;
  82620. /** defines width dimension */
  82621. width: number;
  82622. /** defines height dimension */
  82623. height: number;
  82624. /**
  82625. * Creates a new measure
  82626. * @param left defines left coordinate
  82627. * @param top defines top coordinate
  82628. * @param width defines width dimension
  82629. * @param height defines height dimension
  82630. */
  82631. constructor(
  82632. /** defines left coordinate */
  82633. left: number,
  82634. /** defines top coordinate */
  82635. top: number,
  82636. /** defines width dimension */
  82637. width: number,
  82638. /** defines height dimension */
  82639. height: number);
  82640. /**
  82641. * Copy from another measure
  82642. * @param other defines the other measure to copy from
  82643. */
  82644. copyFrom(other: Measure): void;
  82645. /**
  82646. * Copy from a group of 4 floats
  82647. * @param left defines left coordinate
  82648. * @param top defines top coordinate
  82649. * @param width defines width dimension
  82650. * @param height defines height dimension
  82651. */
  82652. copyFromFloats(left: number, top: number, width: number, height: number): void;
  82653. /**
  82654. * Computes the axis aligned bounding box measure for two given measures
  82655. * @param a Input measure
  82656. * @param b Input measure
  82657. * @param result the resulting bounding measure
  82658. */
  82659. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  82660. /**
  82661. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82662. * @param transform the matrix to transform the measure before computing the AABB
  82663. * @param addX number to add to left
  82664. * @param addY number to add to top
  82665. * @param addWidth number to add to width
  82666. * @param addHeight number to add to height
  82667. * @param result the resulting AABB
  82668. */
  82669. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  82670. /**
  82671. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82672. * @param transform the matrix to transform the measure before computing the AABB
  82673. * @param result the resulting AABB
  82674. */
  82675. transformToRef(transform: Matrix2D, result: Measure): void;
  82676. /**
  82677. * Check equality between this measure and another one
  82678. * @param other defines the other measures
  82679. * @returns true if both measures are equals
  82680. */
  82681. isEqualsTo(other: Measure): boolean;
  82682. /**
  82683. * Creates an empty measure
  82684. * @returns a new measure
  82685. */
  82686. static Empty(): Measure;
  82687. }
  82688. }
  82689. declare module BABYLON.GUI {
  82690. /**
  82691. * Class used to create texture to support 2D GUI elements
  82692. * @see https://doc.babylonjs.com/how_to/gui
  82693. */
  82694. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  82695. /** Define the Uurl to load snippets */
  82696. static SnippetUrl: string;
  82697. /** Snippet ID if the content was created from the snippet server */
  82698. snippetId: string;
  82699. private _isDirty;
  82700. private _renderObserver;
  82701. private _resizeObserver;
  82702. private _preKeyboardObserver;
  82703. private _pointerMoveObserver;
  82704. private _pointerObserver;
  82705. private _canvasPointerOutObserver;
  82706. private _canvasBlurObserver;
  82707. private _background;
  82708. /** @hidden */
  82709. _rootContainer: Container;
  82710. /** @hidden */
  82711. _lastPickedControl: Control;
  82712. /** @hidden */
  82713. _lastControlOver: {
  82714. [pointerId: number]: Control;
  82715. };
  82716. /** @hidden */
  82717. _lastControlDown: {
  82718. [pointerId: number]: Control;
  82719. };
  82720. /** @hidden */
  82721. _capturingControl: {
  82722. [pointerId: number]: Control;
  82723. };
  82724. /** @hidden */
  82725. _shouldBlockPointer: boolean;
  82726. /** @hidden */
  82727. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  82728. /** @hidden */
  82729. _linkedControls: Control[];
  82730. private _isFullscreen;
  82731. private _fullscreenViewport;
  82732. private _idealWidth;
  82733. private _idealHeight;
  82734. private _useSmallestIdeal;
  82735. private _renderAtIdealSize;
  82736. private _focusedControl;
  82737. private _blockNextFocusCheck;
  82738. private _renderScale;
  82739. private _rootElement;
  82740. private _cursorChanged;
  82741. private _defaultMousePointerId;
  82742. /** @hidden */
  82743. _numLayoutCalls: number;
  82744. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82745. get numLayoutCalls(): number;
  82746. /** @hidden */
  82747. _numRenderCalls: number;
  82748. /** Gets the number of render calls made the last time the ADT has been rendered */
  82749. get numRenderCalls(): number;
  82750. /**
  82751. * Define type to string to ensure compatibility across browsers
  82752. * Safari doesn't support DataTransfer constructor
  82753. */
  82754. private _clipboardData;
  82755. /**
  82756. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82757. */
  82758. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82759. /**
  82760. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82761. */
  82762. onControlPickedObservable: BABYLON.Observable<Control>;
  82763. /**
  82764. * BABYLON.Observable event triggered before layout is evaluated
  82765. */
  82766. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82767. /**
  82768. * BABYLON.Observable event triggered after the layout was evaluated
  82769. */
  82770. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82771. /**
  82772. * BABYLON.Observable event triggered before the texture is rendered
  82773. */
  82774. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82775. /**
  82776. * BABYLON.Observable event triggered after the texture was rendered
  82777. */
  82778. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82779. /**
  82780. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82781. */
  82782. premulAlpha: boolean;
  82783. /**
  82784. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82785. */
  82786. applyYInversionOnUpdate: boolean;
  82787. /**
  82788. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82789. * Useful when you want more antialiasing
  82790. */
  82791. get renderScale(): number;
  82792. set renderScale(value: number);
  82793. /** Gets or sets the background color */
  82794. get background(): string;
  82795. set background(value: string);
  82796. /**
  82797. * Gets or sets the ideal width used to design controls.
  82798. * The GUI will then rescale everything accordingly
  82799. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82800. */
  82801. get idealWidth(): number;
  82802. set idealWidth(value: number);
  82803. /**
  82804. * Gets or sets the ideal height used to design controls.
  82805. * The GUI will then rescale everything accordingly
  82806. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82807. */
  82808. get idealHeight(): number;
  82809. set idealHeight(value: number);
  82810. /**
  82811. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82812. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82813. */
  82814. get useSmallestIdeal(): boolean;
  82815. set useSmallestIdeal(value: boolean);
  82816. /**
  82817. * Gets or sets a boolean indicating if adaptive scaling must be used
  82818. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82819. */
  82820. get renderAtIdealSize(): boolean;
  82821. set renderAtIdealSize(value: boolean);
  82822. /**
  82823. * Gets the ratio used when in "ideal mode"
  82824. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82825. * */
  82826. get idealRatio(): number;
  82827. /**
  82828. * Gets the underlying layer used to render the texture when in fullscreen mode
  82829. */
  82830. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  82831. /**
  82832. * Gets the root container control
  82833. */
  82834. get rootContainer(): Container;
  82835. /**
  82836. * Returns an array containing the root container.
  82837. * This is mostly used to let the Inspector introspects the ADT
  82838. * @returns an array containing the rootContainer
  82839. */
  82840. getChildren(): Array<Container>;
  82841. /**
  82842. * Will return all controls that are inside this texture
  82843. * @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
  82844. * @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
  82845. * @return all child controls
  82846. */
  82847. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  82848. /**
  82849. * Gets or sets the current focused control
  82850. */
  82851. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  82852. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  82853. /**
  82854. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  82855. */
  82856. get isForeground(): boolean;
  82857. set isForeground(value: boolean);
  82858. /**
  82859. * Gets or set information about clipboardData
  82860. */
  82861. get clipboardData(): string;
  82862. set clipboardData(value: string);
  82863. /**
  82864. * Creates a new AdvancedDynamicTexture
  82865. * @param name defines the name of the texture
  82866. * @param width defines the width of the texture
  82867. * @param height defines the height of the texture
  82868. * @param scene defines the hosting scene
  82869. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  82870. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82871. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82872. */
  82873. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  82874. /**
  82875. * Get the current class name of the texture useful for serialization or dynamic coding.
  82876. * @returns "AdvancedDynamicTexture"
  82877. */
  82878. getClassName(): string;
  82879. /**
  82880. * Function used to execute a function on all controls
  82881. * @param func defines the function to execute
  82882. * @param container defines the container where controls belong. If null the root container will be used
  82883. */
  82884. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  82885. private _useInvalidateRectOptimization;
  82886. /**
  82887. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  82888. */
  82889. get useInvalidateRectOptimization(): boolean;
  82890. set useInvalidateRectOptimization(value: boolean);
  82891. private _invalidatedRectangle;
  82892. /**
  82893. * Invalidates a rectangle area on the gui texture
  82894. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  82895. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  82896. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  82897. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  82898. */
  82899. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  82900. /**
  82901. * Marks the texture as dirty forcing a complete update
  82902. */
  82903. markAsDirty(): void;
  82904. /**
  82905. * Helper function used to create a new style
  82906. * @returns a new style
  82907. * @see https://doc.babylonjs.com/how_to/gui#styles
  82908. */
  82909. createStyle(): Style;
  82910. /**
  82911. * Adds a new control to the root container
  82912. * @param control defines the control to add
  82913. * @returns the current texture
  82914. */
  82915. addControl(control: Control): AdvancedDynamicTexture;
  82916. /**
  82917. * Removes a control from the root container
  82918. * @param control defines the control to remove
  82919. * @returns the current texture
  82920. */
  82921. removeControl(control: Control): AdvancedDynamicTexture;
  82922. /**
  82923. * Release all resources
  82924. */
  82925. dispose(): void;
  82926. private _onResize;
  82927. /** @hidden */
  82928. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  82929. /**
  82930. * Get screen coordinates for a vector3
  82931. * @param position defines the position to project
  82932. * @param worldMatrix defines the world matrix to use
  82933. * @returns the projected position
  82934. */
  82935. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  82936. /**
  82937. * Get screen coordinates for a vector3
  82938. * @param position defines the position to project
  82939. * @param worldMatrix defines the world matrix to use
  82940. * @returns the projected position with Z
  82941. */
  82942. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  82943. private _checkUpdate;
  82944. private _clearMeasure;
  82945. private _render;
  82946. /** @hidden */
  82947. _changeCursor(cursor: string): void;
  82948. /** @hidden */
  82949. _registerLastControlDown(control: Control, pointerId: number): void;
  82950. private _doPicking;
  82951. /** @hidden */
  82952. _cleanControlAfterRemovalFromList(list: {
  82953. [pointerId: number]: Control;
  82954. }, control: Control): void;
  82955. /** @hidden */
  82956. _cleanControlAfterRemoval(control: Control): void;
  82957. /** Attach to all scene events required to support pointer events */
  82958. attach(): void;
  82959. /** @hidden */
  82960. private onClipboardCopy;
  82961. /** @hidden */
  82962. private onClipboardCut;
  82963. /** @hidden */
  82964. private onClipboardPaste;
  82965. /**
  82966. * Register the clipboard Events onto the canvas
  82967. */
  82968. registerClipboardEvents(): void;
  82969. /**
  82970. * Unregister the clipboard Events from the canvas
  82971. */
  82972. unRegisterClipboardEvents(): void;
  82973. /**
  82974. * Connect the texture to a hosting mesh to enable interactions
  82975. * @param mesh defines the mesh to attach to
  82976. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  82977. */
  82978. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  82979. /**
  82980. * Move the focus to a specific control
  82981. * @param control defines the control which will receive the focus
  82982. */
  82983. moveFocusToControl(control: IFocusableControl): void;
  82984. private _manageFocus;
  82985. private _attachToOnPointerOut;
  82986. private _attachToOnBlur;
  82987. /**
  82988. * Serializes the entire GUI system
  82989. * @returns an object with the JSON serialized data
  82990. */
  82991. serializeContent(): any;
  82992. /**
  82993. * Recreate the content of the ADT from a JSON object
  82994. * @param serializedObject define the JSON serialized object to restore from
  82995. */
  82996. parseContent(serializedObject: any): void;
  82997. /**
  82998. * Recreate the content of the ADT from a snippet saved by the GUI editor
  82999. * @param snippetId defines the snippet to load
  83000. * @returns a promise that will resolve on success
  83001. */
  83002. parseFromSnippetAsync(snippetId: string): Promise<void>;
  83003. /**
  83004. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  83005. * @param mesh defines the mesh which will receive the texture
  83006. * @param width defines the texture width (1024 by default)
  83007. * @param height defines the texture height (1024 by default)
  83008. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83009. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  83010. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83011. * @returns a new AdvancedDynamicTexture
  83012. */
  83013. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83014. /**
  83015. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh) BUT do not create a new material for the mesh. You will be responsible for connecting the texture
  83016. * @param mesh defines the mesh which will receive the texture
  83017. * @param width defines the texture width (1024 by default)
  83018. * @param height defines the texture height (1024 by default)
  83019. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83020. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83021. * @returns a new AdvancedDynamicTexture
  83022. */
  83023. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83024. /**
  83025. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  83026. * In this mode the texture will rely on a layer for its rendering.
  83027. * This allows it to be treated like any other layer.
  83028. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  83029. * LayerMask is set through advancedTexture.layer.layerMask
  83030. * @param name defines name for the texture
  83031. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  83032. * @param scene defines the hsoting scene
  83033. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  83034. * @returns a new AdvancedDynamicTexture
  83035. */
  83036. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  83037. }
  83038. }
  83039. declare module BABYLON.GUI {
  83040. /**
  83041. * Root class used for all 2D controls
  83042. * @see https://doc.babylonjs.com/how_to/gui#controls
  83043. */
  83044. export class Control {
  83045. /** defines the name of the control */
  83046. name?: string | undefined;
  83047. /**
  83048. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  83049. */
  83050. static AllowAlphaInheritance: boolean;
  83051. private _alpha;
  83052. private _alphaSet;
  83053. private _zIndex;
  83054. /** @hidden */
  83055. _host: AdvancedDynamicTexture;
  83056. /** Gets or sets the control parent */
  83057. parent: BABYLON.Nullable<Container>;
  83058. /** @hidden */
  83059. _currentMeasure: Measure;
  83060. private _fontFamily;
  83061. private _fontStyle;
  83062. private _fontWeight;
  83063. private _fontSize;
  83064. private _font;
  83065. /** @hidden */
  83066. _width: ValueAndUnit;
  83067. /** @hidden */
  83068. _height: ValueAndUnit;
  83069. /** @hidden */
  83070. protected _fontOffset: {
  83071. ascent: number;
  83072. height: number;
  83073. descent: number;
  83074. };
  83075. private _color;
  83076. private _style;
  83077. private _styleObserver;
  83078. /** @hidden */
  83079. protected _horizontalAlignment: number;
  83080. /** @hidden */
  83081. protected _verticalAlignment: number;
  83082. /** @hidden */
  83083. protected _isDirty: boolean;
  83084. /** @hidden */
  83085. protected _wasDirty: boolean;
  83086. /** @hidden */
  83087. _tempParentMeasure: Measure;
  83088. /** @hidden */
  83089. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  83090. /** @hidden */
  83091. protected _cachedParentMeasure: Measure;
  83092. private _paddingLeft;
  83093. private _paddingRight;
  83094. private _paddingTop;
  83095. private _paddingBottom;
  83096. /** @hidden */
  83097. _left: ValueAndUnit;
  83098. /** @hidden */
  83099. _top: ValueAndUnit;
  83100. private _scaleX;
  83101. private _scaleY;
  83102. private _rotation;
  83103. private _transformCenterX;
  83104. private _transformCenterY;
  83105. /** @hidden */
  83106. _transformMatrix: Matrix2D;
  83107. /** @hidden */
  83108. protected _invertTransformMatrix: Matrix2D;
  83109. /** @hidden */
  83110. protected _transformedPosition: BABYLON.Vector2;
  83111. private _isMatrixDirty;
  83112. private _cachedOffsetX;
  83113. private _cachedOffsetY;
  83114. private _isVisible;
  83115. private _isHighlighted;
  83116. /** @hidden */
  83117. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  83118. private _fontSet;
  83119. private _dummyVector2;
  83120. private _downCount;
  83121. private _enterCount;
  83122. private _doNotRender;
  83123. private _downPointerIds;
  83124. protected _isEnabled: boolean;
  83125. protected _disabledColor: string;
  83126. protected _disabledColorItem: string;
  83127. /** @hidden */
  83128. protected _rebuildLayout: boolean;
  83129. /** @hidden */
  83130. _customData: any;
  83131. /** @hidden */
  83132. _isClipped: boolean;
  83133. /** @hidden */
  83134. _automaticSize: boolean;
  83135. /** @hidden */
  83136. _tag: any;
  83137. /**
  83138. * Gets or sets the unique id of the node. Please note that this number will be updated when the control is added to a container
  83139. */
  83140. uniqueId: number;
  83141. /**
  83142. * Gets or sets an object used to store user defined information for the node
  83143. */
  83144. metadata: any;
  83145. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  83146. isHitTestVisible: boolean;
  83147. /** Gets or sets a boolean indicating if the control can block pointer events */
  83148. isPointerBlocker: boolean;
  83149. /** Gets or sets a boolean indicating if the control can be focusable */
  83150. isFocusInvisible: boolean;
  83151. /**
  83152. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  83153. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  83154. */
  83155. clipChildren: boolean;
  83156. /**
  83157. * Gets or sets a boolean indicating that control content must be clipped
  83158. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  83159. */
  83160. clipContent: boolean;
  83161. /**
  83162. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  83163. */
  83164. useBitmapCache: boolean;
  83165. private _cacheData;
  83166. private _shadowOffsetX;
  83167. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  83168. get shadowOffsetX(): number;
  83169. set shadowOffsetX(value: number);
  83170. private _shadowOffsetY;
  83171. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  83172. get shadowOffsetY(): number;
  83173. set shadowOffsetY(value: number);
  83174. private _shadowBlur;
  83175. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  83176. get shadowBlur(): number;
  83177. set shadowBlur(value: number);
  83178. private _shadowColor;
  83179. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  83180. get shadowColor(): string;
  83181. set shadowColor(value: string);
  83182. /** Gets or sets the cursor to use when the control is hovered */
  83183. hoverCursor: string;
  83184. /** @hidden */
  83185. protected _linkOffsetX: ValueAndUnit;
  83186. /** @hidden */
  83187. protected _linkOffsetY: ValueAndUnit;
  83188. /** Gets the control type name */
  83189. get typeName(): string;
  83190. /**
  83191. * Get the current class name of the control.
  83192. * @returns current class name
  83193. */
  83194. getClassName(): string;
  83195. /**
  83196. * An event triggered when pointer wheel is scrolled
  83197. */
  83198. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  83199. /**
  83200. * An event triggered when the pointer move over the control.
  83201. */
  83202. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  83203. /**
  83204. * An event triggered when the pointer move out of the control.
  83205. */
  83206. onPointerOutObservable: BABYLON.Observable<Control>;
  83207. /**
  83208. * An event triggered when the pointer taps the control
  83209. */
  83210. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  83211. /**
  83212. * An event triggered when pointer up
  83213. */
  83214. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  83215. /**
  83216. * An event triggered when a control is clicked on
  83217. */
  83218. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  83219. /**
  83220. * An event triggered when pointer enters the control
  83221. */
  83222. onPointerEnterObservable: BABYLON.Observable<Control>;
  83223. /**
  83224. * An event triggered when the control is marked as dirty
  83225. */
  83226. onDirtyObservable: BABYLON.Observable<Control>;
  83227. /**
  83228. * An event triggered before drawing the control
  83229. */
  83230. onBeforeDrawObservable: BABYLON.Observable<Control>;
  83231. /**
  83232. * An event triggered after the control was drawn
  83233. */
  83234. onAfterDrawObservable: BABYLON.Observable<Control>;
  83235. /**
  83236. * An event triggered when the control has been disposed
  83237. */
  83238. onDisposeObservable: BABYLON.Observable<Control>;
  83239. /**
  83240. * Get the hosting AdvancedDynamicTexture
  83241. */
  83242. get host(): AdvancedDynamicTexture;
  83243. /** Gets or set information about font offsets (used to render and align text) */
  83244. get fontOffset(): {
  83245. ascent: number;
  83246. height: number;
  83247. descent: number;
  83248. };
  83249. set fontOffset(offset: {
  83250. ascent: number;
  83251. height: number;
  83252. descent: number;
  83253. });
  83254. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  83255. get alpha(): number;
  83256. set alpha(value: number);
  83257. /**
  83258. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  83259. */
  83260. get isHighlighted(): boolean;
  83261. set isHighlighted(value: boolean);
  83262. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  83263. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83264. */
  83265. get scaleX(): number;
  83266. set scaleX(value: number);
  83267. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  83268. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83269. */
  83270. get scaleY(): number;
  83271. set scaleY(value: number);
  83272. /** Gets or sets the rotation angle (0 by default)
  83273. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83274. */
  83275. get rotation(): number;
  83276. set rotation(value: number);
  83277. /** Gets or sets the transformation center on Y axis (0 by default)
  83278. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83279. */
  83280. get transformCenterY(): number;
  83281. set transformCenterY(value: number);
  83282. /** Gets or sets the transformation center on X axis (0 by default)
  83283. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83284. */
  83285. get transformCenterX(): number;
  83286. set transformCenterX(value: number);
  83287. /**
  83288. * Gets or sets the horizontal alignment
  83289. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83290. */
  83291. get horizontalAlignment(): number;
  83292. set horizontalAlignment(value: number);
  83293. /**
  83294. * Gets or sets the vertical alignment
  83295. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83296. */
  83297. get verticalAlignment(): number;
  83298. set verticalAlignment(value: number);
  83299. /**
  83300. * Gets or sets a fixed ratio for this control.
  83301. * When different from 0, the ratio is used to compute the "second" dimension.
  83302. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  83303. * second dimension is computed as first dimension * fixedRatio
  83304. */
  83305. fixedRatio: number;
  83306. private _fixedRatioMasterIsWidth;
  83307. /**
  83308. * Gets or sets control width
  83309. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83310. */
  83311. get width(): string | number;
  83312. set width(value: string | number);
  83313. /**
  83314. * Gets or sets the control width in pixel
  83315. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83316. */
  83317. get widthInPixels(): number;
  83318. set widthInPixels(value: number);
  83319. /**
  83320. * Gets or sets control height
  83321. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83322. */
  83323. get height(): string | number;
  83324. set height(value: string | number);
  83325. /**
  83326. * Gets or sets control height in pixel
  83327. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83328. */
  83329. get heightInPixels(): number;
  83330. set heightInPixels(value: number);
  83331. /** Gets or set font family */
  83332. get fontFamily(): string;
  83333. set fontFamily(value: string);
  83334. /** Gets or sets font style */
  83335. get fontStyle(): string;
  83336. set fontStyle(value: string);
  83337. /** Gets or sets font weight */
  83338. get fontWeight(): string;
  83339. set fontWeight(value: string);
  83340. /**
  83341. * Gets or sets style
  83342. * @see https://doc.babylonjs.com/how_to/gui#styles
  83343. */
  83344. get style(): BABYLON.Nullable<Style>;
  83345. set style(value: BABYLON.Nullable<Style>);
  83346. /** @hidden */
  83347. get _isFontSizeInPercentage(): boolean;
  83348. /** Gets or sets font size in pixels */
  83349. get fontSizeInPixels(): number;
  83350. set fontSizeInPixels(value: number);
  83351. /** Gets or sets font size */
  83352. get fontSize(): string | number;
  83353. set fontSize(value: string | number);
  83354. /** Gets or sets foreground color */
  83355. get color(): string;
  83356. set color(value: string);
  83357. /** Gets or sets z index which is used to reorder controls on the z axis */
  83358. get zIndex(): number;
  83359. set zIndex(value: number);
  83360. /** Gets or sets a boolean indicating if the control can be rendered */
  83361. get notRenderable(): boolean;
  83362. set notRenderable(value: boolean);
  83363. /** Gets or sets a boolean indicating if the control is visible */
  83364. get isVisible(): boolean;
  83365. set isVisible(value: boolean);
  83366. /** Gets a boolean indicating that the control needs to update its rendering */
  83367. get isDirty(): boolean;
  83368. /**
  83369. * Gets the current linked mesh (or null if none)
  83370. */
  83371. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  83372. /**
  83373. * Gets or sets a value indicating the padding to use on the left of the control
  83374. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83375. */
  83376. get paddingLeft(): string | number;
  83377. set paddingLeft(value: string | number);
  83378. /**
  83379. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  83380. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83381. */
  83382. get paddingLeftInPixels(): number;
  83383. set paddingLeftInPixels(value: number);
  83384. /**
  83385. * Gets or sets a value indicating the padding to use on the right of the control
  83386. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83387. */
  83388. get paddingRight(): string | number;
  83389. set paddingRight(value: string | number);
  83390. /**
  83391. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  83392. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83393. */
  83394. get paddingRightInPixels(): number;
  83395. set paddingRightInPixels(value: number);
  83396. /**
  83397. * Gets or sets a value indicating the padding to use on the top of the control
  83398. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83399. */
  83400. get paddingTop(): string | number;
  83401. set paddingTop(value: string | number);
  83402. /**
  83403. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  83404. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83405. */
  83406. get paddingTopInPixels(): number;
  83407. set paddingTopInPixels(value: number);
  83408. /**
  83409. * Gets or sets a value indicating the padding to use on the bottom of the control
  83410. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83411. */
  83412. get paddingBottom(): string | number;
  83413. set paddingBottom(value: string | number);
  83414. /**
  83415. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  83416. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83417. */
  83418. get paddingBottomInPixels(): number;
  83419. set paddingBottomInPixels(value: number);
  83420. /**
  83421. * Gets or sets a value indicating the left coordinate of the control
  83422. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83423. */
  83424. get left(): string | number;
  83425. set left(value: string | number);
  83426. /**
  83427. * Gets or sets a value indicating the left coordinate in pixels of the control
  83428. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83429. */
  83430. get leftInPixels(): number;
  83431. set leftInPixels(value: number);
  83432. /**
  83433. * Gets or sets a value indicating the top coordinate of the control
  83434. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83435. */
  83436. get top(): string | number;
  83437. set top(value: string | number);
  83438. /**
  83439. * Gets or sets a value indicating the top coordinate in pixels of the control
  83440. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83441. */
  83442. get topInPixels(): number;
  83443. set topInPixels(value: number);
  83444. /**
  83445. * Gets or sets a value indicating the offset on X axis to the linked mesh
  83446. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83447. */
  83448. get linkOffsetX(): string | number;
  83449. set linkOffsetX(value: string | number);
  83450. /**
  83451. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  83452. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83453. */
  83454. get linkOffsetXInPixels(): number;
  83455. set linkOffsetXInPixels(value: number);
  83456. /**
  83457. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  83458. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83459. */
  83460. get linkOffsetY(): string | number;
  83461. set linkOffsetY(value: string | number);
  83462. /**
  83463. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  83464. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83465. */
  83466. get linkOffsetYInPixels(): number;
  83467. set linkOffsetYInPixels(value: number);
  83468. /** Gets the center coordinate on X axis */
  83469. get centerX(): number;
  83470. /** Gets the center coordinate on Y axis */
  83471. get centerY(): number;
  83472. /** Gets or sets if control is Enabled */
  83473. get isEnabled(): boolean;
  83474. set isEnabled(value: boolean);
  83475. /** Gets or sets background color of control if it's disabled */
  83476. get disabledColor(): string;
  83477. set disabledColor(value: string);
  83478. /** Gets or sets front color of control if it's disabled */
  83479. get disabledColorItem(): string;
  83480. set disabledColorItem(value: string);
  83481. /**
  83482. * Creates a new control
  83483. * @param name defines the name of the control
  83484. */
  83485. constructor(
  83486. /** defines the name of the control */
  83487. name?: string | undefined);
  83488. /** @hidden */
  83489. protected _getTypeName(): string;
  83490. /**
  83491. * Gets the first ascendant in the hierarchy of the given type
  83492. * @param className defines the required type
  83493. * @returns the ascendant or null if not found
  83494. */
  83495. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  83496. /** @hidden */
  83497. _resetFontCache(): void;
  83498. /**
  83499. * Determines if a container is an ascendant of the current control
  83500. * @param container defines the container to look for
  83501. * @returns true if the container is one of the ascendant of the control
  83502. */
  83503. isAscendant(container: Control): boolean;
  83504. /**
  83505. * Gets coordinates in local control space
  83506. * @param globalCoordinates defines the coordinates to transform
  83507. * @returns the new coordinates in local space
  83508. */
  83509. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83510. /**
  83511. * Gets coordinates in local control space
  83512. * @param globalCoordinates defines the coordinates to transform
  83513. * @param result defines the target vector2 where to store the result
  83514. * @returns the current control
  83515. */
  83516. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  83517. /**
  83518. * Gets coordinates in parent local control space
  83519. * @param globalCoordinates defines the coordinates to transform
  83520. * @returns the new coordinates in parent local space
  83521. */
  83522. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83523. /**
  83524. * Move the current control to a vector3 position projected onto the screen.
  83525. * @param position defines the target position
  83526. * @param scene defines the hosting scene
  83527. */
  83528. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  83529. /**
  83530. * Will store all controls that have this control as ascendant in a given array
  83531. * @param results defines the array where to store the descendants
  83532. * @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
  83533. * @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
  83534. */
  83535. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83536. /**
  83537. * Will return all controls that have this control as ascendant
  83538. * @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
  83539. * @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
  83540. * @return all child controls
  83541. */
  83542. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83543. /**
  83544. * Link current control with a target mesh
  83545. * @param mesh defines the mesh to link with
  83546. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83547. */
  83548. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  83549. /**
  83550. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  83551. * @param { string | number} paddingTop - The value of the top padding.
  83552. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  83553. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  83554. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  83555. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83556. */
  83557. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  83558. /**
  83559. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  83560. * @param { number} paddingTop - The value in pixels of the top padding.
  83561. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  83562. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  83563. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  83564. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83565. */
  83566. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  83567. /** @hidden */
  83568. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  83569. /** @hidden */
  83570. _offsetLeft(offset: number): void;
  83571. /** @hidden */
  83572. _offsetTop(offset: number): void;
  83573. /** @hidden */
  83574. _markMatrixAsDirty(): void;
  83575. /** @hidden */
  83576. _flagDescendantsAsMatrixDirty(): void;
  83577. /** @hidden */
  83578. _intersectsRect(rect: Measure): boolean;
  83579. /** @hidden */
  83580. protected invalidateRect(): void;
  83581. /** @hidden */
  83582. _markAsDirty(force?: boolean): void;
  83583. /** @hidden */
  83584. _markAllAsDirty(): void;
  83585. /** @hidden */
  83586. _link(host: AdvancedDynamicTexture): void;
  83587. /** @hidden */
  83588. protected _transform(context?: CanvasRenderingContext2D): void;
  83589. /** @hidden */
  83590. _renderHighlight(context: CanvasRenderingContext2D): void;
  83591. /** @hidden */
  83592. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83593. /** @hidden */
  83594. protected _applyStates(context: CanvasRenderingContext2D): void;
  83595. /** @hidden */
  83596. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83597. /** @hidden */
  83598. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83599. protected _evaluateClippingState(parentMeasure: Measure): void;
  83600. /** @hidden */
  83601. _measure(): void;
  83602. /** @hidden */
  83603. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83604. /** @hidden */
  83605. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83606. /** @hidden */
  83607. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83608. /** @hidden */
  83609. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83610. private static _ClipMeasure;
  83611. private _tmpMeasureA;
  83612. private _clip;
  83613. /** @hidden */
  83614. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  83615. /** @hidden */
  83616. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83617. /**
  83618. * Tests if a given coordinates belong to the current control
  83619. * @param x defines x coordinate to test
  83620. * @param y defines y coordinate to test
  83621. * @returns true if the coordinates are inside the control
  83622. */
  83623. contains(x: number, y: number): boolean;
  83624. /** @hidden */
  83625. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83626. /** @hidden */
  83627. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83628. /** @hidden */
  83629. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83630. /** @hidden */
  83631. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  83632. /** @hidden */
  83633. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83634. /** @hidden */
  83635. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  83636. /** @hidden */
  83637. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  83638. /** @hidden */
  83639. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  83640. /** @hidden */
  83641. _onCanvasBlur(): void;
  83642. /** @hidden */
  83643. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83644. private _prepareFont;
  83645. /**
  83646. * Serializes the current control
  83647. * @param serializationObject defined the JSON serialized object
  83648. */
  83649. serialize(serializationObject: any): void;
  83650. /** @hidden */
  83651. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83652. /** Releases associated resources */
  83653. dispose(): void;
  83654. private static _HORIZONTAL_ALIGNMENT_LEFT;
  83655. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  83656. private static _HORIZONTAL_ALIGNMENT_CENTER;
  83657. private static _VERTICAL_ALIGNMENT_TOP;
  83658. private static _VERTICAL_ALIGNMENT_BOTTOM;
  83659. private static _VERTICAL_ALIGNMENT_CENTER;
  83660. /** HORIZONTAL_ALIGNMENT_LEFT */
  83661. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  83662. /** HORIZONTAL_ALIGNMENT_RIGHT */
  83663. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  83664. /** HORIZONTAL_ALIGNMENT_CENTER */
  83665. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  83666. /** VERTICAL_ALIGNMENT_TOP */
  83667. static get VERTICAL_ALIGNMENT_TOP(): number;
  83668. /** VERTICAL_ALIGNMENT_BOTTOM */
  83669. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  83670. /** VERTICAL_ALIGNMENT_CENTER */
  83671. static get VERTICAL_ALIGNMENT_CENTER(): number;
  83672. private static _FontHeightSizes;
  83673. /** @hidden */
  83674. static _GetFontOffset(font: string): {
  83675. ascent: number;
  83676. height: number;
  83677. descent: number;
  83678. };
  83679. /**
  83680. * Creates a Control from parsed data
  83681. * @param serializedObject defines parsed data
  83682. * @param host defines the hosting AdvancedDynamicTexture
  83683. * @returns a new Control
  83684. */
  83685. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  83686. /**
  83687. * Creates a stack panel that can be used to render headers
  83688. * @param control defines the control to associate with the header
  83689. * @param text defines the text of the header
  83690. * @param size defines the size of the header
  83691. * @param options defines options used to configure the header
  83692. * @returns a new StackPanel
  83693. * @ignore
  83694. * @hidden
  83695. */
  83696. static AddHeader: (control: Control, text: string, size: string | number, options: {
  83697. isHorizontal: boolean;
  83698. controlFirst: boolean;
  83699. }) => any;
  83700. /** @hidden */
  83701. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  83702. }
  83703. }
  83704. declare module BABYLON.GUI {
  83705. /**
  83706. * Root class for 2D containers
  83707. * @see https://doc.babylonjs.com/how_to/gui#containers
  83708. */
  83709. export class Container extends Control {
  83710. name?: string | undefined;
  83711. /** @hidden */
  83712. _children: Control[];
  83713. /** @hidden */
  83714. protected _measureForChildren: Measure;
  83715. /** @hidden */
  83716. protected _background: string;
  83717. /** @hidden */
  83718. protected _adaptWidthToChildren: boolean;
  83719. /** @hidden */
  83720. protected _adaptHeightToChildren: boolean;
  83721. /**
  83722. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  83723. */
  83724. logLayoutCycleErrors: boolean;
  83725. /**
  83726. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  83727. */
  83728. maxLayoutCycle: number;
  83729. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  83730. get adaptHeightToChildren(): boolean;
  83731. set adaptHeightToChildren(value: boolean);
  83732. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  83733. get adaptWidthToChildren(): boolean;
  83734. set adaptWidthToChildren(value: boolean);
  83735. /** Gets or sets background color */
  83736. get background(): string;
  83737. set background(value: string);
  83738. /** Gets the list of children */
  83739. get children(): Control[];
  83740. /**
  83741. * Creates a new Container
  83742. * @param name defines the name of the container
  83743. */
  83744. constructor(name?: string | undefined);
  83745. protected _getTypeName(): string;
  83746. _flagDescendantsAsMatrixDirty(): void;
  83747. /**
  83748. * Gets a child using its name
  83749. * @param name defines the child name to look for
  83750. * @returns the child control if found
  83751. */
  83752. getChildByName(name: string): BABYLON.Nullable<Control>;
  83753. /**
  83754. * Gets a child using its type and its name
  83755. * @param name defines the child name to look for
  83756. * @param type defines the child type to look for
  83757. * @returns the child control if found
  83758. */
  83759. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  83760. /**
  83761. * Search for a specific control in children
  83762. * @param control defines the control to look for
  83763. * @returns true if the control is in child list
  83764. */
  83765. containsControl(control: Control): boolean;
  83766. /**
  83767. * Adds a new control to the current container
  83768. * @param control defines the control to add
  83769. * @returns the current container
  83770. */
  83771. addControl(control: BABYLON.Nullable<Control>): Container;
  83772. /**
  83773. * Removes all controls from the current container
  83774. * @returns the current container
  83775. */
  83776. clearControls(): Container;
  83777. /**
  83778. * Removes a control from the current container
  83779. * @param control defines the control to remove
  83780. * @returns the current container
  83781. */
  83782. removeControl(control: Control): Container;
  83783. /** @hidden */
  83784. _reOrderControl(control: Control): void;
  83785. /** @hidden */
  83786. _offsetLeft(offset: number): void;
  83787. /** @hidden */
  83788. _offsetTop(offset: number): void;
  83789. /** @hidden */
  83790. _markAllAsDirty(): void;
  83791. /** @hidden */
  83792. protected _localDraw(context: CanvasRenderingContext2D): void;
  83793. /** @hidden */
  83794. _link(host: AdvancedDynamicTexture): void;
  83795. /** @hidden */
  83796. protected _beforeLayout(): void;
  83797. /** @hidden */
  83798. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83799. /** @hidden */
  83800. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83801. protected _postMeasure(): void;
  83802. /** @hidden */
  83803. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83804. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83805. /** @hidden */
  83806. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83807. /** @hidden */
  83808. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83809. /**
  83810. * Serializes the current control
  83811. * @param serializationObject defined the JSON serialized object
  83812. */
  83813. serialize(serializationObject: any): void;
  83814. /** Releases associated resources */
  83815. dispose(): void;
  83816. /** @hidden */
  83817. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83818. }
  83819. }
  83820. declare module BABYLON.GUI {
  83821. /** Class used to create rectangle container */
  83822. export class Rectangle extends Container {
  83823. name?: string | undefined;
  83824. private _thickness;
  83825. private _cornerRadius;
  83826. /** Gets or sets border thickness */
  83827. get thickness(): number;
  83828. set thickness(value: number);
  83829. /** Gets or sets the corner radius angle */
  83830. get cornerRadius(): number;
  83831. set cornerRadius(value: number);
  83832. /**
  83833. * Creates a new Rectangle
  83834. * @param name defines the control name
  83835. */
  83836. constructor(name?: string | undefined);
  83837. protected _getTypeName(): string;
  83838. protected _localDraw(context: CanvasRenderingContext2D): void;
  83839. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83840. private _drawRoundedRect;
  83841. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83842. }
  83843. }
  83844. declare module BABYLON.GUI {
  83845. /**
  83846. * Enum that determines the text-wrapping mode to use.
  83847. */
  83848. export enum TextWrapping {
  83849. /**
  83850. * Clip the text when it's larger than Control.width; this is the default mode.
  83851. */
  83852. Clip = 0,
  83853. /**
  83854. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  83855. */
  83856. WordWrap = 1,
  83857. /**
  83858. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  83859. */
  83860. Ellipsis = 2
  83861. }
  83862. /**
  83863. * Class used to create text block control
  83864. */
  83865. export class TextBlock extends Control {
  83866. /**
  83867. * Defines the name of the control
  83868. */
  83869. name?: string | undefined;
  83870. private _text;
  83871. private _textWrapping;
  83872. private _textHorizontalAlignment;
  83873. private _textVerticalAlignment;
  83874. private _lines;
  83875. private _resizeToFit;
  83876. private _lineSpacing;
  83877. private _outlineWidth;
  83878. private _outlineColor;
  83879. private _underline;
  83880. private _lineThrough;
  83881. /**
  83882. * An event triggered after the text is changed
  83883. */
  83884. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  83885. /**
  83886. * An event triggered after the text was broken up into lines
  83887. */
  83888. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  83889. /**
  83890. * Function used to split a string into words. By default, a string is split at each space character found
  83891. */
  83892. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  83893. /**
  83894. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  83895. */
  83896. get lines(): any[];
  83897. /**
  83898. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83899. */
  83900. get resizeToFit(): boolean;
  83901. /**
  83902. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83903. */
  83904. set resizeToFit(value: boolean);
  83905. /**
  83906. * Gets or sets a boolean indicating if text must be wrapped
  83907. */
  83908. get textWrapping(): TextWrapping | boolean;
  83909. /**
  83910. * Gets or sets a boolean indicating if text must be wrapped
  83911. */
  83912. set textWrapping(value: TextWrapping | boolean);
  83913. /**
  83914. * Gets or sets text to display
  83915. */
  83916. get text(): string;
  83917. /**
  83918. * Gets or sets text to display
  83919. */
  83920. set text(value: string);
  83921. /**
  83922. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83923. */
  83924. get textHorizontalAlignment(): number;
  83925. /**
  83926. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83927. */
  83928. set textHorizontalAlignment(value: number);
  83929. /**
  83930. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83931. */
  83932. get textVerticalAlignment(): number;
  83933. /**
  83934. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83935. */
  83936. set textVerticalAlignment(value: number);
  83937. /**
  83938. * Gets or sets line spacing value
  83939. */
  83940. set lineSpacing(value: string | number);
  83941. /**
  83942. * Gets or sets line spacing value
  83943. */
  83944. get lineSpacing(): string | number;
  83945. /**
  83946. * Gets or sets outlineWidth of the text to display
  83947. */
  83948. get outlineWidth(): number;
  83949. /**
  83950. * Gets or sets outlineWidth of the text to display
  83951. */
  83952. set outlineWidth(value: number);
  83953. /**
  83954. * Gets or sets a boolean indicating that text must have underline
  83955. */
  83956. get underline(): boolean;
  83957. /**
  83958. * Gets or sets a boolean indicating that text must have underline
  83959. */
  83960. set underline(value: boolean);
  83961. /**
  83962. * Gets or sets an boolean indicating that text must be crossed out
  83963. */
  83964. get lineThrough(): boolean;
  83965. /**
  83966. * Gets or sets an boolean indicating that text must be crossed out
  83967. */
  83968. set lineThrough(value: boolean);
  83969. /**
  83970. * Gets or sets outlineColor of the text to display
  83971. */
  83972. get outlineColor(): string;
  83973. /**
  83974. * Gets or sets outlineColor of the text to display
  83975. */
  83976. set outlineColor(value: string);
  83977. /**
  83978. * Creates a new TextBlock object
  83979. * @param name defines the name of the control
  83980. * @param text defines the text to display (emptry string by default)
  83981. */
  83982. constructor(
  83983. /**
  83984. * Defines the name of the control
  83985. */
  83986. name?: string | undefined, text?: string);
  83987. protected _getTypeName(): string;
  83988. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83989. private _drawText;
  83990. /** @hidden */
  83991. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83992. protected _applyStates(context: CanvasRenderingContext2D): void;
  83993. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  83994. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  83995. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  83996. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  83997. protected _renderLines(context: CanvasRenderingContext2D): void;
  83998. /**
  83999. * Given a width constraint applied on the text block, find the expected height
  84000. * @returns expected height
  84001. */
  84002. computeExpectedHeight(): number;
  84003. dispose(): void;
  84004. }
  84005. }
  84006. declare module BABYLON.GUI {
  84007. /**
  84008. * Class used to create 2D images
  84009. */
  84010. export class Image extends Control {
  84011. name?: string | undefined;
  84012. private _workingCanvas;
  84013. private _domImage;
  84014. private _imageWidth;
  84015. private _imageHeight;
  84016. private _loaded;
  84017. private _stretch;
  84018. private _source;
  84019. private _autoScale;
  84020. private _sourceLeft;
  84021. private _sourceTop;
  84022. private _sourceWidth;
  84023. private _sourceHeight;
  84024. private _svgAttributesComputationCompleted;
  84025. private _isSVG;
  84026. private _cellWidth;
  84027. private _cellHeight;
  84028. private _cellId;
  84029. private _populateNinePatchSlicesFromImage;
  84030. private _sliceLeft;
  84031. private _sliceRight;
  84032. private _sliceTop;
  84033. private _sliceBottom;
  84034. private _detectPointerOnOpaqueOnly;
  84035. private _imageDataCache;
  84036. /**
  84037. * BABYLON.Observable notified when the content is loaded
  84038. */
  84039. onImageLoadedObservable: BABYLON.Observable<Image>;
  84040. /**
  84041. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  84042. */
  84043. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  84044. /**
  84045. * Gets a boolean indicating that the content is loaded
  84046. */
  84047. get isLoaded(): boolean;
  84048. /**
  84049. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  84050. */
  84051. get populateNinePatchSlicesFromImage(): boolean;
  84052. set populateNinePatchSlicesFromImage(value: boolean);
  84053. /**
  84054. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  84055. * Beware using this as this will comsume more memory as the image has to be stored twice
  84056. */
  84057. get detectPointerOnOpaqueOnly(): boolean;
  84058. set detectPointerOnOpaqueOnly(value: boolean);
  84059. /**
  84060. * Gets or sets the left value for slicing (9-patch)
  84061. */
  84062. get sliceLeft(): number;
  84063. set sliceLeft(value: number);
  84064. /**
  84065. * Gets or sets the right value for slicing (9-patch)
  84066. */
  84067. get sliceRight(): number;
  84068. set sliceRight(value: number);
  84069. /**
  84070. * Gets or sets the top value for slicing (9-patch)
  84071. */
  84072. get sliceTop(): number;
  84073. set sliceTop(value: number);
  84074. /**
  84075. * Gets or sets the bottom value for slicing (9-patch)
  84076. */
  84077. get sliceBottom(): number;
  84078. set sliceBottom(value: number);
  84079. /**
  84080. * Gets or sets the left coordinate in the source image
  84081. */
  84082. get sourceLeft(): number;
  84083. set sourceLeft(value: number);
  84084. /**
  84085. * Gets or sets the top coordinate in the source image
  84086. */
  84087. get sourceTop(): number;
  84088. set sourceTop(value: number);
  84089. /**
  84090. * Gets or sets the width to capture in the source image
  84091. */
  84092. get sourceWidth(): number;
  84093. set sourceWidth(value: number);
  84094. /**
  84095. * Gets or sets the height to capture in the source image
  84096. */
  84097. get sourceHeight(): number;
  84098. set sourceHeight(value: number);
  84099. /** Indicates if the format of the image is SVG */
  84100. get isSVG(): boolean;
  84101. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  84102. get svgAttributesComputationCompleted(): boolean;
  84103. /**
  84104. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  84105. * @see https://doc.babylonjs.com/how_to/gui#image
  84106. */
  84107. get autoScale(): boolean;
  84108. set autoScale(value: boolean);
  84109. /** Gets or sets the streching mode used by the image */
  84110. get stretch(): number;
  84111. set stretch(value: number);
  84112. /** @hidden */
  84113. _rotate90(n: number, preserveProperties?: boolean): Image;
  84114. private _handleRotationForSVGImage;
  84115. private _rotate90SourceProperties;
  84116. /**
  84117. * Gets or sets the internal DOM image used to render the control
  84118. */
  84119. set domImage(value: HTMLImageElement);
  84120. get domImage(): HTMLImageElement;
  84121. private _onImageLoaded;
  84122. private _extractNinePatchSliceDataFromImage;
  84123. /**
  84124. * Gets the image source url
  84125. */
  84126. get source(): BABYLON.Nullable<string>;
  84127. /**
  84128. * Gets or sets image source url
  84129. */
  84130. set source(value: BABYLON.Nullable<string>);
  84131. /**
  84132. * Checks for svg document with icon id present
  84133. */
  84134. private _svgCheck;
  84135. /**
  84136. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  84137. * given external svg file and icon id
  84138. */
  84139. private _getSVGAttribs;
  84140. /**
  84141. * Gets or sets the cell width to use when animation sheet is enabled
  84142. * @see https://doc.babylonjs.com/how_to/gui#image
  84143. */
  84144. get cellWidth(): number;
  84145. set cellWidth(value: number);
  84146. /**
  84147. * Gets or sets the cell height to use when animation sheet is enabled
  84148. * @see https://doc.babylonjs.com/how_to/gui#image
  84149. */
  84150. get cellHeight(): number;
  84151. set cellHeight(value: number);
  84152. /**
  84153. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  84154. * @see https://doc.babylonjs.com/how_to/gui#image
  84155. */
  84156. get cellId(): number;
  84157. set cellId(value: number);
  84158. /**
  84159. * Creates a new Image
  84160. * @param name defines the control name
  84161. * @param url defines the image url
  84162. */
  84163. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  84164. /**
  84165. * Tests if a given coordinates belong to the current control
  84166. * @param x defines x coordinate to test
  84167. * @param y defines y coordinate to test
  84168. * @returns true if the coordinates are inside the control
  84169. */
  84170. contains(x: number, y: number): boolean;
  84171. protected _getTypeName(): string;
  84172. /** Force the control to synchronize with its content */
  84173. synchronizeSizeWithContent(): void;
  84174. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84175. private _prepareWorkingCanvasForOpaqueDetection;
  84176. private _drawImage;
  84177. _draw(context: CanvasRenderingContext2D): void;
  84178. private _renderCornerPatch;
  84179. private _renderNinePatch;
  84180. dispose(): void;
  84181. /** STRETCH_NONE */
  84182. static readonly STRETCH_NONE: number;
  84183. /** STRETCH_FILL */
  84184. static readonly STRETCH_FILL: number;
  84185. /** STRETCH_UNIFORM */
  84186. static readonly STRETCH_UNIFORM: number;
  84187. /** STRETCH_EXTEND */
  84188. static readonly STRETCH_EXTEND: number;
  84189. /** NINE_PATCH */
  84190. static readonly STRETCH_NINE_PATCH: number;
  84191. }
  84192. }
  84193. declare module BABYLON.GUI {
  84194. /**
  84195. * Class used to create 2D buttons
  84196. */
  84197. export class Button extends Rectangle {
  84198. name?: string | undefined;
  84199. /**
  84200. * Function called to generate a pointer enter animation
  84201. */
  84202. pointerEnterAnimation: () => void;
  84203. /**
  84204. * Function called to generate a pointer out animation
  84205. */
  84206. pointerOutAnimation: () => void;
  84207. /**
  84208. * Function called to generate a pointer down animation
  84209. */
  84210. pointerDownAnimation: () => void;
  84211. /**
  84212. * Function called to generate a pointer up animation
  84213. */
  84214. pointerUpAnimation: () => void;
  84215. /**
  84216. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  84217. */
  84218. delegatePickingToChildren: boolean;
  84219. private _image;
  84220. /**
  84221. * Returns the image part of the button (if any)
  84222. */
  84223. get image(): BABYLON.Nullable<Image>;
  84224. private _textBlock;
  84225. /**
  84226. * Returns the image part of the button (if any)
  84227. */
  84228. get textBlock(): BABYLON.Nullable<TextBlock>;
  84229. /**
  84230. * Creates a new Button
  84231. * @param name defines the name of the button
  84232. */
  84233. constructor(name?: string | undefined);
  84234. protected _getTypeName(): string;
  84235. /** @hidden */
  84236. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84237. /** @hidden */
  84238. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  84239. /** @hidden */
  84240. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  84241. /** @hidden */
  84242. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84243. /** @hidden */
  84244. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84245. /**
  84246. * Creates a new button made with an image and a text
  84247. * @param name defines the name of the button
  84248. * @param text defines the text of the button
  84249. * @param imageUrl defines the url of the image
  84250. * @returns a new Button
  84251. */
  84252. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  84253. /**
  84254. * Creates a new button made with an image
  84255. * @param name defines the name of the button
  84256. * @param imageUrl defines the url of the image
  84257. * @returns a new Button
  84258. */
  84259. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  84260. /**
  84261. * Creates a new button made with a text
  84262. * @param name defines the name of the button
  84263. * @param text defines the text of the button
  84264. * @returns a new Button
  84265. */
  84266. static CreateSimpleButton(name: string, text: string): Button;
  84267. /**
  84268. * Creates a new button made with an image and a centered text
  84269. * @param name defines the name of the button
  84270. * @param text defines the text of the button
  84271. * @param imageUrl defines the url of the image
  84272. * @returns a new Button
  84273. */
  84274. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  84275. }
  84276. }
  84277. declare module BABYLON.GUI {
  84278. /**
  84279. * Class used to create a 2D stack panel container
  84280. */
  84281. export class StackPanel extends Container {
  84282. name?: string | undefined;
  84283. private _isVertical;
  84284. private _manualWidth;
  84285. private _manualHeight;
  84286. private _doNotTrackManualChanges;
  84287. /**
  84288. * Gets or sets a boolean indicating that layou warnings should be ignored
  84289. */
  84290. ignoreLayoutWarnings: boolean;
  84291. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  84292. get isVertical(): boolean;
  84293. set isVertical(value: boolean);
  84294. /**
  84295. * Gets or sets panel width.
  84296. * This value should not be set when in horizontal mode as it will be computed automatically
  84297. */
  84298. set width(value: string | number);
  84299. get width(): string | number;
  84300. /**
  84301. * Gets or sets panel height.
  84302. * This value should not be set when in vertical mode as it will be computed automatically
  84303. */
  84304. set height(value: string | number);
  84305. get height(): string | number;
  84306. /**
  84307. * Creates a new StackPanel
  84308. * @param name defines control name
  84309. */
  84310. constructor(name?: string | undefined);
  84311. protected _getTypeName(): string;
  84312. /** @hidden */
  84313. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84314. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84315. protected _postMeasure(): void;
  84316. /**
  84317. * Serializes the current control
  84318. * @param serializationObject defined the JSON serialized object
  84319. */
  84320. serialize(serializationObject: any): void;
  84321. /** @hidden */
  84322. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84323. }
  84324. }
  84325. declare module BABYLON.GUI {
  84326. /**
  84327. * Class used to represent a 2D checkbox
  84328. */
  84329. export class Checkbox extends Control {
  84330. name?: string | undefined;
  84331. private _isChecked;
  84332. private _background;
  84333. private _checkSizeRatio;
  84334. private _thickness;
  84335. /** Gets or sets border thickness */
  84336. get thickness(): number;
  84337. set thickness(value: number);
  84338. /**
  84339. * BABYLON.Observable raised when isChecked property changes
  84340. */
  84341. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84342. /** Gets or sets a value indicating the ratio between overall size and check size */
  84343. get checkSizeRatio(): number;
  84344. set checkSizeRatio(value: number);
  84345. /** Gets or sets background color */
  84346. get background(): string;
  84347. set background(value: string);
  84348. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84349. get isChecked(): boolean;
  84350. set isChecked(value: boolean);
  84351. /**
  84352. * Creates a new CheckBox
  84353. * @param name defines the control name
  84354. */
  84355. constructor(name?: string | undefined);
  84356. protected _getTypeName(): string;
  84357. /** @hidden */
  84358. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84359. /** @hidden */
  84360. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84361. /**
  84362. * Utility function to easily create a checkbox with a header
  84363. * @param title defines the label to use for the header
  84364. * @param onValueChanged defines the callback to call when value changes
  84365. * @returns a StackPanel containing the checkbox and a textBlock
  84366. */
  84367. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  84368. }
  84369. }
  84370. declare module BABYLON.GUI {
  84371. /**
  84372. * Class used to store key control properties
  84373. */
  84374. export class KeyPropertySet {
  84375. /** Width */
  84376. width?: string;
  84377. /** Height */
  84378. height?: string;
  84379. /** Left padding */
  84380. paddingLeft?: string;
  84381. /** Right padding */
  84382. paddingRight?: string;
  84383. /** Top padding */
  84384. paddingTop?: string;
  84385. /** Bottom padding */
  84386. paddingBottom?: string;
  84387. /** Foreground color */
  84388. color?: string;
  84389. /** Background color */
  84390. background?: string;
  84391. }
  84392. /**
  84393. * Class used to create virtual keyboard
  84394. */
  84395. export class VirtualKeyboard extends StackPanel {
  84396. /** BABYLON.Observable raised when a key is pressed */
  84397. onKeyPressObservable: BABYLON.Observable<string>;
  84398. /** Gets or sets default key button width */
  84399. defaultButtonWidth: string;
  84400. /** Gets or sets default key button height */
  84401. defaultButtonHeight: string;
  84402. /** Gets or sets default key button left padding */
  84403. defaultButtonPaddingLeft: string;
  84404. /** Gets or sets default key button right padding */
  84405. defaultButtonPaddingRight: string;
  84406. /** Gets or sets default key button top padding */
  84407. defaultButtonPaddingTop: string;
  84408. /** Gets or sets default key button bottom padding */
  84409. defaultButtonPaddingBottom: string;
  84410. /** Gets or sets default key button foreground color */
  84411. defaultButtonColor: string;
  84412. /** Gets or sets default key button background color */
  84413. defaultButtonBackground: string;
  84414. /** Gets or sets shift button foreground color */
  84415. shiftButtonColor: string;
  84416. /** Gets or sets shift button thickness*/
  84417. selectedShiftThickness: number;
  84418. /** Gets shift key state */
  84419. shiftState: number;
  84420. protected _getTypeName(): string;
  84421. private _createKey;
  84422. /**
  84423. * Adds a new row of keys
  84424. * @param keys defines the list of keys to add
  84425. * @param propertySets defines the associated property sets
  84426. */
  84427. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  84428. /**
  84429. * Set the shift key to a specific state
  84430. * @param shiftState defines the new shift state
  84431. */
  84432. applyShiftState(shiftState: number): void;
  84433. private _currentlyConnectedInputText;
  84434. private _connectedInputTexts;
  84435. private _onKeyPressObserver;
  84436. /** Gets the input text control currently attached to the keyboard */
  84437. get connectedInputText(): BABYLON.Nullable<InputText>;
  84438. /**
  84439. * Connects the keyboard with an input text control
  84440. *
  84441. * @param input defines the target control
  84442. */
  84443. connect(input: InputText): void;
  84444. /**
  84445. * Disconnects the keyboard from connected InputText controls
  84446. *
  84447. * @param input optionally defines a target control, otherwise all are disconnected
  84448. */
  84449. disconnect(input?: InputText): void;
  84450. private _removeConnectedInputObservables;
  84451. /**
  84452. * Release all resources
  84453. */
  84454. dispose(): void;
  84455. /**
  84456. * Creates a new keyboard using a default layout
  84457. *
  84458. * @param name defines control name
  84459. * @returns a new VirtualKeyboard
  84460. */
  84461. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  84462. }
  84463. }
  84464. declare module BABYLON.GUI {
  84465. /** @hidden */
  84466. export class TextWrapper {
  84467. private _text;
  84468. private _characters;
  84469. get text(): string;
  84470. set text(txt: string);
  84471. get length(): number;
  84472. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  84473. charAt(idx: number): string;
  84474. substr(from: number, length?: number): string;
  84475. substring(from: number, to?: number): string;
  84476. isWord(index: number): boolean;
  84477. }
  84478. }
  84479. declare module BABYLON.GUI {
  84480. /**
  84481. * Class used to create input text control
  84482. */
  84483. export class InputText extends Control implements IFocusableControl {
  84484. name?: string | undefined;
  84485. private _textWrapper;
  84486. private _placeholderText;
  84487. private _background;
  84488. private _focusedBackground;
  84489. private _focusedColor;
  84490. private _placeholderColor;
  84491. private _thickness;
  84492. private _margin;
  84493. private _autoStretchWidth;
  84494. private _maxWidth;
  84495. private _isFocused;
  84496. private _blinkTimeout;
  84497. private _blinkIsEven;
  84498. private _cursorOffset;
  84499. private _scrollLeft;
  84500. private _textWidth;
  84501. private _clickedCoordinate;
  84502. private _deadKey;
  84503. private _addKey;
  84504. private _currentKey;
  84505. private _isTextHighlightOn;
  84506. private _textHighlightColor;
  84507. private _highligherOpacity;
  84508. private _highlightedText;
  84509. private _startHighlightIndex;
  84510. private _endHighlightIndex;
  84511. private _cursorIndex;
  84512. private _onFocusSelectAll;
  84513. private _isPointerDown;
  84514. private _onClipboardObserver;
  84515. private _onPointerDblTapObserver;
  84516. /** @hidden */
  84517. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  84518. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  84519. promptMessage: string;
  84520. /** Force disable prompt on mobile device */
  84521. disableMobilePrompt: boolean;
  84522. /** BABYLON.Observable raised when the text changes */
  84523. onTextChangedObservable: BABYLON.Observable<InputText>;
  84524. /** BABYLON.Observable raised just before an entered character is to be added */
  84525. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  84526. /** BABYLON.Observable raised when the control gets the focus */
  84527. onFocusObservable: BABYLON.Observable<InputText>;
  84528. /** BABYLON.Observable raised when the control loses the focus */
  84529. onBlurObservable: BABYLON.Observable<InputText>;
  84530. /**Observable raised when the text is highlighted */
  84531. onTextHighlightObservable: BABYLON.Observable<InputText>;
  84532. /**Observable raised when copy event is triggered */
  84533. onTextCopyObservable: BABYLON.Observable<InputText>;
  84534. /** BABYLON.Observable raised when cut event is triggered */
  84535. onTextCutObservable: BABYLON.Observable<InputText>;
  84536. /** BABYLON.Observable raised when paste event is triggered */
  84537. onTextPasteObservable: BABYLON.Observable<InputText>;
  84538. /** BABYLON.Observable raised when a key event was processed */
  84539. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84540. /** Gets or sets the maximum width allowed by the control */
  84541. get maxWidth(): string | number;
  84542. /** Gets the maximum width allowed by the control in pixels */
  84543. get maxWidthInPixels(): number;
  84544. set maxWidth(value: string | number);
  84545. /** Gets or sets the text highlighter transparency; default: 0.4 */
  84546. get highligherOpacity(): number;
  84547. set highligherOpacity(value: number);
  84548. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  84549. get onFocusSelectAll(): boolean;
  84550. set onFocusSelectAll(value: boolean);
  84551. /** Gets or sets the text hightlight color */
  84552. get textHighlightColor(): string;
  84553. set textHighlightColor(value: string);
  84554. /** Gets or sets control margin */
  84555. get margin(): string;
  84556. /** Gets control margin in pixels */
  84557. get marginInPixels(): number;
  84558. set margin(value: string);
  84559. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  84560. get autoStretchWidth(): boolean;
  84561. set autoStretchWidth(value: boolean);
  84562. /** Gets or sets border thickness */
  84563. get thickness(): number;
  84564. set thickness(value: number);
  84565. /** Gets or sets the background color when focused */
  84566. get focusedBackground(): string;
  84567. set focusedBackground(value: string);
  84568. /** Gets or sets the background color when focused */
  84569. get focusedColor(): string;
  84570. set focusedColor(value: string);
  84571. /** Gets or sets the background color */
  84572. get background(): string;
  84573. set background(value: string);
  84574. /** Gets or sets the placeholder color */
  84575. get placeholderColor(): string;
  84576. set placeholderColor(value: string);
  84577. /** Gets or sets the text displayed when the control is empty */
  84578. get placeholderText(): string;
  84579. set placeholderText(value: string);
  84580. /** Gets or sets the dead key flag */
  84581. get deadKey(): boolean;
  84582. set deadKey(flag: boolean);
  84583. /** Gets or sets the highlight text */
  84584. get highlightedText(): string;
  84585. set highlightedText(text: string);
  84586. /** Gets or sets if the current key should be added */
  84587. get addKey(): boolean;
  84588. set addKey(flag: boolean);
  84589. /** Gets or sets the value of the current key being entered */
  84590. get currentKey(): string;
  84591. set currentKey(key: string);
  84592. /** Gets or sets the text displayed in the control */
  84593. get text(): string;
  84594. set text(value: string);
  84595. private _textHasChanged;
  84596. /** Gets or sets control width */
  84597. get width(): string | number;
  84598. set width(value: string | number);
  84599. /**
  84600. * Creates a new InputText
  84601. * @param name defines the control name
  84602. * @param text defines the text of the control
  84603. */
  84604. constructor(name?: string | undefined, text?: string);
  84605. /** @hidden */
  84606. onBlur(): void;
  84607. /** @hidden */
  84608. onFocus(): void;
  84609. /**
  84610. * Function to focus an inputText programmatically
  84611. */
  84612. focus(): void;
  84613. /**
  84614. * Function to unfocus an inputText programmatically
  84615. */
  84616. blur(): void;
  84617. protected _getTypeName(): string;
  84618. /**
  84619. * Function called to get the list of controls that should not steal the focus from this control
  84620. * @returns an array of controls
  84621. */
  84622. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84623. /** @hidden */
  84624. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  84625. /** @hidden */
  84626. private _updateValueFromCursorIndex;
  84627. /** @hidden */
  84628. private _processDblClick;
  84629. /** @hidden */
  84630. private _selectAllText;
  84631. /**
  84632. * Handles the keyboard event
  84633. * @param evt Defines the KeyboardEvent
  84634. */
  84635. processKeyboard(evt: KeyboardEvent): void;
  84636. /** @hidden */
  84637. private _onCopyText;
  84638. /** @hidden */
  84639. private _onCutText;
  84640. /** @hidden */
  84641. private _onPasteText;
  84642. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84643. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84644. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84645. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84646. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84647. dispose(): void;
  84648. }
  84649. }
  84650. declare module BABYLON.GUI {
  84651. /**
  84652. * Class used to create a 2D grid container
  84653. */
  84654. export class Grid extends Container {
  84655. name?: string | undefined;
  84656. private _rowDefinitions;
  84657. private _columnDefinitions;
  84658. private _cells;
  84659. private _childControls;
  84660. /**
  84661. * Gets the number of columns
  84662. */
  84663. get columnCount(): number;
  84664. /**
  84665. * Gets the number of rows
  84666. */
  84667. get rowCount(): number;
  84668. /** Gets the list of children */
  84669. get children(): Control[];
  84670. /** Gets the list of cells (e.g. the containers) */
  84671. get cells(): {
  84672. [key: string]: Container;
  84673. };
  84674. /**
  84675. * Gets the definition of a specific row
  84676. * @param index defines the index of the row
  84677. * @returns the row definition
  84678. */
  84679. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84680. /**
  84681. * Gets the definition of a specific column
  84682. * @param index defines the index of the column
  84683. * @returns the column definition
  84684. */
  84685. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84686. /**
  84687. * Adds a new row to the grid
  84688. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84689. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  84690. * @returns the current grid
  84691. */
  84692. addRowDefinition(height: number, isPixel?: boolean): Grid;
  84693. /**
  84694. * Adds a new column to the grid
  84695. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84696. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84697. * @returns the current grid
  84698. */
  84699. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  84700. /**
  84701. * Update a row definition
  84702. * @param index defines the index of the row to update
  84703. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84704. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  84705. * @returns the current grid
  84706. */
  84707. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  84708. /**
  84709. * Update a column definition
  84710. * @param index defines the index of the column to update
  84711. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84712. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84713. * @returns the current grid
  84714. */
  84715. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  84716. /**
  84717. * Gets the list of children stored in a specific cell
  84718. * @param row defines the row to check
  84719. * @param column defines the column to check
  84720. * @returns the list of controls
  84721. */
  84722. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  84723. /**
  84724. * Gets a string representing the child cell info (row x column)
  84725. * @param child defines the control to get info from
  84726. * @returns a string containing the child cell info (row x column)
  84727. */
  84728. getChildCellInfo(child: Control): string;
  84729. private _removeCell;
  84730. private _offsetCell;
  84731. /**
  84732. * Remove a column definition at specified index
  84733. * @param index defines the index of the column to remove
  84734. * @returns the current grid
  84735. */
  84736. removeColumnDefinition(index: number): Grid;
  84737. /**
  84738. * Remove a row definition at specified index
  84739. * @param index defines the index of the row to remove
  84740. * @returns the current grid
  84741. */
  84742. removeRowDefinition(index: number): Grid;
  84743. /**
  84744. * Adds a new control to the current grid
  84745. * @param control defines the control to add
  84746. * @param row defines the row where to add the control (0 by default)
  84747. * @param column defines the column where to add the control (0 by default)
  84748. * @returns the current grid
  84749. */
  84750. addControl(control: Control, row?: number, column?: number): Grid;
  84751. /**
  84752. * Removes a control from the current container
  84753. * @param control defines the control to remove
  84754. * @returns the current container
  84755. */
  84756. removeControl(control: Control): Container;
  84757. /**
  84758. * Creates a new Grid
  84759. * @param name defines control name
  84760. */
  84761. constructor(name?: string | undefined);
  84762. protected _getTypeName(): string;
  84763. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  84764. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84765. _flagDescendantsAsMatrixDirty(): void;
  84766. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84767. /** Releases associated resources */
  84768. dispose(): void;
  84769. }
  84770. }
  84771. declare module BABYLON.GUI {
  84772. /** Class used to create color pickers */
  84773. export class ColorPicker extends Control {
  84774. name?: string | undefined;
  84775. private static _Epsilon;
  84776. private _colorWheelCanvas;
  84777. private _value;
  84778. private _tmpColor;
  84779. private _pointerStartedOnSquare;
  84780. private _pointerStartedOnWheel;
  84781. private _squareLeft;
  84782. private _squareTop;
  84783. private _squareSize;
  84784. private _h;
  84785. private _s;
  84786. private _v;
  84787. private _lastPointerDownID;
  84788. /**
  84789. * BABYLON.Observable raised when the value changes
  84790. */
  84791. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  84792. /** Gets or sets the color of the color picker */
  84793. get value(): BABYLON.Color3;
  84794. set value(value: BABYLON.Color3);
  84795. /**
  84796. * Gets or sets control width
  84797. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84798. */
  84799. get width(): string | number;
  84800. set width(value: string | number);
  84801. /**
  84802. * Gets or sets control height
  84803. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84804. */
  84805. get height(): string | number;
  84806. /** Gets or sets control height */
  84807. set height(value: string | number);
  84808. /** Gets or sets control size */
  84809. get size(): string | number;
  84810. set size(value: string | number);
  84811. /**
  84812. * Creates a new ColorPicker
  84813. * @param name defines the control name
  84814. */
  84815. constructor(name?: string | undefined);
  84816. protected _getTypeName(): string;
  84817. /** @hidden */
  84818. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84819. private _updateSquareProps;
  84820. private _drawGradientSquare;
  84821. private _drawCircle;
  84822. private _createColorWheelCanvas;
  84823. /** @hidden */
  84824. _draw(context: CanvasRenderingContext2D): void;
  84825. private _pointerIsDown;
  84826. private _updateValueFromPointer;
  84827. private _isPointOnSquare;
  84828. private _isPointOnWheel;
  84829. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84830. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84831. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84832. _onCanvasBlur(): void;
  84833. /**
  84834. * This function expands the color picker by creating a color picker dialog with manual
  84835. * color value input and the ability to save colors into an array to be used later in
  84836. * subsequent launches of the dialogue.
  84837. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  84838. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  84839. * @returns picked color as a hex string and the saved colors array as hex strings.
  84840. */
  84841. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  84842. pickerWidth?: string;
  84843. pickerHeight?: string;
  84844. headerHeight?: string;
  84845. lastColor?: string;
  84846. swatchLimit?: number;
  84847. numSwatchesPerLine?: number;
  84848. savedColors?: Array<string>;
  84849. }): Promise<{
  84850. savedColors?: string[];
  84851. pickedColor: string;
  84852. }>;
  84853. }
  84854. }
  84855. declare module BABYLON.GUI {
  84856. /** Class used to create 2D ellipse containers */
  84857. export class Ellipse extends Container {
  84858. name?: string | undefined;
  84859. private _thickness;
  84860. /** Gets or sets border thickness */
  84861. get thickness(): number;
  84862. set thickness(value: number);
  84863. /**
  84864. * Creates a new Ellipse
  84865. * @param name defines the control name
  84866. */
  84867. constructor(name?: string | undefined);
  84868. protected _getTypeName(): string;
  84869. protected _localDraw(context: CanvasRenderingContext2D): void;
  84870. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84871. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84872. }
  84873. }
  84874. declare module BABYLON.GUI {
  84875. /**
  84876. * Class used to create a focusable button that can easily handle keyboard events
  84877. */
  84878. export class FocusableButton extends Button implements IFocusableControl {
  84879. name?: string | undefined;
  84880. /** Highlight color when button is focused */
  84881. focusedColor: BABYLON.Nullable<string>;
  84882. private _isFocused;
  84883. private _unfocusedColor;
  84884. /** BABYLON.Observable raised when the control gets the focus */
  84885. onFocusObservable: BABYLON.Observable<Button>;
  84886. /** BABYLON.Observable raised when the control loses the focus */
  84887. onBlurObservable: BABYLON.Observable<Button>;
  84888. /** BABYLON.Observable raised when a key event was processed */
  84889. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84890. constructor(name?: string | undefined);
  84891. /** @hidden */
  84892. onBlur(): void;
  84893. /** @hidden */
  84894. onFocus(): void;
  84895. /**
  84896. * Function called to get the list of controls that should not steal the focus from this control
  84897. * @returns an array of controls
  84898. */
  84899. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84900. /**
  84901. * Function to focus a button programmatically
  84902. */
  84903. focus(): void;
  84904. /**
  84905. * Function to unfocus a button programmatically
  84906. */
  84907. blur(): void;
  84908. /**
  84909. * Handles the keyboard event
  84910. * @param evt Defines the KeyboardEvent
  84911. */
  84912. processKeyboard(evt: KeyboardEvent): void;
  84913. /** @hidden */
  84914. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84915. /** @hidden */
  84916. displose(): void;
  84917. }
  84918. }
  84919. declare module BABYLON.GUI {
  84920. /**
  84921. * Class used to create a password control
  84922. */
  84923. export class InputPassword extends InputText {
  84924. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84925. }
  84926. }
  84927. declare module BABYLON.GUI {
  84928. /** Class used to render 2D lines */
  84929. export class Line extends Control {
  84930. name?: string | undefined;
  84931. private _lineWidth;
  84932. private _x1;
  84933. private _y1;
  84934. private _x2;
  84935. private _y2;
  84936. private _dash;
  84937. private _connectedControl;
  84938. private _connectedControlDirtyObserver;
  84939. /** Gets or sets the dash pattern */
  84940. get dash(): Array<number>;
  84941. set dash(value: Array<number>);
  84942. /** Gets or sets the control connected with the line end */
  84943. get connectedControl(): Control;
  84944. set connectedControl(value: Control);
  84945. /** Gets or sets start coordinates on X axis */
  84946. get x1(): string | number;
  84947. set x1(value: string | number);
  84948. /** Gets or sets start coordinates on Y axis */
  84949. get y1(): string | number;
  84950. set y1(value: string | number);
  84951. /** Gets or sets end coordinates on X axis */
  84952. get x2(): string | number;
  84953. set x2(value: string | number);
  84954. /** Gets or sets end coordinates on Y axis */
  84955. get y2(): string | number;
  84956. set y2(value: string | number);
  84957. /** Gets or sets line width */
  84958. get lineWidth(): number;
  84959. set lineWidth(value: number);
  84960. /** Gets or sets horizontal alignment */
  84961. set horizontalAlignment(value: number);
  84962. /** Gets or sets vertical alignment */
  84963. set verticalAlignment(value: number);
  84964. private get _effectiveX2();
  84965. private get _effectiveY2();
  84966. /**
  84967. * Creates a new Line
  84968. * @param name defines the control name
  84969. */
  84970. constructor(name?: string | undefined);
  84971. protected _getTypeName(): string;
  84972. _draw(context: CanvasRenderingContext2D): void;
  84973. _measure(): void;
  84974. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84975. /**
  84976. * Move one end of the line given 3D cartesian coordinates.
  84977. * @param position Targeted world position
  84978. * @param scene BABYLON.Scene
  84979. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84980. */
  84981. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  84982. /**
  84983. * Move one end of the line to a position in screen absolute space.
  84984. * @param projectedPosition Position in screen absolute space (X, Y)
  84985. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84986. */
  84987. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  84988. }
  84989. }
  84990. declare module BABYLON.GUI {
  84991. /**
  84992. * Class used to store a point for a MultiLine object.
  84993. * The point can be pure 2D coordinates, a mesh or a control
  84994. */
  84995. export class MultiLinePoint {
  84996. private _multiLine;
  84997. private _x;
  84998. private _y;
  84999. private _control;
  85000. private _mesh;
  85001. private _controlObserver;
  85002. private _meshObserver;
  85003. /** @hidden */
  85004. _point: BABYLON.Vector3;
  85005. /**
  85006. * Creates a new MultiLinePoint
  85007. * @param multiLine defines the source MultiLine object
  85008. */
  85009. constructor(multiLine: MultiLine);
  85010. /** Gets or sets x coordinate */
  85011. get x(): string | number;
  85012. set x(value: string | number);
  85013. /** Gets or sets y coordinate */
  85014. get y(): string | number;
  85015. set y(value: string | number);
  85016. /** Gets or sets the control associated with this point */
  85017. get control(): BABYLON.Nullable<Control>;
  85018. set control(value: BABYLON.Nullable<Control>);
  85019. /** Gets or sets the mesh associated with this point */
  85020. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85021. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  85022. /** Resets links */
  85023. resetLinks(): void;
  85024. /**
  85025. * Gets a translation vector with Z component
  85026. * @returns the translation vector
  85027. */
  85028. translate(): BABYLON.Vector3;
  85029. private _translatePoint;
  85030. /** Release associated resources */
  85031. dispose(): void;
  85032. }
  85033. }
  85034. declare module BABYLON.GUI {
  85035. /**
  85036. * Class used to create multi line control
  85037. */
  85038. export class MultiLine extends Control {
  85039. name?: string | undefined;
  85040. private _lineWidth;
  85041. private _dash;
  85042. private _points;
  85043. private _minX;
  85044. private _minY;
  85045. private _maxX;
  85046. private _maxY;
  85047. /**
  85048. * Creates a new MultiLine
  85049. * @param name defines the control name
  85050. */
  85051. constructor(name?: string | undefined);
  85052. /** Gets or sets dash pattern */
  85053. get dash(): Array<number>;
  85054. set dash(value: Array<number>);
  85055. /**
  85056. * Gets point stored at specified index
  85057. * @param index defines the index to look for
  85058. * @returns the requested point if found
  85059. */
  85060. getAt(index: number): MultiLinePoint;
  85061. /** Function called when a point is updated */
  85062. onPointUpdate: () => void;
  85063. /**
  85064. * Adds new points to the point collection
  85065. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  85066. * @returns the list of created MultiLinePoint
  85067. */
  85068. add(...items: (AbstractMesh | Control | {
  85069. x: string | number;
  85070. y: string | number;
  85071. })[]): MultiLinePoint[];
  85072. /**
  85073. * Adds a new point to the point collection
  85074. * @param item defines the item (mesh, control or 2d coordiantes) to add
  85075. * @returns the created MultiLinePoint
  85076. */
  85077. push(item?: (AbstractMesh | Control | {
  85078. x: string | number;
  85079. y: string | number;
  85080. })): MultiLinePoint;
  85081. /**
  85082. * Remove a specific value or point from the active point collection
  85083. * @param value defines the value or point to remove
  85084. */
  85085. remove(value: number | MultiLinePoint): void;
  85086. /**
  85087. * Resets this object to initial state (no point)
  85088. */
  85089. reset(): void;
  85090. /**
  85091. * Resets all links
  85092. */
  85093. resetLinks(): void;
  85094. /** Gets or sets line width */
  85095. get lineWidth(): number;
  85096. set lineWidth(value: number);
  85097. set horizontalAlignment(value: number);
  85098. set verticalAlignment(value: number);
  85099. protected _getTypeName(): string;
  85100. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85101. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85102. _measure(): void;
  85103. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85104. dispose(): void;
  85105. }
  85106. }
  85107. declare module BABYLON.GUI {
  85108. /**
  85109. * Class used to create radio button controls
  85110. */
  85111. export class RadioButton extends Control {
  85112. name?: string | undefined;
  85113. private _isChecked;
  85114. private _background;
  85115. private _checkSizeRatio;
  85116. private _thickness;
  85117. /** Gets or sets border thickness */
  85118. get thickness(): number;
  85119. set thickness(value: number);
  85120. /** Gets or sets group name */
  85121. group: string;
  85122. /** BABYLON.Observable raised when isChecked is changed */
  85123. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  85124. /** Gets or sets a value indicating the ratio between overall size and check size */
  85125. get checkSizeRatio(): number;
  85126. set checkSizeRatio(value: number);
  85127. /** Gets or sets background color */
  85128. get background(): string;
  85129. set background(value: string);
  85130. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  85131. get isChecked(): boolean;
  85132. set isChecked(value: boolean);
  85133. /**
  85134. * Creates a new RadioButton
  85135. * @param name defines the control name
  85136. */
  85137. constructor(name?: string | undefined);
  85138. protected _getTypeName(): string;
  85139. _draw(context: CanvasRenderingContext2D): void;
  85140. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85141. /**
  85142. * Utility function to easily create a radio button with a header
  85143. * @param title defines the label to use for the header
  85144. * @param group defines the group to use for the radio button
  85145. * @param isChecked defines the initial state of the radio button
  85146. * @param onValueChanged defines the callback to call when value changes
  85147. * @returns a StackPanel containing the radio button and a textBlock
  85148. */
  85149. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  85150. }
  85151. }
  85152. declare module BABYLON.GUI {
  85153. /**
  85154. * Class used to create slider controls
  85155. */
  85156. export class BaseSlider extends Control {
  85157. name?: string | undefined;
  85158. protected _thumbWidth: ValueAndUnit;
  85159. private _minimum;
  85160. private _maximum;
  85161. private _value;
  85162. private _isVertical;
  85163. protected _barOffset: ValueAndUnit;
  85164. private _isThumbClamped;
  85165. protected _displayThumb: boolean;
  85166. private _step;
  85167. private _lastPointerDownID;
  85168. protected _effectiveBarOffset: number;
  85169. protected _renderLeft: number;
  85170. protected _renderTop: number;
  85171. protected _renderWidth: number;
  85172. protected _renderHeight: number;
  85173. protected _backgroundBoxLength: number;
  85174. protected _backgroundBoxThickness: number;
  85175. protected _effectiveThumbThickness: number;
  85176. /** BABYLON.Observable raised when the sldier value changes */
  85177. onValueChangedObservable: BABYLON.Observable<number>;
  85178. /** Gets or sets a boolean indicating if the thumb must be rendered */
  85179. get displayThumb(): boolean;
  85180. set displayThumb(value: boolean);
  85181. /** Gets or sets a step to apply to values (0 by default) */
  85182. get step(): number;
  85183. set step(value: number);
  85184. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  85185. get barOffset(): string | number;
  85186. /** Gets main bar offset in pixels*/
  85187. get barOffsetInPixels(): number;
  85188. set barOffset(value: string | number);
  85189. /** Gets or sets thumb width */
  85190. get thumbWidth(): string | number;
  85191. /** Gets thumb width in pixels */
  85192. get thumbWidthInPixels(): number;
  85193. set thumbWidth(value: string | number);
  85194. /** Gets or sets minimum value */
  85195. get minimum(): number;
  85196. set minimum(value: number);
  85197. /** Gets or sets maximum value */
  85198. get maximum(): number;
  85199. set maximum(value: number);
  85200. /** Gets or sets current value */
  85201. get value(): number;
  85202. set value(value: number);
  85203. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  85204. get isVertical(): boolean;
  85205. set isVertical(value: boolean);
  85206. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  85207. get isThumbClamped(): boolean;
  85208. set isThumbClamped(value: boolean);
  85209. /**
  85210. * Creates a new BaseSlider
  85211. * @param name defines the control name
  85212. */
  85213. constructor(name?: string | undefined);
  85214. protected _getTypeName(): string;
  85215. protected _getThumbPosition(): number;
  85216. protected _getThumbThickness(type: string): number;
  85217. protected _prepareRenderingData(type: string): void;
  85218. private _pointerIsDown;
  85219. /** @hidden */
  85220. protected _updateValueFromPointer(x: number, y: number): void;
  85221. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85222. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85223. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85224. _onCanvasBlur(): void;
  85225. }
  85226. }
  85227. declare module BABYLON.GUI {
  85228. /**
  85229. * Class used to create slider controls
  85230. */
  85231. export class Slider extends BaseSlider {
  85232. name?: string | undefined;
  85233. private _background;
  85234. private _borderColor;
  85235. private _thumbColor;
  85236. private _isThumbCircle;
  85237. protected _displayValueBar: boolean;
  85238. /** Gets or sets a boolean indicating if the value bar must be rendered */
  85239. get displayValueBar(): boolean;
  85240. set displayValueBar(value: boolean);
  85241. /** Gets or sets border color */
  85242. get borderColor(): string;
  85243. set borderColor(value: string);
  85244. /** Gets or sets background color */
  85245. get background(): string;
  85246. set background(value: string);
  85247. /** Gets or sets thumb's color */
  85248. get thumbColor(): string;
  85249. set thumbColor(value: string);
  85250. /** Gets or sets a boolean indicating if the thumb should be round or square */
  85251. get isThumbCircle(): boolean;
  85252. set isThumbCircle(value: boolean);
  85253. /**
  85254. * Creates a new Slider
  85255. * @param name defines the control name
  85256. */
  85257. constructor(name?: string | undefined);
  85258. protected _getTypeName(): string;
  85259. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85260. }
  85261. }
  85262. declare module BABYLON.GUI {
  85263. /** Class used to create a RadioGroup
  85264. * which contains groups of radio buttons
  85265. */
  85266. export class SelectorGroup {
  85267. /** name of SelectorGroup */
  85268. name: string;
  85269. private _groupPanel;
  85270. private _selectors;
  85271. private _groupHeader;
  85272. /**
  85273. * Creates a new SelectorGroup
  85274. * @param name of group, used as a group heading
  85275. */
  85276. constructor(
  85277. /** name of SelectorGroup */
  85278. name: string);
  85279. /** Gets the groupPanel of the SelectorGroup */
  85280. get groupPanel(): StackPanel;
  85281. /** Gets the selectors array */
  85282. get selectors(): StackPanel[];
  85283. /** Gets and sets the group header */
  85284. get header(): string;
  85285. set header(label: string);
  85286. /** @hidden */
  85287. private _addGroupHeader;
  85288. /** @hidden*/
  85289. _getSelector(selectorNb: number): StackPanel | undefined;
  85290. /** Removes the selector at the given position
  85291. * @param selectorNb the position of the selector within the group
  85292. */
  85293. removeSelector(selectorNb: number): void;
  85294. }
  85295. /** Class used to create a CheckboxGroup
  85296. * which contains groups of checkbox buttons
  85297. */
  85298. export class CheckboxGroup extends SelectorGroup {
  85299. /** Adds a checkbox as a control
  85300. * @param text is the label for the selector
  85301. * @param func is the function called when the Selector is checked
  85302. * @param checked is true when Selector is checked
  85303. */
  85304. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  85305. /** @hidden */
  85306. _setSelectorLabel(selectorNb: number, label: string): void;
  85307. /** @hidden */
  85308. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85309. /** @hidden */
  85310. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85311. /** @hidden */
  85312. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85313. }
  85314. /** Class used to create a RadioGroup
  85315. * which contains groups of radio buttons
  85316. */
  85317. export class RadioGroup extends SelectorGroup {
  85318. private _selectNb;
  85319. /** Adds a radio button as a control
  85320. * @param label is the label for the selector
  85321. * @param func is the function called when the Selector is checked
  85322. * @param checked is true when Selector is checked
  85323. */
  85324. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  85325. /** @hidden */
  85326. _setSelectorLabel(selectorNb: number, label: string): void;
  85327. /** @hidden */
  85328. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85329. /** @hidden */
  85330. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85331. /** @hidden */
  85332. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85333. }
  85334. /** Class used to create a SliderGroup
  85335. * which contains groups of slider buttons
  85336. */
  85337. export class SliderGroup extends SelectorGroup {
  85338. /**
  85339. * Adds a slider to the SelectorGroup
  85340. * @param label is the label for the SliderBar
  85341. * @param func is the function called when the Slider moves
  85342. * @param unit is a string describing the units used, eg degrees or metres
  85343. * @param min is the minimum value for the Slider
  85344. * @param max is the maximum value for the Slider
  85345. * @param value is the start value for the Slider between min and max
  85346. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  85347. */
  85348. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  85349. /** @hidden */
  85350. _setSelectorLabel(selectorNb: number, label: string): void;
  85351. /** @hidden */
  85352. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85353. /** @hidden */
  85354. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85355. /** @hidden */
  85356. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85357. }
  85358. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  85359. * @see https://doc.babylonjs.com/how_to/selector
  85360. */
  85361. export class SelectionPanel extends Rectangle {
  85362. /** name of SelectionPanel */
  85363. name: string;
  85364. /** an array of SelectionGroups */
  85365. groups: SelectorGroup[];
  85366. private _panel;
  85367. private _buttonColor;
  85368. private _buttonBackground;
  85369. private _headerColor;
  85370. private _barColor;
  85371. private _barHeight;
  85372. private _spacerHeight;
  85373. private _labelColor;
  85374. private _groups;
  85375. private _bars;
  85376. /**
  85377. * Creates a new SelectionPanel
  85378. * @param name of SelectionPanel
  85379. * @param groups is an array of SelectionGroups
  85380. */
  85381. constructor(
  85382. /** name of SelectionPanel */
  85383. name: string,
  85384. /** an array of SelectionGroups */
  85385. groups?: SelectorGroup[]);
  85386. protected _getTypeName(): string;
  85387. /** Gets the (stack) panel of the SelectionPanel */
  85388. get panel(): StackPanel;
  85389. /** Gets or sets the headerColor */
  85390. get headerColor(): string;
  85391. set headerColor(color: string);
  85392. private _setHeaderColor;
  85393. /** Gets or sets the button color */
  85394. get buttonColor(): string;
  85395. set buttonColor(color: string);
  85396. private _setbuttonColor;
  85397. /** Gets or sets the label color */
  85398. get labelColor(): string;
  85399. set labelColor(color: string);
  85400. private _setLabelColor;
  85401. /** Gets or sets the button background */
  85402. get buttonBackground(): string;
  85403. set buttonBackground(color: string);
  85404. private _setButtonBackground;
  85405. /** Gets or sets the color of separator bar */
  85406. get barColor(): string;
  85407. set barColor(color: string);
  85408. private _setBarColor;
  85409. /** Gets or sets the height of separator bar */
  85410. get barHeight(): string;
  85411. set barHeight(value: string);
  85412. private _setBarHeight;
  85413. /** Gets or sets the height of spacers*/
  85414. get spacerHeight(): string;
  85415. set spacerHeight(value: string);
  85416. private _setSpacerHeight;
  85417. /** Adds a bar between groups */
  85418. private _addSpacer;
  85419. /** Add a group to the selection panel
  85420. * @param group is the selector group to add
  85421. */
  85422. addGroup(group: SelectorGroup): void;
  85423. /** Remove the group from the given position
  85424. * @param groupNb is the position of the group in the list
  85425. */
  85426. removeGroup(groupNb: number): void;
  85427. /** Change a group header label
  85428. * @param label is the new group header label
  85429. * @param groupNb is the number of the group to relabel
  85430. * */
  85431. setHeaderName(label: string, groupNb: number): void;
  85432. /** Change selector label to the one given
  85433. * @param label is the new selector label
  85434. * @param groupNb is the number of the groupcontaining the selector
  85435. * @param selectorNb is the number of the selector within a group to relabel
  85436. * */
  85437. relabel(label: string, groupNb: number, selectorNb: number): void;
  85438. /** For a given group position remove the selector at the given position
  85439. * @param groupNb is the number of the group to remove the selector from
  85440. * @param selectorNb is the number of the selector within the group
  85441. */
  85442. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  85443. /** For a given group position of correct type add a checkbox button
  85444. * @param groupNb is the number of the group to remove the selector from
  85445. * @param label is the label for the selector
  85446. * @param func is the function called when the Selector is checked
  85447. * @param checked is true when Selector is checked
  85448. */
  85449. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85450. /** For a given group position of correct type add a radio button
  85451. * @param groupNb is the number of the group to remove the selector from
  85452. * @param label is the label for the selector
  85453. * @param func is the function called when the Selector is checked
  85454. * @param checked is true when Selector is checked
  85455. */
  85456. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85457. /**
  85458. * For a given slider group add a slider
  85459. * @param groupNb is the number of the group to add the slider to
  85460. * @param label is the label for the Slider
  85461. * @param func is the function called when the Slider moves
  85462. * @param unit is a string describing the units used, eg degrees or metres
  85463. * @param min is the minimum value for the Slider
  85464. * @param max is the maximum value for the Slider
  85465. * @param value is the start value for the Slider between min and max
  85466. * @param onVal is the function used to format the value displayed, eg radians to degrees
  85467. */
  85468. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  85469. }
  85470. }
  85471. declare module BABYLON.GUI {
  85472. /**
  85473. * Class used to hold a the container for ScrollViewer
  85474. * @hidden
  85475. */
  85476. export class _ScrollViewerWindow extends Container {
  85477. parentClientWidth: number;
  85478. parentClientHeight: number;
  85479. private _freezeControls;
  85480. private _parentMeasure;
  85481. private _oldLeft;
  85482. private _oldTop;
  85483. get freezeControls(): boolean;
  85484. set freezeControls(value: boolean);
  85485. private _bucketWidth;
  85486. private _bucketHeight;
  85487. private _buckets;
  85488. private _bucketLen;
  85489. get bucketWidth(): number;
  85490. get bucketHeight(): number;
  85491. setBucketSizes(width: number, height: number): void;
  85492. private _useBuckets;
  85493. private _makeBuckets;
  85494. private _dispatchInBuckets;
  85495. private _updateMeasures;
  85496. private _updateChildrenMeasures;
  85497. private _restoreMeasures;
  85498. /**
  85499. * Creates a new ScrollViewerWindow
  85500. * @param name of ScrollViewerWindow
  85501. */
  85502. constructor(name?: string);
  85503. protected _getTypeName(): string;
  85504. /** @hidden */
  85505. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85506. /** @hidden */
  85507. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  85508. private _scrollChildren;
  85509. private _scrollChildrenWithBuckets;
  85510. /** @hidden */
  85511. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  85512. protected _postMeasure(): void;
  85513. }
  85514. }
  85515. declare module BABYLON.GUI {
  85516. /**
  85517. * Class used to create slider controls
  85518. */
  85519. export class ScrollBar extends BaseSlider {
  85520. name?: string | undefined;
  85521. private _background;
  85522. private _borderColor;
  85523. private _tempMeasure;
  85524. /** Gets or sets border color */
  85525. get borderColor(): string;
  85526. set borderColor(value: string);
  85527. /** Gets or sets background color */
  85528. get background(): string;
  85529. set background(value: string);
  85530. /**
  85531. * Creates a new Slider
  85532. * @param name defines the control name
  85533. */
  85534. constructor(name?: string | undefined);
  85535. protected _getTypeName(): string;
  85536. protected _getThumbThickness(): number;
  85537. _draw(context: CanvasRenderingContext2D): void;
  85538. private _first;
  85539. private _originX;
  85540. private _originY;
  85541. /** @hidden */
  85542. protected _updateValueFromPointer(x: number, y: number): void;
  85543. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85544. }
  85545. }
  85546. declare module BABYLON.GUI {
  85547. /**
  85548. * Class used to create slider controls
  85549. */
  85550. export class ImageScrollBar extends BaseSlider {
  85551. name?: string | undefined;
  85552. private _backgroundBaseImage;
  85553. private _backgroundImage;
  85554. private _thumbImage;
  85555. private _thumbBaseImage;
  85556. private _thumbLength;
  85557. private _thumbHeight;
  85558. private _barImageHeight;
  85559. private _tempMeasure;
  85560. /** Number of 90° rotation to apply on the images when in vertical mode */
  85561. num90RotationInVerticalMode: number;
  85562. /**
  85563. * Gets or sets the image used to render the background for horizontal bar
  85564. */
  85565. get backgroundImage(): Image;
  85566. set backgroundImage(value: Image);
  85567. /**
  85568. * Gets or sets the image used to render the thumb
  85569. */
  85570. get thumbImage(): Image;
  85571. set thumbImage(value: Image);
  85572. /**
  85573. * Gets or sets the length of the thumb
  85574. */
  85575. get thumbLength(): number;
  85576. set thumbLength(value: number);
  85577. /**
  85578. * Gets or sets the height of the thumb
  85579. */
  85580. get thumbHeight(): number;
  85581. set thumbHeight(value: number);
  85582. /**
  85583. * Gets or sets the height of the bar image
  85584. */
  85585. get barImageHeight(): number;
  85586. set barImageHeight(value: number);
  85587. /**
  85588. * Creates a new ImageScrollBar
  85589. * @param name defines the control name
  85590. */
  85591. constructor(name?: string | undefined);
  85592. protected _getTypeName(): string;
  85593. protected _getThumbThickness(): number;
  85594. _draw(context: CanvasRenderingContext2D): void;
  85595. private _first;
  85596. private _originX;
  85597. private _originY;
  85598. /** @hidden */
  85599. protected _updateValueFromPointer(x: number, y: number): void;
  85600. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85601. }
  85602. }
  85603. declare module BABYLON.GUI {
  85604. /**
  85605. * Class used to hold a viewer window and sliders in a grid
  85606. */
  85607. export class ScrollViewer extends Rectangle {
  85608. private _grid;
  85609. private _horizontalBarSpace;
  85610. private _verticalBarSpace;
  85611. private _dragSpace;
  85612. private _horizontalBar;
  85613. private _verticalBar;
  85614. private _barColor;
  85615. private _barBackground;
  85616. private _barImage;
  85617. private _horizontalBarImage;
  85618. private _verticalBarImage;
  85619. private _barBackgroundImage;
  85620. private _horizontalBarBackgroundImage;
  85621. private _verticalBarBackgroundImage;
  85622. private _barSize;
  85623. private _window;
  85624. private _pointerIsOver;
  85625. private _wheelPrecision;
  85626. private _onWheelObserver;
  85627. private _clientWidth;
  85628. private _clientHeight;
  85629. private _useImageBar;
  85630. private _thumbLength;
  85631. private _thumbHeight;
  85632. private _barImageHeight;
  85633. private _horizontalBarImageHeight;
  85634. private _verticalBarImageHeight;
  85635. private _oldWindowContentsWidth;
  85636. private _oldWindowContentsHeight;
  85637. /**
  85638. * Gets the horizontal scrollbar
  85639. */
  85640. get horizontalBar(): ScrollBar | ImageScrollBar;
  85641. /**
  85642. * Gets the vertical scrollbar
  85643. */
  85644. get verticalBar(): ScrollBar | ImageScrollBar;
  85645. /**
  85646. * Adds a new control to the current container
  85647. * @param control defines the control to add
  85648. * @returns the current container
  85649. */
  85650. addControl(control: BABYLON.Nullable<Control>): Container;
  85651. /**
  85652. * Removes a control from the current container
  85653. * @param control defines the control to remove
  85654. * @returns the current container
  85655. */
  85656. removeControl(control: Control): Container;
  85657. /** Gets the list of children */
  85658. get children(): Control[];
  85659. _flagDescendantsAsMatrixDirty(): void;
  85660. /**
  85661. * Freezes or unfreezes the controls in the window.
  85662. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  85663. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  85664. */
  85665. get freezeControls(): boolean;
  85666. set freezeControls(value: boolean);
  85667. /** Gets the bucket width */
  85668. get bucketWidth(): number;
  85669. /** Gets the bucket height */
  85670. get bucketHeight(): number;
  85671. /**
  85672. * Sets the bucket sizes.
  85673. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  85674. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  85675. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  85676. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  85677. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  85678. * used), that's why it is not enabled by default.
  85679. * @param width width of the bucket
  85680. * @param height height of the bucket
  85681. */
  85682. setBucketSizes(width: number, height: number): void;
  85683. private _forceHorizontalBar;
  85684. private _forceVerticalBar;
  85685. /**
  85686. * Forces the horizontal scroll bar to be displayed
  85687. */
  85688. get forceHorizontalBar(): boolean;
  85689. set forceHorizontalBar(value: boolean);
  85690. /**
  85691. * Forces the vertical scroll bar to be displayed
  85692. */
  85693. get forceVerticalBar(): boolean;
  85694. set forceVerticalBar(value: boolean);
  85695. /**
  85696. * Creates a new ScrollViewer
  85697. * @param name of ScrollViewer
  85698. */
  85699. constructor(name?: string, isImageBased?: boolean);
  85700. /** Reset the scroll viewer window to initial size */
  85701. resetWindow(): void;
  85702. protected _getTypeName(): string;
  85703. private _buildClientSizes;
  85704. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85705. protected _postMeasure(): void;
  85706. /**
  85707. * Gets or sets the mouse wheel precision
  85708. * from 0 to 1 with a default value of 0.05
  85709. * */
  85710. get wheelPrecision(): number;
  85711. set wheelPrecision(value: number);
  85712. /** Gets or sets the scroll bar container background color */
  85713. get scrollBackground(): string;
  85714. set scrollBackground(color: string);
  85715. /** Gets or sets the bar color */
  85716. get barColor(): string;
  85717. set barColor(color: string);
  85718. /** Gets or sets the bar image */
  85719. get thumbImage(): Image;
  85720. set thumbImage(value: Image);
  85721. /** Gets or sets the horizontal bar image */
  85722. get horizontalThumbImage(): Image;
  85723. set horizontalThumbImage(value: Image);
  85724. /** Gets or sets the vertical bar image */
  85725. get verticalThumbImage(): Image;
  85726. set verticalThumbImage(value: Image);
  85727. /** Gets or sets the size of the bar */
  85728. get barSize(): number;
  85729. set barSize(value: number);
  85730. /** Gets or sets the length of the thumb */
  85731. get thumbLength(): number;
  85732. set thumbLength(value: number);
  85733. /** Gets or sets the height of the thumb */
  85734. get thumbHeight(): number;
  85735. set thumbHeight(value: number);
  85736. /** Gets or sets the height of the bar image */
  85737. get barImageHeight(): number;
  85738. set barImageHeight(value: number);
  85739. /** Gets or sets the height of the horizontal bar image */
  85740. get horizontalBarImageHeight(): number;
  85741. set horizontalBarImageHeight(value: number);
  85742. /** Gets or sets the height of the vertical bar image */
  85743. get verticalBarImageHeight(): number;
  85744. set verticalBarImageHeight(value: number);
  85745. /** Gets or sets the bar background */
  85746. get barBackground(): string;
  85747. set barBackground(color: string);
  85748. /** Gets or sets the bar background image */
  85749. get barImage(): Image;
  85750. set barImage(value: Image);
  85751. /** Gets or sets the horizontal bar background image */
  85752. get horizontalBarImage(): Image;
  85753. set horizontalBarImage(value: Image);
  85754. /** Gets or sets the vertical bar background image */
  85755. get verticalBarImage(): Image;
  85756. set verticalBarImage(value: Image);
  85757. private _setWindowPosition;
  85758. /** @hidden */
  85759. private _updateScroller;
  85760. _link(host: AdvancedDynamicTexture): void;
  85761. /** @hidden */
  85762. private _addBar;
  85763. /** @hidden */
  85764. private _attachWheel;
  85765. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85766. /** Releases associated resources */
  85767. dispose(): void;
  85768. }
  85769. }
  85770. declare module BABYLON.GUI {
  85771. /**
  85772. * Class used to create toggle buttons
  85773. */
  85774. export class ToggleButton extends Rectangle {
  85775. name?: string | undefined;
  85776. /**
  85777. * Function called to generate the toActive animation
  85778. */
  85779. toActiveAnimation: () => void;
  85780. /**
  85781. * Function called to generate the toInactive animation
  85782. */
  85783. toInactiveAnimation: () => void;
  85784. /**
  85785. * Function called to generate a pointer enter animation when the toggle button is active.
  85786. */
  85787. pointerEnterActiveAnimation: () => void;
  85788. /**
  85789. * Function called to generate a pointer out animation when the toggle button is active.
  85790. */
  85791. pointerOutActiveAnimation: () => void;
  85792. /**
  85793. * Function called to generate a pointer down animation when the toggle button is active.
  85794. */
  85795. pointerDownActiveAnimation: () => void;
  85796. /**
  85797. * Function called to generate a pointer up animation when the toggle button is active.
  85798. */
  85799. pointerUpActiveAnimation: () => void;
  85800. /**
  85801. * Function called to generate a pointer enter animation when the toggle button is inactive.
  85802. */
  85803. pointerEnterInactiveAnimation: () => void;
  85804. /**
  85805. * Function called to generate a pointer out animation when the toggle button is inactive.
  85806. */
  85807. pointerOutInactiveAnimation: () => void;
  85808. /**
  85809. * Function called to generate a pointer down animation when the toggle button is inactive.
  85810. */
  85811. pointerDownInactiveAnimation: () => void;
  85812. /**
  85813. * Function called to generate a pointer up animation when the toggle button is inactive.
  85814. */
  85815. pointerUpInactiveAnimation: () => void;
  85816. /** BABYLON.Observable raised when isActive is changed */
  85817. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  85818. /**
  85819. * Gets or sets a boolean indicating that the toggle button will let internal controls handle picking instead of doing it directly using its bounding info
  85820. */
  85821. delegatePickingToChildren: boolean;
  85822. private _image;
  85823. /**
  85824. * Returns the ToggleButton's image control if it exists
  85825. */
  85826. get image(): BABYLON.Nullable<Image>;
  85827. private _textBlock;
  85828. /**
  85829. * Returns the ToggleButton's child TextBlock control if it exists
  85830. */
  85831. get textBlock(): BABYLON.Nullable<TextBlock>;
  85832. private _group;
  85833. /** Gets or sets group name this toggle button belongs to */
  85834. get group(): string;
  85835. set group(value: string);
  85836. private _isActive;
  85837. /** Gets or sets a boolean indicating if the toogle button is active or not */
  85838. get isActive(): boolean;
  85839. set isActive(value: boolean);
  85840. /**
  85841. * Creates a new ToggleButton
  85842. * @param name defines the control name
  85843. * @param group defines the toggle group this toggle belongs to
  85844. */
  85845. constructor(name?: string | undefined, group?: string);
  85846. protected _getTypeName(): string;
  85847. /** @hidden */
  85848. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  85849. /** @hidden */
  85850. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  85851. /** @hidden */
  85852. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  85853. /** @hidden */
  85854. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85855. /** @hidden */
  85856. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85857. }
  85858. }
  85859. declare module BABYLON.GUI {
  85860. /** Class used to render a grid */
  85861. export class DisplayGrid extends Control {
  85862. name?: string | undefined;
  85863. private _cellWidth;
  85864. private _cellHeight;
  85865. private _minorLineTickness;
  85866. private _minorLineColor;
  85867. private _majorLineTickness;
  85868. private _majorLineColor;
  85869. private _majorLineFrequency;
  85870. private _background;
  85871. private _displayMajorLines;
  85872. private _displayMinorLines;
  85873. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  85874. get displayMinorLines(): boolean;
  85875. set displayMinorLines(value: boolean);
  85876. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  85877. get displayMajorLines(): boolean;
  85878. set displayMajorLines(value: boolean);
  85879. /** Gets or sets background color (Black by default) */
  85880. get background(): string;
  85881. set background(value: string);
  85882. /** Gets or sets the width of each cell (20 by default) */
  85883. get cellWidth(): number;
  85884. set cellWidth(value: number);
  85885. /** Gets or sets the height of each cell (20 by default) */
  85886. get cellHeight(): number;
  85887. set cellHeight(value: number);
  85888. /** Gets or sets the tickness of minor lines (1 by default) */
  85889. get minorLineTickness(): number;
  85890. set minorLineTickness(value: number);
  85891. /** Gets or sets the color of minor lines (DarkGray by default) */
  85892. get minorLineColor(): string;
  85893. set minorLineColor(value: string);
  85894. /** Gets or sets the tickness of major lines (2 by default) */
  85895. get majorLineTickness(): number;
  85896. set majorLineTickness(value: number);
  85897. /** Gets or sets the color of major lines (White by default) */
  85898. get majorLineColor(): string;
  85899. set majorLineColor(value: string);
  85900. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  85901. get majorLineFrequency(): number;
  85902. set majorLineFrequency(value: number);
  85903. /**
  85904. * Creates a new GridDisplayRectangle
  85905. * @param name defines the control name
  85906. */
  85907. constructor(name?: string | undefined);
  85908. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85909. protected _getTypeName(): string;
  85910. }
  85911. }
  85912. declare module BABYLON.GUI {
  85913. /**
  85914. * Class used to create slider controls based on images
  85915. */
  85916. export class ImageBasedSlider extends BaseSlider {
  85917. name?: string | undefined;
  85918. private _backgroundImage;
  85919. private _thumbImage;
  85920. private _valueBarImage;
  85921. private _tempMeasure;
  85922. get displayThumb(): boolean;
  85923. set displayThumb(value: boolean);
  85924. /**
  85925. * Gets or sets the image used to render the background
  85926. */
  85927. get backgroundImage(): Image;
  85928. set backgroundImage(value: Image);
  85929. /**
  85930. * Gets or sets the image used to render the value bar
  85931. */
  85932. get valueBarImage(): Image;
  85933. set valueBarImage(value: Image);
  85934. /**
  85935. * Gets or sets the image used to render the thumb
  85936. */
  85937. get thumbImage(): Image;
  85938. set thumbImage(value: Image);
  85939. /**
  85940. * Creates a new ImageBasedSlider
  85941. * @param name defines the control name
  85942. */
  85943. constructor(name?: string | undefined);
  85944. protected _getTypeName(): string;
  85945. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85946. }
  85947. }
  85948. declare module BABYLON.GUI {
  85949. /**
  85950. * Forcing an export so that this code will execute
  85951. * @hidden
  85952. */
  85953. const name = "Statics";
  85954. }
  85955. declare module BABYLON.GUI {
  85956. /**
  85957. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  85958. */
  85959. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  85960. /**
  85961. * Define the instrumented AdvancedDynamicTexture.
  85962. */
  85963. texture: AdvancedDynamicTexture;
  85964. private _captureRenderTime;
  85965. private _renderTime;
  85966. private _captureLayoutTime;
  85967. private _layoutTime;
  85968. private _onBeginRenderObserver;
  85969. private _onEndRenderObserver;
  85970. private _onBeginLayoutObserver;
  85971. private _onEndLayoutObserver;
  85972. /**
  85973. * Gets the perf counter used to capture render time
  85974. */
  85975. get renderTimeCounter(): BABYLON.PerfCounter;
  85976. /**
  85977. * Gets the perf counter used to capture layout time
  85978. */
  85979. get layoutTimeCounter(): BABYLON.PerfCounter;
  85980. /**
  85981. * Enable or disable the render time capture
  85982. */
  85983. get captureRenderTime(): boolean;
  85984. set captureRenderTime(value: boolean);
  85985. /**
  85986. * Enable or disable the layout time capture
  85987. */
  85988. get captureLayoutTime(): boolean;
  85989. set captureLayoutTime(value: boolean);
  85990. /**
  85991. * Instantiates a new advanced dynamic texture instrumentation.
  85992. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  85993. * @param texture Defines the AdvancedDynamicTexture to instrument
  85994. */
  85995. constructor(
  85996. /**
  85997. * Define the instrumented AdvancedDynamicTexture.
  85998. */
  85999. texture: AdvancedDynamicTexture);
  86000. /**
  86001. * Dispose and release associated resources.
  86002. */
  86003. dispose(): void;
  86004. }
  86005. }
  86006. declare module BABYLON.GUI {
  86007. /**
  86008. * Class used to load GUI via XML.
  86009. */
  86010. export class XmlLoader {
  86011. private _nodes;
  86012. private _nodeTypes;
  86013. private _isLoaded;
  86014. private _objectAttributes;
  86015. private _parentClass;
  86016. /**
  86017. * Create a new xml loader
  86018. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  86019. */
  86020. constructor(parentClass?: null);
  86021. private _getChainElement;
  86022. private _getClassAttribute;
  86023. private _createGuiElement;
  86024. private _parseGrid;
  86025. private _parseElement;
  86026. private _prepareSourceElement;
  86027. private _parseElementsFromSource;
  86028. private _parseXml;
  86029. /**
  86030. * Gets if the loading has finished.
  86031. * @returns whether the loading has finished or not
  86032. */
  86033. isLoaded(): boolean;
  86034. /**
  86035. * Gets a loaded node / control by id.
  86036. * @param id the Controls id set in the xml
  86037. * @returns element of type Control
  86038. */
  86039. getNodeById(id: string): any;
  86040. /**
  86041. * Gets all loaded nodes / controls
  86042. * @returns Array of controls
  86043. */
  86044. getNodes(): any;
  86045. /**
  86046. * Initiates the xml layout loading
  86047. * @param xmlFile defines the xml layout to load
  86048. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  86049. * @param callback defines the callback called on layout load.
  86050. */
  86051. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  86052. }
  86053. }
  86054. declare module BABYLON.GUI {
  86055. /**
  86056. * Class used to create containers for controls
  86057. */
  86058. export class Container3D extends Control3D {
  86059. private _blockLayout;
  86060. /**
  86061. * Gets the list of child controls
  86062. */
  86063. protected _children: Control3D[];
  86064. /**
  86065. * Gets the list of child controls
  86066. */
  86067. get children(): Array<Control3D>;
  86068. /**
  86069. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  86070. * This is helpful to optimize layout operation when adding multiple children in a row
  86071. */
  86072. get blockLayout(): boolean;
  86073. set blockLayout(value: boolean);
  86074. /**
  86075. * Creates a new container
  86076. * @param name defines the container name
  86077. */
  86078. constructor(name?: string);
  86079. /**
  86080. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  86081. * @returns the current container
  86082. */
  86083. updateLayout(): Container3D;
  86084. /**
  86085. * Gets a boolean indicating if the given control is in the children of this control
  86086. * @param control defines the control to check
  86087. * @returns true if the control is in the child list
  86088. */
  86089. containsControl(control: Control3D): boolean;
  86090. /**
  86091. * Adds a control to the children of this control
  86092. * @param control defines the control to add
  86093. * @returns the current container
  86094. */
  86095. addControl(control: Control3D): Container3D;
  86096. /**
  86097. * This function will be called everytime a new control is added
  86098. */
  86099. protected _arrangeChildren(): void;
  86100. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86101. /**
  86102. * Removes a control from the children of this control
  86103. * @param control defines the control to remove
  86104. * @returns the current container
  86105. */
  86106. removeControl(control: Control3D): Container3D;
  86107. protected _getTypeName(): string;
  86108. /**
  86109. * Releases all associated resources
  86110. */
  86111. dispose(): void;
  86112. /** Control rotation will remain unchanged */
  86113. static readonly UNSET_ORIENTATION: number;
  86114. /** Control will rotate to make it look at sphere central axis */
  86115. static readonly FACEORIGIN_ORIENTATION: number;
  86116. /** Control will rotate to make it look back at sphere central axis */
  86117. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  86118. /** Control will rotate to look at z axis (0, 0, 1) */
  86119. static readonly FACEFORWARD_ORIENTATION: number;
  86120. /** Control will rotate to look at negative z axis (0, 0, -1) */
  86121. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  86122. }
  86123. }
  86124. declare module BABYLON.GUI {
  86125. /**
  86126. * Class used to manage 3D user interface
  86127. * @see https://doc.babylonjs.com/how_to/gui3d
  86128. */
  86129. export class GUI3DManager implements BABYLON.IDisposable {
  86130. private _scene;
  86131. private _sceneDisposeObserver;
  86132. private _utilityLayer;
  86133. private _rootContainer;
  86134. private _pointerObserver;
  86135. private _pointerOutObserver;
  86136. /** @hidden */
  86137. _lastPickedControl: Control3D;
  86138. /** @hidden */
  86139. _lastControlOver: {
  86140. [pointerId: number]: Control3D;
  86141. };
  86142. /** @hidden */
  86143. _lastControlDown: {
  86144. [pointerId: number]: Control3D;
  86145. };
  86146. /**
  86147. * BABYLON.Observable raised when the point picked by the pointer events changed
  86148. */
  86149. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  86150. /** @hidden */
  86151. _sharedMaterials: {
  86152. [key: string]: BABYLON.Material;
  86153. };
  86154. /** Gets the hosting scene */
  86155. get scene(): BABYLON.Scene;
  86156. /** Gets associated utility layer */
  86157. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  86158. /**
  86159. * Creates a new GUI3DManager
  86160. * @param scene
  86161. */
  86162. constructor(scene?: BABYLON.Scene);
  86163. private _handlePointerOut;
  86164. private _doPicking;
  86165. /**
  86166. * Gets the root container
  86167. */
  86168. get rootContainer(): Container3D;
  86169. /**
  86170. * Gets a boolean indicating if the given control is in the root child list
  86171. * @param control defines the control to check
  86172. * @returns true if the control is in the root child list
  86173. */
  86174. containsControl(control: Control3D): boolean;
  86175. /**
  86176. * Adds a control to the root child list
  86177. * @param control defines the control to add
  86178. * @returns the current manager
  86179. */
  86180. addControl(control: Control3D): GUI3DManager;
  86181. /**
  86182. * Removes a control from the root child list
  86183. * @param control defines the control to remove
  86184. * @returns the current container
  86185. */
  86186. removeControl(control: Control3D): GUI3DManager;
  86187. /**
  86188. * Releases all associated resources
  86189. */
  86190. dispose(): void;
  86191. }
  86192. }
  86193. declare module BABYLON.GUI {
  86194. /**
  86195. * Class used to transport BABYLON.Vector3 information for pointer events
  86196. */
  86197. export class Vector3WithInfo extends BABYLON.Vector3 {
  86198. /** defines the current mouse button index */
  86199. buttonIndex: number;
  86200. /**
  86201. * Creates a new Vector3WithInfo
  86202. * @param source defines the vector3 data to transport
  86203. * @param buttonIndex defines the current mouse button index
  86204. */
  86205. constructor(source: BABYLON.Vector3,
  86206. /** defines the current mouse button index */
  86207. buttonIndex?: number);
  86208. }
  86209. }
  86210. declare module BABYLON.GUI {
  86211. /**
  86212. * Class used as base class for controls
  86213. */
  86214. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  86215. /** Defines the control name */
  86216. name?: string | undefined;
  86217. /** @hidden */
  86218. _host: GUI3DManager;
  86219. private _node;
  86220. private _downCount;
  86221. private _enterCount;
  86222. private _downPointerIds;
  86223. private _isVisible;
  86224. /** Gets or sets the control position in world space */
  86225. get position(): BABYLON.Vector3;
  86226. set position(value: BABYLON.Vector3);
  86227. /** Gets or sets the control scaling in world space */
  86228. get scaling(): BABYLON.Vector3;
  86229. set scaling(value: BABYLON.Vector3);
  86230. /** Callback used to start pointer enter animation */
  86231. pointerEnterAnimation: () => void;
  86232. /** Callback used to start pointer out animation */
  86233. pointerOutAnimation: () => void;
  86234. /** Callback used to start pointer down animation */
  86235. pointerDownAnimation: () => void;
  86236. /** Callback used to start pointer up animation */
  86237. pointerUpAnimation: () => void;
  86238. /**
  86239. * An event triggered when the pointer move over the control
  86240. */
  86241. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  86242. /**
  86243. * An event triggered when the pointer move out of the control
  86244. */
  86245. onPointerOutObservable: BABYLON.Observable<Control3D>;
  86246. /**
  86247. * An event triggered when the pointer taps the control
  86248. */
  86249. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  86250. /**
  86251. * An event triggered when pointer is up
  86252. */
  86253. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  86254. /**
  86255. * An event triggered when a control is clicked on (with a mouse)
  86256. */
  86257. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  86258. /**
  86259. * An event triggered when pointer enters the control
  86260. */
  86261. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  86262. /**
  86263. * Gets or sets the parent container
  86264. */
  86265. parent: BABYLON.Nullable<Container3D>;
  86266. private _behaviors;
  86267. /**
  86268. * Gets the list of attached behaviors
  86269. * @see https://doc.babylonjs.com/features/behaviour
  86270. */
  86271. get behaviors(): BABYLON.Behavior<Control3D>[];
  86272. /**
  86273. * Attach a behavior to the control
  86274. * @see https://doc.babylonjs.com/features/behaviour
  86275. * @param behavior defines the behavior to attach
  86276. * @returns the current control
  86277. */
  86278. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86279. /**
  86280. * Remove an attached behavior
  86281. * @see https://doc.babylonjs.com/features/behaviour
  86282. * @param behavior defines the behavior to attach
  86283. * @returns the current control
  86284. */
  86285. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86286. /**
  86287. * Gets an attached behavior by name
  86288. * @param name defines the name of the behavior to look for
  86289. * @see https://doc.babylonjs.com/features/behaviour
  86290. * @returns null if behavior was not found else the requested behavior
  86291. */
  86292. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  86293. /** Gets or sets a boolean indicating if the control is visible */
  86294. get isVisible(): boolean;
  86295. set isVisible(value: boolean);
  86296. /**
  86297. * Creates a new control
  86298. * @param name defines the control name
  86299. */
  86300. constructor(
  86301. /** Defines the control name */
  86302. name?: string | undefined);
  86303. /**
  86304. * Gets a string representing the class name
  86305. */
  86306. get typeName(): string;
  86307. /**
  86308. * Get the current class name of the control.
  86309. * @returns current class name
  86310. */
  86311. getClassName(): string;
  86312. protected _getTypeName(): string;
  86313. /**
  86314. * Gets the transform node used by this control
  86315. */
  86316. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  86317. /**
  86318. * Gets the mesh used to render this control
  86319. */
  86320. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  86321. /**
  86322. * Link the control as child of the given node
  86323. * @param node defines the node to link to. Use null to unlink the control
  86324. * @returns the current control
  86325. */
  86326. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  86327. /** @hidden **/
  86328. _prepareNode(scene: BABYLON.Scene): void;
  86329. protected _injectGUI3DMetadata(node: BABYLON.TransformNode): any;
  86330. /**
  86331. * Node creation.
  86332. * Can be overriden by children
  86333. * @param scene defines the scene where the node must be attached
  86334. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  86335. */
  86336. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86337. /**
  86338. * Affect a material to the given mesh
  86339. * @param mesh defines the mesh which will represent the control
  86340. */
  86341. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86342. /** @hidden */
  86343. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  86344. /** @hidden */
  86345. _onPointerEnter(target: Control3D): boolean;
  86346. /** @hidden */
  86347. _onPointerOut(target: Control3D): void;
  86348. /** @hidden */
  86349. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86350. /** @hidden */
  86351. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  86352. /** @hidden */
  86353. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  86354. /** @hidden */
  86355. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86356. /** @hidden */
  86357. _disposeNode(): void;
  86358. /**
  86359. * Releases all associated resources
  86360. */
  86361. dispose(): void;
  86362. }
  86363. }
  86364. declare module BABYLON.GUI {
  86365. /**
  86366. * Class used as a root to all buttons
  86367. */
  86368. export class AbstractButton3D extends Control3D {
  86369. /**
  86370. * Creates a new button
  86371. * @param name defines the control name
  86372. */
  86373. constructor(name?: string);
  86374. protected _getTypeName(): string;
  86375. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86376. }
  86377. }
  86378. declare module BABYLON.GUI {
  86379. /**
  86380. * Class used to create a button in 3D
  86381. */
  86382. export class Button3D extends AbstractButton3D {
  86383. /** @hidden */
  86384. protected _currentMaterial: BABYLON.Material;
  86385. private _facadeTexture;
  86386. private _content;
  86387. private _contentResolution;
  86388. private _contentScaleRatio;
  86389. /**
  86390. * Gets or sets the texture resolution used to render content (512 by default)
  86391. */
  86392. get contentResolution(): BABYLON.int;
  86393. set contentResolution(value: BABYLON.int);
  86394. /**
  86395. * Gets or sets the texture scale ratio used to render content (2 by default)
  86396. */
  86397. get contentScaleRatio(): number;
  86398. set contentScaleRatio(value: number);
  86399. protected _disposeFacadeTexture(): void;
  86400. protected _resetContent(): void;
  86401. /**
  86402. * Creates a new button
  86403. * @param name defines the control name
  86404. */
  86405. constructor(name?: string);
  86406. /**
  86407. * Gets or sets the GUI 2D content used to display the button's facade
  86408. */
  86409. get content(): Control;
  86410. set content(value: Control);
  86411. /**
  86412. * Apply the facade texture (created from the content property).
  86413. * This function can be overloaded by child classes
  86414. * @param facadeTexture defines the AdvancedDynamicTexture to use
  86415. */
  86416. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86417. protected _getTypeName(): string;
  86418. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86419. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86420. /**
  86421. * Releases all associated resources
  86422. */
  86423. dispose(): void;
  86424. }
  86425. }
  86426. declare module BABYLON.GUI {
  86427. /**
  86428. * Abstract class used to create a container panel deployed on the surface of a volume
  86429. */
  86430. export abstract class VolumeBasedPanel extends Container3D {
  86431. private _columns;
  86432. private _rows;
  86433. private _rowThenColum;
  86434. private _orientation;
  86435. protected _cellWidth: number;
  86436. protected _cellHeight: number;
  86437. /**
  86438. * Gets or sets the distance between elements
  86439. */
  86440. margin: number;
  86441. /**
  86442. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  86443. * | Value | Type | Description |
  86444. * | ----- | ----------------------------------- | ----------- |
  86445. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  86446. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  86447. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  86448. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  86449. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  86450. */
  86451. get orientation(): number;
  86452. set orientation(value: number);
  86453. /**
  86454. * Gets or sets the number of columns requested (10 by default).
  86455. * The panel will automatically compute the number of rows based on number of child controls.
  86456. */
  86457. get columns(): BABYLON.int;
  86458. set columns(value: BABYLON.int);
  86459. /**
  86460. * Gets or sets a the number of rows requested.
  86461. * The panel will automatically compute the number of columns based on number of child controls.
  86462. */
  86463. get rows(): BABYLON.int;
  86464. set rows(value: BABYLON.int);
  86465. /**
  86466. * Creates new VolumeBasedPanel
  86467. */
  86468. constructor();
  86469. protected _arrangeChildren(): void;
  86470. /** Child classes must implement this function to provide correct control positioning */
  86471. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86472. /** Child classes can implement this function to provide additional processing */
  86473. protected _finalProcessing(): void;
  86474. }
  86475. }
  86476. declare module BABYLON.GUI {
  86477. /**
  86478. * Class used to create a container panel deployed on the surface of a cylinder
  86479. */
  86480. export class CylinderPanel extends VolumeBasedPanel {
  86481. private _radius;
  86482. /**
  86483. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  86484. */
  86485. get radius(): BABYLON.float;
  86486. set radius(value: BABYLON.float);
  86487. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86488. private _cylindricalMapping;
  86489. }
  86490. }
  86491. declare module BABYLON.GUI {
  86492. /** @hidden */
  86493. export var fluentVertexShader: {
  86494. name: string;
  86495. shader: string;
  86496. };
  86497. }
  86498. declare module BABYLON.GUI {
  86499. /** @hidden */
  86500. export var fluentPixelShader: {
  86501. name: string;
  86502. shader: string;
  86503. };
  86504. }
  86505. declare module BABYLON.GUI {
  86506. /** @hidden */
  86507. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  86508. INNERGLOW: boolean;
  86509. BORDER: boolean;
  86510. HOVERLIGHT: boolean;
  86511. TEXTURE: boolean;
  86512. constructor();
  86513. }
  86514. /**
  86515. * Class used to render controls with fluent desgin
  86516. */
  86517. export class FluentMaterial extends BABYLON.PushMaterial {
  86518. /**
  86519. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  86520. */
  86521. innerGlowColorIntensity: number;
  86522. /**
  86523. * Gets or sets the inner glow color (white by default)
  86524. */
  86525. innerGlowColor: BABYLON.Color3;
  86526. /**
  86527. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  86528. */
  86529. albedoColor: BABYLON.Color3;
  86530. /**
  86531. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  86532. */
  86533. renderBorders: boolean;
  86534. /**
  86535. * Gets or sets border width (default is 0.5)
  86536. */
  86537. borderWidth: number;
  86538. /**
  86539. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  86540. */
  86541. edgeSmoothingValue: number;
  86542. /**
  86543. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  86544. */
  86545. borderMinValue: number;
  86546. /**
  86547. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  86548. */
  86549. renderHoverLight: boolean;
  86550. /**
  86551. * Gets or sets the radius used to render the hover light (default is 1.0)
  86552. */
  86553. hoverRadius: number;
  86554. /**
  86555. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  86556. */
  86557. hoverColor: BABYLON.Color4;
  86558. /**
  86559. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  86560. */
  86561. hoverPosition: BABYLON.Vector3;
  86562. private _albedoTexture;
  86563. /** Gets or sets the texture to use for albedo color */
  86564. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86565. /**
  86566. * Creates a new Fluent material
  86567. * @param name defines the name of the material
  86568. * @param scene defines the hosting scene
  86569. */
  86570. constructor(name: string, scene: BABYLON.Scene);
  86571. needAlphaBlending(): boolean;
  86572. needAlphaTesting(): boolean;
  86573. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86574. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86575. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86576. getActiveTextures(): BABYLON.BaseTexture[];
  86577. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86578. dispose(forceDisposeEffect?: boolean): void;
  86579. clone(name: string): FluentMaterial;
  86580. serialize(): any;
  86581. getClassName(): string;
  86582. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  86583. }
  86584. }
  86585. declare module BABYLON.GUI {
  86586. /**
  86587. * Class used to create a holographic button in 3D
  86588. */
  86589. export class HolographicButton extends Button3D {
  86590. private _backPlate;
  86591. private _textPlate;
  86592. private _frontPlate;
  86593. private _text;
  86594. private _imageUrl;
  86595. private _shareMaterials;
  86596. private _frontMaterial;
  86597. private _backMaterial;
  86598. private _plateMaterial;
  86599. private _pickedPointObserver;
  86600. private _tooltipFade;
  86601. private _tooltipTextBlock;
  86602. private _tooltipTexture;
  86603. private _tooltipMesh;
  86604. private _tooltipHoverObserver;
  86605. private _tooltipOutObserver;
  86606. private _disposeTooltip;
  86607. /**
  86608. * Rendering ground id of all the mesh in the button
  86609. */
  86610. set renderingGroupId(id: number);
  86611. get renderingGroupId(): number;
  86612. /**
  86613. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  86614. */
  86615. set tooltipText(text: BABYLON.Nullable<string>);
  86616. get tooltipText(): BABYLON.Nullable<string>;
  86617. /**
  86618. * Gets or sets text for the button
  86619. */
  86620. get text(): string;
  86621. set text(value: string);
  86622. /**
  86623. * Gets or sets the image url for the button
  86624. */
  86625. get imageUrl(): string;
  86626. set imageUrl(value: string);
  86627. /**
  86628. * Gets the back material used by this button
  86629. */
  86630. get backMaterial(): FluentMaterial;
  86631. /**
  86632. * Gets the front material used by this button
  86633. */
  86634. get frontMaterial(): FluentMaterial;
  86635. /**
  86636. * Gets the plate material used by this button
  86637. */
  86638. get plateMaterial(): BABYLON.StandardMaterial;
  86639. /**
  86640. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  86641. */
  86642. get shareMaterials(): boolean;
  86643. /**
  86644. * Creates a new button
  86645. * @param name defines the control name
  86646. */
  86647. constructor(name?: string, shareMaterials?: boolean);
  86648. protected _getTypeName(): string;
  86649. private _rebuildContent;
  86650. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86651. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86652. private _createBackMaterial;
  86653. private _createFrontMaterial;
  86654. private _createPlateMaterial;
  86655. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  86656. /**
  86657. * Releases all associated resources
  86658. */
  86659. dispose(): void;
  86660. }
  86661. }
  86662. declare module BABYLON.GUI {
  86663. /**
  86664. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  86665. */
  86666. export class MeshButton3D extends Button3D {
  86667. /** @hidden */
  86668. protected _currentMesh: BABYLON.Mesh;
  86669. /**
  86670. * Creates a new 3D button based on a mesh
  86671. * @param mesh mesh to become a 3D button
  86672. * @param name defines the control name
  86673. */
  86674. constructor(mesh: BABYLON.Mesh, name?: string);
  86675. protected _getTypeName(): string;
  86676. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86677. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86678. }
  86679. }
  86680. declare module BABYLON.GUI {
  86681. /**
  86682. * Class used to create a container panel deployed on the surface of a plane
  86683. */
  86684. export class PlanePanel extends VolumeBasedPanel {
  86685. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86686. }
  86687. }
  86688. declare module BABYLON.GUI {
  86689. /**
  86690. * Class used to create a container panel where items get randomized planar mapping
  86691. */
  86692. export class ScatterPanel extends VolumeBasedPanel {
  86693. private _iteration;
  86694. /**
  86695. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  86696. */
  86697. get iteration(): BABYLON.float;
  86698. set iteration(value: BABYLON.float);
  86699. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86700. private _scatterMapping;
  86701. protected _finalProcessing(): void;
  86702. }
  86703. }
  86704. declare module BABYLON.GUI {
  86705. /**
  86706. * Class used to create a container panel deployed on the surface of a sphere
  86707. */
  86708. export class SpherePanel extends VolumeBasedPanel {
  86709. private _radius;
  86710. /**
  86711. * Gets or sets the radius of the sphere where to project controls (5 by default)
  86712. */
  86713. get radius(): BABYLON.float;
  86714. set radius(value: BABYLON.float);
  86715. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86716. private _sphericalMapping;
  86717. }
  86718. }
  86719. declare module BABYLON.GUI {
  86720. /**
  86721. * Class used to create a stack panel in 3D on XY plane
  86722. */
  86723. export class StackPanel3D extends Container3D {
  86724. private _isVertical;
  86725. /**
  86726. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  86727. */
  86728. get isVertical(): boolean;
  86729. set isVertical(value: boolean);
  86730. /**
  86731. * Gets or sets the distance between elements
  86732. */
  86733. margin: number;
  86734. /**
  86735. * Creates new StackPanel
  86736. * @param isVertical
  86737. */
  86738. constructor(isVertical?: boolean);
  86739. protected _arrangeChildren(): void;
  86740. }
  86741. }
  86742. declare module BABYLON {
  86743. /**
  86744. * Configuration for glTF validation
  86745. */
  86746. export interface IGLTFValidationConfiguration {
  86747. /**
  86748. * The url of the glTF validator.
  86749. */
  86750. url: string;
  86751. }
  86752. /**
  86753. * glTF validation
  86754. */
  86755. export class GLTFValidation {
  86756. /**
  86757. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  86758. */
  86759. static Configuration: IGLTFValidationConfiguration;
  86760. private static _LoadScriptPromise;
  86761. /**
  86762. * Validate a glTF asset using the glTF-Validator.
  86763. * @param data The JSON of a glTF or the array buffer of a binary glTF
  86764. * @param rootUrl The root url for the glTF
  86765. * @param fileName The file name for the glTF
  86766. * @param getExternalResource The callback to get external resources for the glTF validator
  86767. * @returns A promise that resolves with the glTF validation results once complete
  86768. */
  86769. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  86770. }
  86771. }
  86772. declare module BABYLON {
  86773. /**
  86774. * Mode that determines the coordinate system to use.
  86775. */
  86776. export enum GLTFLoaderCoordinateSystemMode {
  86777. /**
  86778. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  86779. */
  86780. AUTO = 0,
  86781. /**
  86782. * Sets the useRightHandedSystem flag on the scene.
  86783. */
  86784. FORCE_RIGHT_HANDED = 1
  86785. }
  86786. /**
  86787. * Mode that determines what animations will start.
  86788. */
  86789. export enum GLTFLoaderAnimationStartMode {
  86790. /**
  86791. * No animation will start.
  86792. */
  86793. NONE = 0,
  86794. /**
  86795. * The first animation will start.
  86796. */
  86797. FIRST = 1,
  86798. /**
  86799. * All animations will start.
  86800. */
  86801. ALL = 2
  86802. }
  86803. /**
  86804. * Interface that contains the data for the glTF asset.
  86805. */
  86806. export interface IGLTFLoaderData {
  86807. /**
  86808. * The object that represents the glTF JSON.
  86809. */
  86810. json: Object;
  86811. /**
  86812. * The BIN chunk of a binary glTF.
  86813. */
  86814. bin: Nullable<IDataBuffer>;
  86815. }
  86816. /**
  86817. * Interface for extending the loader.
  86818. */
  86819. export interface IGLTFLoaderExtension {
  86820. /**
  86821. * The name of this extension.
  86822. */
  86823. readonly name: string;
  86824. /**
  86825. * Defines whether this extension is enabled.
  86826. */
  86827. enabled: boolean;
  86828. /**
  86829. * Defines the order of this extension.
  86830. * The loader sorts the extensions using these values when loading.
  86831. */
  86832. order?: number;
  86833. }
  86834. /**
  86835. * Loader state.
  86836. */
  86837. export enum GLTFLoaderState {
  86838. /**
  86839. * The asset is loading.
  86840. */
  86841. LOADING = 0,
  86842. /**
  86843. * The asset is ready for rendering.
  86844. */
  86845. READY = 1,
  86846. /**
  86847. * The asset is completely loaded.
  86848. */
  86849. COMPLETE = 2
  86850. }
  86851. /** @hidden */
  86852. export interface IGLTFLoader extends IDisposable {
  86853. readonly state: Nullable<GLTFLoaderState>;
  86854. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  86855. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  86856. }
  86857. /**
  86858. * File loader for loading glTF files into a scene.
  86859. */
  86860. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  86861. /** @hidden */
  86862. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86863. /** @hidden */
  86864. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86865. /**
  86866. * Raised when the asset has been parsed
  86867. */
  86868. onParsedObservable: Observable<IGLTFLoaderData>;
  86869. private _onParsedObserver;
  86870. /**
  86871. * Raised when the asset has been parsed
  86872. */
  86873. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  86874. /**
  86875. * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
  86876. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  86877. * Defaults to true.
  86878. * @hidden
  86879. */
  86880. static IncrementalLoading: boolean;
  86881. /**
  86882. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  86883. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  86884. * @hidden
  86885. */
  86886. static HomogeneousCoordinates: boolean;
  86887. /**
  86888. * The coordinate system mode. Defaults to AUTO.
  86889. */
  86890. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  86891. /**
  86892. * The animation start mode. Defaults to FIRST.
  86893. */
  86894. animationStartMode: GLTFLoaderAnimationStartMode;
  86895. /**
  86896. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  86897. */
  86898. compileMaterials: boolean;
  86899. /**
  86900. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  86901. */
  86902. useClipPlane: boolean;
  86903. /**
  86904. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  86905. */
  86906. compileShadowGenerators: boolean;
  86907. /**
  86908. * Defines if the Alpha blended materials are only applied as coverage.
  86909. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  86910. * If true, no extra effects are applied to transparent pixels.
  86911. */
  86912. transparencyAsCoverage: boolean;
  86913. /**
  86914. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  86915. * Enabling will disable offline support and glTF validator.
  86916. * Defaults to false.
  86917. */
  86918. useRangeRequests: boolean;
  86919. /**
  86920. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  86921. */
  86922. createInstances: boolean;
  86923. /**
  86924. * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.
  86925. */
  86926. alwaysComputeBoundingBox: boolean;
  86927. /**
  86928. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  86929. */
  86930. loadAllMaterials: boolean;
  86931. /**
  86932. * Function called before loading a url referenced by the asset.
  86933. */
  86934. preprocessUrlAsync: (url: string) => Promise<string>;
  86935. /**
  86936. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86937. * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  86938. */
  86939. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  86940. private _onMeshLoadedObserver;
  86941. /**
  86942. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86943. * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  86944. */
  86945. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  86946. /**
  86947. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  86948. */
  86949. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  86950. private _onTextureLoadedObserver;
  86951. /**
  86952. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  86953. */
  86954. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  86955. /**
  86956. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  86957. */
  86958. readonly onMaterialLoadedObservable: Observable<Material>;
  86959. private _onMaterialLoadedObserver;
  86960. /**
  86961. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  86962. */
  86963. set onMaterialLoaded(callback: (material: Material) => void);
  86964. /**
  86965. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  86966. */
  86967. readonly onCameraLoadedObservable: Observable<Camera>;
  86968. private _onCameraLoadedObserver;
  86969. /**
  86970. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  86971. */
  86972. set onCameraLoaded(callback: (camera: Camera) => void);
  86973. /**
  86974. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  86975. * For assets with LODs, raised when all of the LODs are complete.
  86976. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86977. */
  86978. readonly onCompleteObservable: Observable<void>;
  86979. private _onCompleteObserver;
  86980. /**
  86981. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  86982. * For assets with LODs, raised when all of the LODs are complete.
  86983. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86984. */
  86985. set onComplete(callback: () => void);
  86986. /**
  86987. * Observable raised when an error occurs.
  86988. */
  86989. readonly onErrorObservable: Observable<any>;
  86990. private _onErrorObserver;
  86991. /**
  86992. * Callback raised when an error occurs.
  86993. */
  86994. set onError(callback: (reason: any) => void);
  86995. /**
  86996. * Observable raised after the loader is disposed.
  86997. */
  86998. readonly onDisposeObservable: Observable<void>;
  86999. private _onDisposeObserver;
  87000. /**
  87001. * Callback raised after the loader is disposed.
  87002. */
  87003. set onDispose(callback: () => void);
  87004. /**
  87005. * Observable raised after a loader extension is created.
  87006. * Set additional options for a loader extension in this event.
  87007. */
  87008. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  87009. private _onExtensionLoadedObserver;
  87010. /**
  87011. * Callback raised after a loader extension is created.
  87012. */
  87013. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  87014. /**
  87015. * Defines if the loader logging is enabled.
  87016. */
  87017. get loggingEnabled(): boolean;
  87018. set loggingEnabled(value: boolean);
  87019. /**
  87020. * Defines if the loader should capture performance counters.
  87021. */
  87022. get capturePerformanceCounters(): boolean;
  87023. set capturePerformanceCounters(value: boolean);
  87024. /**
  87025. * Defines if the loader should validate the asset.
  87026. */
  87027. validate: boolean;
  87028. /**
  87029. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  87030. */
  87031. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  87032. private _onValidatedObserver;
  87033. /**
  87034. * Callback raised after a loader extension is created.
  87035. */
  87036. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  87037. private _loader;
  87038. private _progressCallback?;
  87039. private _requests;
  87040. private static magicBase64Encoded;
  87041. /**
  87042. * Name of the loader ("gltf")
  87043. */
  87044. name: string;
  87045. /** @hidden */
  87046. extensions: ISceneLoaderPluginExtensions;
  87047. /**
  87048. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  87049. */
  87050. dispose(): void;
  87051. /** @hidden */
  87052. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87053. /** @hidden */
  87054. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87055. /** @hidden */
  87056. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87057. /** @hidden */
  87058. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87059. /** @hidden */
  87060. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  87061. /** @hidden */
  87062. canDirectLoad(data: string): boolean;
  87063. /** @hidden */
  87064. directLoad(scene: Scene, data: string): Promise<any>;
  87065. /**
  87066. * The callback that allows custom handling of the root url based on the response url.
  87067. * @param rootUrl the original root url
  87068. * @param responseURL the response url if available
  87069. * @returns the new root url
  87070. */
  87071. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  87072. /** @hidden */
  87073. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  87074. /**
  87075. * The loader state or null if the loader is not active.
  87076. */
  87077. get loaderState(): Nullable<GLTFLoaderState>;
  87078. /**
  87079. * Returns a promise that resolves when the asset is completely loaded.
  87080. * @returns a promise that resolves when the asset is completely loaded.
  87081. */
  87082. whenCompleteAsync(): Promise<void>;
  87083. /** @hidden */
  87084. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  87085. /** @hidden */
  87086. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  87087. private _onProgress;
  87088. private _validate;
  87089. private _getLoader;
  87090. private _parseJson;
  87091. private _unpackBinaryAsync;
  87092. private _unpackBinaryV1Async;
  87093. private _unpackBinaryV2Async;
  87094. private static _parseVersion;
  87095. private static _compareVersion;
  87096. private static readonly _logSpaces;
  87097. private _logIndentLevel;
  87098. private _loggingEnabled;
  87099. /** @hidden */
  87100. _log: (message: string) => void;
  87101. /** @hidden */
  87102. _logOpen(message: string): void;
  87103. /** @hidden */
  87104. _logClose(): void;
  87105. private _logEnabled;
  87106. private _logDisabled;
  87107. private _capturePerformanceCounters;
  87108. /** @hidden */
  87109. _startPerformanceCounter: (counterName: string) => void;
  87110. /** @hidden */
  87111. _endPerformanceCounter: (counterName: string) => void;
  87112. private _startPerformanceCounterEnabled;
  87113. private _startPerformanceCounterDisabled;
  87114. private _endPerformanceCounterEnabled;
  87115. private _endPerformanceCounterDisabled;
  87116. }
  87117. }
  87118. declare module BABYLON.GLTF1 {
  87119. /**
  87120. * Enums
  87121. * @hidden
  87122. */
  87123. export enum EComponentType {
  87124. BYTE = 5120,
  87125. UNSIGNED_BYTE = 5121,
  87126. SHORT = 5122,
  87127. UNSIGNED_SHORT = 5123,
  87128. FLOAT = 5126
  87129. }
  87130. /** @hidden */
  87131. export enum EShaderType {
  87132. FRAGMENT = 35632,
  87133. VERTEX = 35633
  87134. }
  87135. /** @hidden */
  87136. export enum EParameterType {
  87137. BYTE = 5120,
  87138. UNSIGNED_BYTE = 5121,
  87139. SHORT = 5122,
  87140. UNSIGNED_SHORT = 5123,
  87141. INT = 5124,
  87142. UNSIGNED_INT = 5125,
  87143. FLOAT = 5126,
  87144. FLOAT_VEC2 = 35664,
  87145. FLOAT_VEC3 = 35665,
  87146. FLOAT_VEC4 = 35666,
  87147. INT_VEC2 = 35667,
  87148. INT_VEC3 = 35668,
  87149. INT_VEC4 = 35669,
  87150. BOOL = 35670,
  87151. BOOL_VEC2 = 35671,
  87152. BOOL_VEC3 = 35672,
  87153. BOOL_VEC4 = 35673,
  87154. FLOAT_MAT2 = 35674,
  87155. FLOAT_MAT3 = 35675,
  87156. FLOAT_MAT4 = 35676,
  87157. SAMPLER_2D = 35678
  87158. }
  87159. /** @hidden */
  87160. export enum ETextureWrapMode {
  87161. CLAMP_TO_EDGE = 33071,
  87162. MIRRORED_REPEAT = 33648,
  87163. REPEAT = 10497
  87164. }
  87165. /** @hidden */
  87166. export enum ETextureFilterType {
  87167. NEAREST = 9728,
  87168. LINEAR = 9728,
  87169. NEAREST_MIPMAP_NEAREST = 9984,
  87170. LINEAR_MIPMAP_NEAREST = 9985,
  87171. NEAREST_MIPMAP_LINEAR = 9986,
  87172. LINEAR_MIPMAP_LINEAR = 9987
  87173. }
  87174. /** @hidden */
  87175. export enum ETextureFormat {
  87176. ALPHA = 6406,
  87177. RGB = 6407,
  87178. RGBA = 6408,
  87179. LUMINANCE = 6409,
  87180. LUMINANCE_ALPHA = 6410
  87181. }
  87182. /** @hidden */
  87183. export enum ECullingType {
  87184. FRONT = 1028,
  87185. BACK = 1029,
  87186. FRONT_AND_BACK = 1032
  87187. }
  87188. /** @hidden */
  87189. export enum EBlendingFunction {
  87190. ZERO = 0,
  87191. ONE = 1,
  87192. SRC_COLOR = 768,
  87193. ONE_MINUS_SRC_COLOR = 769,
  87194. DST_COLOR = 774,
  87195. ONE_MINUS_DST_COLOR = 775,
  87196. SRC_ALPHA = 770,
  87197. ONE_MINUS_SRC_ALPHA = 771,
  87198. DST_ALPHA = 772,
  87199. ONE_MINUS_DST_ALPHA = 773,
  87200. CONSTANT_COLOR = 32769,
  87201. ONE_MINUS_CONSTANT_COLOR = 32770,
  87202. CONSTANT_ALPHA = 32771,
  87203. ONE_MINUS_CONSTANT_ALPHA = 32772,
  87204. SRC_ALPHA_SATURATE = 776
  87205. }
  87206. /** @hidden */
  87207. export interface IGLTFProperty {
  87208. extensions?: {
  87209. [key: string]: any;
  87210. };
  87211. extras?: Object;
  87212. }
  87213. /** @hidden */
  87214. export interface IGLTFChildRootProperty extends IGLTFProperty {
  87215. name?: string;
  87216. }
  87217. /** @hidden */
  87218. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  87219. bufferView: string;
  87220. byteOffset: number;
  87221. byteStride: number;
  87222. count: number;
  87223. type: string;
  87224. componentType: EComponentType;
  87225. max?: number[];
  87226. min?: number[];
  87227. name?: string;
  87228. }
  87229. /** @hidden */
  87230. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  87231. buffer: string;
  87232. byteOffset: number;
  87233. byteLength: number;
  87234. byteStride: number;
  87235. target?: number;
  87236. }
  87237. /** @hidden */
  87238. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  87239. uri: string;
  87240. byteLength?: number;
  87241. type?: string;
  87242. }
  87243. /** @hidden */
  87244. export interface IGLTFShader extends IGLTFChildRootProperty {
  87245. uri: string;
  87246. type: EShaderType;
  87247. }
  87248. /** @hidden */
  87249. export interface IGLTFProgram extends IGLTFChildRootProperty {
  87250. attributes: string[];
  87251. fragmentShader: string;
  87252. vertexShader: string;
  87253. }
  87254. /** @hidden */
  87255. export interface IGLTFTechniqueParameter {
  87256. type: number;
  87257. count?: number;
  87258. semantic?: string;
  87259. node?: string;
  87260. value?: number | boolean | string | Array<any>;
  87261. source?: string;
  87262. babylonValue?: any;
  87263. }
  87264. /** @hidden */
  87265. export interface IGLTFTechniqueCommonProfile {
  87266. lightingModel: string;
  87267. texcoordBindings: Object;
  87268. parameters?: Array<any>;
  87269. }
  87270. /** @hidden */
  87271. export interface IGLTFTechniqueStatesFunctions {
  87272. blendColor?: number[];
  87273. blendEquationSeparate?: number[];
  87274. blendFuncSeparate?: number[];
  87275. colorMask: boolean[];
  87276. cullFace: number[];
  87277. }
  87278. /** @hidden */
  87279. export interface IGLTFTechniqueStates {
  87280. enable: number[];
  87281. functions: IGLTFTechniqueStatesFunctions;
  87282. }
  87283. /** @hidden */
  87284. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  87285. parameters: {
  87286. [key: string]: IGLTFTechniqueParameter;
  87287. };
  87288. program: string;
  87289. attributes: {
  87290. [key: string]: string;
  87291. };
  87292. uniforms: {
  87293. [key: string]: string;
  87294. };
  87295. states: IGLTFTechniqueStates;
  87296. }
  87297. /** @hidden */
  87298. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  87299. technique?: string;
  87300. values: string[];
  87301. }
  87302. /** @hidden */
  87303. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  87304. attributes: {
  87305. [key: string]: string;
  87306. };
  87307. indices: string;
  87308. material: string;
  87309. mode?: number;
  87310. }
  87311. /** @hidden */
  87312. export interface IGLTFMesh extends IGLTFChildRootProperty {
  87313. primitives: IGLTFMeshPrimitive[];
  87314. }
  87315. /** @hidden */
  87316. export interface IGLTFImage extends IGLTFChildRootProperty {
  87317. uri: string;
  87318. }
  87319. /** @hidden */
  87320. export interface IGLTFSampler extends IGLTFChildRootProperty {
  87321. magFilter?: number;
  87322. minFilter?: number;
  87323. wrapS?: number;
  87324. wrapT?: number;
  87325. }
  87326. /** @hidden */
  87327. export interface IGLTFTexture extends IGLTFChildRootProperty {
  87328. sampler: string;
  87329. source: string;
  87330. format?: ETextureFormat;
  87331. internalFormat?: ETextureFormat;
  87332. target?: number;
  87333. type?: number;
  87334. babylonTexture?: Texture;
  87335. }
  87336. /** @hidden */
  87337. export interface IGLTFAmbienLight {
  87338. color?: number[];
  87339. }
  87340. /** @hidden */
  87341. export interface IGLTFDirectionalLight {
  87342. color?: number[];
  87343. }
  87344. /** @hidden */
  87345. export interface IGLTFPointLight {
  87346. color?: number[];
  87347. constantAttenuation?: number;
  87348. linearAttenuation?: number;
  87349. quadraticAttenuation?: number;
  87350. }
  87351. /** @hidden */
  87352. export interface IGLTFSpotLight {
  87353. color?: number[];
  87354. constantAttenuation?: number;
  87355. fallOfAngle?: number;
  87356. fallOffExponent?: number;
  87357. linearAttenuation?: number;
  87358. quadraticAttenuation?: number;
  87359. }
  87360. /** @hidden */
  87361. export interface IGLTFLight extends IGLTFChildRootProperty {
  87362. type: string;
  87363. }
  87364. /** @hidden */
  87365. export interface IGLTFCameraOrthographic {
  87366. xmag: number;
  87367. ymag: number;
  87368. zfar: number;
  87369. znear: number;
  87370. }
  87371. /** @hidden */
  87372. export interface IGLTFCameraPerspective {
  87373. aspectRatio: number;
  87374. yfov: number;
  87375. zfar: number;
  87376. znear: number;
  87377. }
  87378. /** @hidden */
  87379. export interface IGLTFCamera extends IGLTFChildRootProperty {
  87380. type: string;
  87381. }
  87382. /** @hidden */
  87383. export interface IGLTFAnimationChannelTarget {
  87384. id: string;
  87385. path: string;
  87386. }
  87387. /** @hidden */
  87388. export interface IGLTFAnimationChannel {
  87389. sampler: string;
  87390. target: IGLTFAnimationChannelTarget;
  87391. }
  87392. /** @hidden */
  87393. export interface IGLTFAnimationSampler {
  87394. input: string;
  87395. output: string;
  87396. interpolation?: string;
  87397. }
  87398. /** @hidden */
  87399. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  87400. channels?: IGLTFAnimationChannel[];
  87401. parameters?: {
  87402. [key: string]: string;
  87403. };
  87404. samplers?: {
  87405. [key: string]: IGLTFAnimationSampler;
  87406. };
  87407. }
  87408. /** @hidden */
  87409. export interface IGLTFNodeInstanceSkin {
  87410. skeletons: string[];
  87411. skin: string;
  87412. meshes: string[];
  87413. }
  87414. /** @hidden */
  87415. export interface IGLTFSkins extends IGLTFChildRootProperty {
  87416. bindShapeMatrix: number[];
  87417. inverseBindMatrices: string;
  87418. jointNames: string[];
  87419. babylonSkeleton?: Skeleton;
  87420. }
  87421. /** @hidden */
  87422. export interface IGLTFNode extends IGLTFChildRootProperty {
  87423. camera?: string;
  87424. children: string[];
  87425. skin?: string;
  87426. jointName?: string;
  87427. light?: string;
  87428. matrix: number[];
  87429. mesh?: string;
  87430. meshes?: string[];
  87431. rotation?: number[];
  87432. scale?: number[];
  87433. translation?: number[];
  87434. babylonNode?: Node;
  87435. }
  87436. /** @hidden */
  87437. export interface IGLTFScene extends IGLTFChildRootProperty {
  87438. nodes: string[];
  87439. }
  87440. /** @hidden */
  87441. export interface IGLTFRuntime {
  87442. extensions: {
  87443. [key: string]: any;
  87444. };
  87445. accessors: {
  87446. [key: string]: IGLTFAccessor;
  87447. };
  87448. buffers: {
  87449. [key: string]: IGLTFBuffer;
  87450. };
  87451. bufferViews: {
  87452. [key: string]: IGLTFBufferView;
  87453. };
  87454. meshes: {
  87455. [key: string]: IGLTFMesh;
  87456. };
  87457. lights: {
  87458. [key: string]: IGLTFLight;
  87459. };
  87460. cameras: {
  87461. [key: string]: IGLTFCamera;
  87462. };
  87463. nodes: {
  87464. [key: string]: IGLTFNode;
  87465. };
  87466. images: {
  87467. [key: string]: IGLTFImage;
  87468. };
  87469. textures: {
  87470. [key: string]: IGLTFTexture;
  87471. };
  87472. shaders: {
  87473. [key: string]: IGLTFShader;
  87474. };
  87475. programs: {
  87476. [key: string]: IGLTFProgram;
  87477. };
  87478. samplers: {
  87479. [key: string]: IGLTFSampler;
  87480. };
  87481. techniques: {
  87482. [key: string]: IGLTFTechnique;
  87483. };
  87484. materials: {
  87485. [key: string]: IGLTFMaterial;
  87486. };
  87487. animations: {
  87488. [key: string]: IGLTFAnimation;
  87489. };
  87490. skins: {
  87491. [key: string]: IGLTFSkins;
  87492. };
  87493. currentScene?: Object;
  87494. scenes: {
  87495. [key: string]: IGLTFScene;
  87496. };
  87497. extensionsUsed: string[];
  87498. extensionsRequired?: string[];
  87499. buffersCount: number;
  87500. shaderscount: number;
  87501. scene: Scene;
  87502. rootUrl: string;
  87503. loadedBufferCount: number;
  87504. loadedBufferViews: {
  87505. [name: string]: ArrayBufferView;
  87506. };
  87507. loadedShaderCount: number;
  87508. importOnlyMeshes: boolean;
  87509. importMeshesNames?: string[];
  87510. dummyNodes: Node[];
  87511. forAssetContainer: boolean;
  87512. }
  87513. /** @hidden */
  87514. export interface INodeToRoot {
  87515. bone: Bone;
  87516. node: IGLTFNode;
  87517. id: string;
  87518. }
  87519. /** @hidden */
  87520. export interface IJointNode {
  87521. node: IGLTFNode;
  87522. id: string;
  87523. }
  87524. }
  87525. declare module BABYLON.GLTF1 {
  87526. /**
  87527. * Utils functions for GLTF
  87528. * @hidden
  87529. */
  87530. export class GLTFUtils {
  87531. /**
  87532. * Sets the given "parameter" matrix
  87533. * @param scene: the Scene object
  87534. * @param source: the source node where to pick the matrix
  87535. * @param parameter: the GLTF technique parameter
  87536. * @param uniformName: the name of the shader's uniform
  87537. * @param shaderMaterial: the shader material
  87538. */
  87539. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  87540. /**
  87541. * Sets the given "parameter" matrix
  87542. * @param shaderMaterial: the shader material
  87543. * @param uniform: the name of the shader's uniform
  87544. * @param value: the value of the uniform
  87545. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  87546. */
  87547. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  87548. /**
  87549. * Returns the wrap mode of the texture
  87550. * @param mode: the mode value
  87551. */
  87552. static GetWrapMode(mode: number): number;
  87553. /**
  87554. * Returns the byte stride giving an accessor
  87555. * @param accessor: the GLTF accessor objet
  87556. */
  87557. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  87558. /**
  87559. * Returns the texture filter mode giving a mode value
  87560. * @param mode: the filter mode value
  87561. */
  87562. static GetTextureFilterMode(mode: number): ETextureFilterType;
  87563. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  87564. /**
  87565. * Returns a buffer from its accessor
  87566. * @param gltfRuntime: the GLTF runtime
  87567. * @param accessor: the GLTF accessor
  87568. */
  87569. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  87570. /**
  87571. * Decodes a buffer view into a string
  87572. * @param view: the buffer view
  87573. */
  87574. static DecodeBufferToText(view: ArrayBufferView): string;
  87575. /**
  87576. * Returns the default material of gltf. Related to
  87577. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  87578. * @param scene: the Babylon.js scene
  87579. */
  87580. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  87581. private static _DefaultMaterial;
  87582. }
  87583. }
  87584. declare module BABYLON.GLTF1 {
  87585. /**
  87586. * Implementation of the base glTF spec
  87587. * @hidden
  87588. */
  87589. export class GLTFLoaderBase {
  87590. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  87591. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87592. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  87593. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87594. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  87595. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87596. }
  87597. /**
  87598. * glTF V1 Loader
  87599. * @hidden
  87600. */
  87601. export class GLTFLoader implements IGLTFLoader {
  87602. static Extensions: {
  87603. [name: string]: GLTFLoaderExtension;
  87604. };
  87605. static RegisterExtension(extension: GLTFLoaderExtension): void;
  87606. state: Nullable<GLTFLoaderState>;
  87607. dispose(): void;
  87608. private _importMeshAsync;
  87609. /**
  87610. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  87611. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  87612. * @param scene the scene the meshes should be added to
  87613. * @param forAssetContainer defines if the entities must be stored in the scene
  87614. * @param data gltf data containing information of the meshes in a loaded file
  87615. * @param rootUrl root url to load from
  87616. * @param onProgress event that fires when loading progress has occured
  87617. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  87618. */
  87619. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  87620. private _loadAsync;
  87621. /**
  87622. * Imports all objects from a loaded gltf file and adds them to the scene
  87623. * @param scene the scene the objects should be added to
  87624. * @param data gltf data containing information of the meshes in a loaded file
  87625. * @param rootUrl root url to load from
  87626. * @param onProgress event that fires when loading progress has occured
  87627. * @returns a promise which completes when objects have been loaded to the scene
  87628. */
  87629. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  87630. private _loadShadersAsync;
  87631. private _loadBuffersAsync;
  87632. private _createNodes;
  87633. }
  87634. /** @hidden */
  87635. export abstract class GLTFLoaderExtension {
  87636. private _name;
  87637. constructor(name: string);
  87638. get name(): string;
  87639. /**
  87640. * Defines an override for loading the runtime
  87641. * Return true to stop further extensions from loading the runtime
  87642. */
  87643. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  87644. /**
  87645. * Defines an onverride for creating gltf runtime
  87646. * Return true to stop further extensions from creating the runtime
  87647. */
  87648. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  87649. /**
  87650. * Defines an override for loading buffers
  87651. * Return true to stop further extensions from loading this buffer
  87652. */
  87653. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  87654. /**
  87655. * Defines an override for loading texture buffers
  87656. * Return true to stop further extensions from loading this texture data
  87657. */
  87658. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87659. /**
  87660. * Defines an override for creating textures
  87661. * Return true to stop further extensions from loading this texture
  87662. */
  87663. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  87664. /**
  87665. * Defines an override for loading shader strings
  87666. * Return true to stop further extensions from loading this shader data
  87667. */
  87668. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87669. /**
  87670. * Defines an override for loading materials
  87671. * Return true to stop further extensions from loading this material
  87672. */
  87673. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87674. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  87675. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  87676. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87677. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87678. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  87679. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87680. private static LoadTextureBufferAsync;
  87681. private static CreateTextureAsync;
  87682. private static ApplyExtensions;
  87683. }
  87684. }
  87685. declare module BABYLON.GLTF1 {
  87686. /** @hidden */
  87687. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  87688. private _bin;
  87689. constructor();
  87690. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  87691. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87692. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87693. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87694. }
  87695. }
  87696. declare module BABYLON.GLTF1 {
  87697. /** @hidden */
  87698. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  87699. constructor();
  87700. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  87701. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87702. private _loadTexture;
  87703. }
  87704. }
  87705. declare module BABYLON.GLTF2.Loader {
  87706. /**
  87707. * Loader interface with an index field.
  87708. */
  87709. export interface IArrayItem {
  87710. /**
  87711. * The index of this item in the array.
  87712. */
  87713. index: number;
  87714. }
  87715. /**
  87716. * Loader interface with additional members.
  87717. */
  87718. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  87719. /** @hidden */
  87720. _data?: Promise<ArrayBufferView>;
  87721. /** @hidden */
  87722. _babylonVertexBuffer?: Promise<VertexBuffer>;
  87723. }
  87724. /**
  87725. * Loader interface with additional members.
  87726. */
  87727. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  87728. }
  87729. /** @hidden */
  87730. export interface _IAnimationSamplerData {
  87731. input: Float32Array;
  87732. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  87733. output: Float32Array;
  87734. }
  87735. /**
  87736. * Loader interface with additional members.
  87737. */
  87738. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  87739. /** @hidden */
  87740. _data?: Promise<_IAnimationSamplerData>;
  87741. }
  87742. /**
  87743. * Loader interface with additional members.
  87744. */
  87745. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  87746. channels: IAnimationChannel[];
  87747. samplers: IAnimationSampler[];
  87748. /** @hidden */
  87749. _babylonAnimationGroup?: AnimationGroup;
  87750. }
  87751. /**
  87752. * Loader interface with additional members.
  87753. */
  87754. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  87755. /** @hidden */
  87756. _data?: Promise<ArrayBufferView>;
  87757. }
  87758. /**
  87759. * Loader interface with additional members.
  87760. */
  87761. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  87762. /** @hidden */
  87763. _data?: Promise<ArrayBufferView>;
  87764. /** @hidden */
  87765. _babylonBuffer?: Promise<Buffer>;
  87766. }
  87767. /**
  87768. * Loader interface with additional members.
  87769. */
  87770. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  87771. }
  87772. /**
  87773. * Loader interface with additional members.
  87774. */
  87775. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  87776. /** @hidden */
  87777. _data?: Promise<ArrayBufferView>;
  87778. }
  87779. /**
  87780. * Loader interface with additional members.
  87781. */
  87782. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  87783. }
  87784. /**
  87785. * Loader interface with additional members.
  87786. */
  87787. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  87788. }
  87789. /**
  87790. * Loader interface with additional members.
  87791. */
  87792. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  87793. baseColorTexture?: ITextureInfo;
  87794. metallicRoughnessTexture?: ITextureInfo;
  87795. }
  87796. /**
  87797. * Loader interface with additional members.
  87798. */
  87799. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  87800. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  87801. normalTexture?: IMaterialNormalTextureInfo;
  87802. occlusionTexture?: IMaterialOcclusionTextureInfo;
  87803. emissiveTexture?: ITextureInfo;
  87804. /** @hidden */
  87805. _data?: {
  87806. [babylonDrawMode: number]: {
  87807. babylonMaterial: Material;
  87808. babylonMeshes: AbstractMesh[];
  87809. promise: Promise<void>;
  87810. };
  87811. };
  87812. }
  87813. /**
  87814. * Loader interface with additional members.
  87815. */
  87816. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  87817. primitives: IMeshPrimitive[];
  87818. }
  87819. /**
  87820. * Loader interface with additional members.
  87821. */
  87822. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  87823. /** @hidden */
  87824. _instanceData?: {
  87825. babylonSourceMesh: Mesh;
  87826. promise: Promise<any>;
  87827. };
  87828. }
  87829. /**
  87830. * Loader interface with additional members.
  87831. */
  87832. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  87833. /**
  87834. * The parent glTF node.
  87835. */
  87836. parent?: INode;
  87837. /** @hidden */
  87838. _babylonTransformNode?: TransformNode;
  87839. /** @hidden */
  87840. _primitiveBabylonMeshes?: AbstractMesh[];
  87841. /** @hidden */
  87842. _babylonBones?: Bone[];
  87843. /** @hidden */
  87844. _numMorphTargets?: number;
  87845. }
  87846. /** @hidden */
  87847. export interface _ISamplerData {
  87848. noMipMaps: boolean;
  87849. samplingMode: number;
  87850. wrapU: number;
  87851. wrapV: number;
  87852. }
  87853. /**
  87854. * Loader interface with additional members.
  87855. */
  87856. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  87857. /** @hidden */
  87858. _data?: _ISamplerData;
  87859. }
  87860. /**
  87861. * Loader interface with additional members.
  87862. */
  87863. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  87864. }
  87865. /**
  87866. * Loader interface with additional members.
  87867. */
  87868. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  87869. /** @hidden */
  87870. _data?: {
  87871. babylonSkeleton: Skeleton;
  87872. promise: Promise<void>;
  87873. };
  87874. }
  87875. /**
  87876. * Loader interface with additional members.
  87877. */
  87878. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  87879. /** @hidden */
  87880. _textureInfo: ITextureInfo;
  87881. }
  87882. /**
  87883. * Loader interface with additional members.
  87884. */
  87885. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  87886. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  87887. nonColorData?: boolean;
  87888. }
  87889. /**
  87890. * Loader interface with additional members.
  87891. */
  87892. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  87893. accessors?: IAccessor[];
  87894. animations?: IAnimation[];
  87895. buffers?: IBuffer[];
  87896. bufferViews?: IBufferView[];
  87897. cameras?: ICamera[];
  87898. images?: IImage[];
  87899. materials?: IMaterial[];
  87900. meshes?: IMesh[];
  87901. nodes?: INode[];
  87902. samplers?: ISampler[];
  87903. scenes?: IScene[];
  87904. skins?: ISkin[];
  87905. textures?: ITexture[];
  87906. }
  87907. }
  87908. declare module BABYLON.GLTF2 {
  87909. /**
  87910. * Interface for a glTF loader extension.
  87911. */
  87912. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  87913. /**
  87914. * Called after the loader state changes to LOADING.
  87915. */
  87916. onLoading?(): void;
  87917. /**
  87918. * Called after the loader state changes to READY.
  87919. */
  87920. onReady?(): void;
  87921. /**
  87922. * Define this method to modify the default behavior when loading scenes.
  87923. * @param context The context when loading the asset
  87924. * @param scene The glTF scene property
  87925. * @returns A promise that resolves when the load is complete or null if not handled
  87926. */
  87927. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  87928. /**
  87929. * Define this method to modify the default behavior when loading nodes.
  87930. * @param context The context when loading the asset
  87931. * @param node The glTF node property
  87932. * @param assign A function called synchronously after parsing the glTF properties
  87933. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  87934. */
  87935. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87936. /**
  87937. * Define this method to modify the default behavior when loading cameras.
  87938. * @param context The context when loading the asset
  87939. * @param camera The glTF camera property
  87940. * @param assign A function called synchronously after parsing the glTF properties
  87941. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  87942. */
  87943. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  87944. /**
  87945. * @hidden
  87946. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  87947. * @param context The context when loading the asset
  87948. * @param primitive The glTF mesh primitive property
  87949. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  87950. */
  87951. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  87952. /**
  87953. * @hidden
  87954. * Define this method to modify the default behavior when loading data for mesh primitives.
  87955. * @param context The context when loading the asset
  87956. * @param name The mesh name when loading the asset
  87957. * @param node The glTF node when loading the asset
  87958. * @param mesh The glTF mesh when loading the asset
  87959. * @param primitive The glTF mesh primitive property
  87960. * @param assign A function called synchronously after parsing the glTF properties
  87961. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87962. */
  87963. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  87964. /**
  87965. * @hidden
  87966. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  87967. * @param context The context when loading the asset
  87968. * @param material The glTF material property
  87969. * @param assign A function called synchronously after parsing the glTF properties
  87970. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  87971. */
  87972. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  87973. /**
  87974. * Define this method to modify the default behavior when creating materials.
  87975. * @param context The context when loading the asset
  87976. * @param material The glTF material property
  87977. * @param babylonDrawMode The draw mode for the Babylon material
  87978. * @returns The Babylon material or null if not handled
  87979. */
  87980. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  87981. /**
  87982. * Define this method to modify the default behavior when loading material properties.
  87983. * @param context The context when loading the asset
  87984. * @param material The glTF material property
  87985. * @param babylonMaterial The Babylon material
  87986. * @returns A promise that resolves when the load is complete or null if not handled
  87987. */
  87988. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87989. /**
  87990. * Define this method to modify the default behavior when loading texture infos.
  87991. * @param context The context when loading the asset
  87992. * @param textureInfo The glTF texture info property
  87993. * @param assign A function called synchronously after parsing the glTF properties
  87994. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87995. */
  87996. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87997. /**
  87998. * @hidden
  87999. * Define this method to modify the default behavior when loading textures.
  88000. * @param context The context when loading the asset
  88001. * @param texture The glTF texture property
  88002. * @param assign A function called synchronously after parsing the glTF properties
  88003. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88004. */
  88005. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88006. /**
  88007. * Define this method to modify the default behavior when loading animations.
  88008. * @param context The context when loading the asset
  88009. * @param animation The glTF animation property
  88010. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  88011. */
  88012. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88013. /**
  88014. * @hidden
  88015. * Define this method to modify the default behavior when loading skins.
  88016. * @param context The context when loading the asset
  88017. * @param node The glTF node property
  88018. * @param skin The glTF skin property
  88019. * @returns A promise that resolves when the load is complete or null if not handled
  88020. */
  88021. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  88022. /**
  88023. * @hidden
  88024. * Define this method to modify the default behavior when loading uris.
  88025. * @param context The context when loading the asset
  88026. * @param property The glTF property associated with the uri
  88027. * @param uri The uri to load
  88028. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88029. */
  88030. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88031. /**
  88032. * Define this method to modify the default behavior when loading buffer views.
  88033. * @param context The context when loading the asset
  88034. * @param bufferView The glTF buffer view property
  88035. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88036. */
  88037. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88038. /**
  88039. * Define this method to modify the default behavior when loading buffers.
  88040. * @param context The context when loading the asset
  88041. * @param buffer The glTF buffer property
  88042. * @param byteOffset The byte offset to load
  88043. * @param byteLength The byte length to load
  88044. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88045. */
  88046. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88047. }
  88048. }
  88049. declare module BABYLON.GLTF2 {
  88050. /**
  88051. * Helper class for working with arrays when loading the glTF asset
  88052. */
  88053. export class ArrayItem {
  88054. /**
  88055. * Gets an item from the given array.
  88056. * @param context The context when loading the asset
  88057. * @param array The array to get the item from
  88058. * @param index The index to the array
  88059. * @returns The array item
  88060. */
  88061. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  88062. /**
  88063. * Assign an `index` field to each item of the given array.
  88064. * @param array The array of items
  88065. */
  88066. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  88067. }
  88068. /**
  88069. * The glTF 2.0 loader
  88070. */
  88071. export class GLTFLoader implements IGLTFLoader {
  88072. /** @hidden */
  88073. _completePromises: Promise<any>[];
  88074. /** @hidden */
  88075. _forAssetContainer: boolean;
  88076. /** Storage */
  88077. _babylonLights: Light[];
  88078. /** @hidden */
  88079. _disableInstancedMesh: number;
  88080. private _disposed;
  88081. private _parent;
  88082. private _state;
  88083. private _extensions;
  88084. private _rootUrl;
  88085. private _fileName;
  88086. private _uniqueRootUrl;
  88087. private _gltf;
  88088. private _bin;
  88089. private _babylonScene;
  88090. private _rootBabylonMesh;
  88091. private _defaultBabylonMaterialData;
  88092. private static _RegisteredExtensions;
  88093. /**
  88094. * The default glTF sampler.
  88095. */
  88096. static readonly DefaultSampler: ISampler;
  88097. /**
  88098. * Registers a loader extension.
  88099. * @param name The name of the loader extension.
  88100. * @param factory The factory function that creates the loader extension.
  88101. */
  88102. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  88103. /**
  88104. * Unregisters a loader extension.
  88105. * @param name The name of the loader extension.
  88106. * @returns A boolean indicating whether the extension has been unregistered
  88107. */
  88108. static UnregisterExtension(name: string): boolean;
  88109. /**
  88110. * The loader state.
  88111. */
  88112. get state(): Nullable<GLTFLoaderState>;
  88113. /**
  88114. * The object that represents the glTF JSON.
  88115. */
  88116. get gltf(): IGLTF;
  88117. /**
  88118. * The BIN chunk of a binary glTF.
  88119. */
  88120. get bin(): Nullable<IDataBuffer>;
  88121. /**
  88122. * The parent file loader.
  88123. */
  88124. get parent(): GLTFFileLoader;
  88125. /**
  88126. * The Babylon scene when loading the asset.
  88127. */
  88128. get babylonScene(): Scene;
  88129. /**
  88130. * The root Babylon mesh when loading the asset.
  88131. */
  88132. get rootBabylonMesh(): Mesh;
  88133. /** @hidden */
  88134. constructor(parent: GLTFFileLoader);
  88135. /** @hidden */
  88136. dispose(): void;
  88137. /** @hidden */
  88138. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88139. /** @hidden */
  88140. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88141. private _loadAsync;
  88142. private _loadData;
  88143. private _setupData;
  88144. private _loadExtensions;
  88145. private _checkExtensions;
  88146. private _setState;
  88147. private _createRootNode;
  88148. /**
  88149. * Loads a glTF scene.
  88150. * @param context The context when loading the asset
  88151. * @param scene The glTF scene property
  88152. * @returns A promise that resolves when the load is complete
  88153. */
  88154. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  88155. private _forEachPrimitive;
  88156. private _getGeometries;
  88157. private _getMeshes;
  88158. private _getTransformNodes;
  88159. private _getSkeletons;
  88160. private _getAnimationGroups;
  88161. private _startAnimations;
  88162. /**
  88163. * Loads a glTF node.
  88164. * @param context The context when loading the asset
  88165. * @param node The glTF node property
  88166. * @param assign A function called synchronously after parsing the glTF properties
  88167. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  88168. */
  88169. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  88170. private _loadMeshAsync;
  88171. /**
  88172. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  88173. * @param context The context when loading the asset
  88174. * @param name The mesh name when loading the asset
  88175. * @param node The glTF node when loading the asset
  88176. * @param mesh The glTF mesh when loading the asset
  88177. * @param primitive The glTF mesh primitive property
  88178. * @param assign A function called synchronously after parsing the glTF properties
  88179. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88180. */
  88181. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  88182. private _loadVertexDataAsync;
  88183. private _createMorphTargets;
  88184. private _loadMorphTargetsAsync;
  88185. private _loadMorphTargetVertexDataAsync;
  88186. private static _LoadTransform;
  88187. private _loadSkinAsync;
  88188. private _loadBones;
  88189. private _loadBone;
  88190. private _loadSkinInverseBindMatricesDataAsync;
  88191. private _updateBoneMatrices;
  88192. private _getNodeMatrix;
  88193. /**
  88194. * Loads a glTF camera.
  88195. * @param context The context when loading the asset
  88196. * @param camera The glTF camera property
  88197. * @param assign A function called synchronously after parsing the glTF properties
  88198. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  88199. */
  88200. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  88201. private _loadAnimationsAsync;
  88202. /**
  88203. * Loads a glTF animation.
  88204. * @param context The context when loading the asset
  88205. * @param animation The glTF animation property
  88206. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  88207. */
  88208. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  88209. /**
  88210. * @hidden Loads a glTF animation channel.
  88211. * @param context The context when loading the asset
  88212. * @param animationContext The context of the animation when loading the asset
  88213. * @param animation The glTF animation property
  88214. * @param channel The glTF animation channel property
  88215. * @param babylonAnimationGroup The babylon animation group property
  88216. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  88217. * @returns A void promise when the channel load is complete
  88218. */
  88219. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  88220. private _loadAnimationSamplerAsync;
  88221. /**
  88222. * Loads a glTF buffer.
  88223. * @param context The context when loading the asset
  88224. * @param buffer The glTF buffer property
  88225. * @param byteOffset The byte offset to use
  88226. * @param byteLength The byte length to use
  88227. * @returns A promise that resolves with the loaded data when the load is complete
  88228. */
  88229. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  88230. /**
  88231. * Loads a glTF buffer view.
  88232. * @param context The context when loading the asset
  88233. * @param bufferView The glTF buffer view property
  88234. * @returns A promise that resolves with the loaded data when the load is complete
  88235. */
  88236. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  88237. private _loadAccessorAsync;
  88238. /** @hidden */
  88239. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  88240. private _loadIndicesAccessorAsync;
  88241. private _loadVertexBufferViewAsync;
  88242. private _loadVertexAccessorAsync;
  88243. private _loadMaterialMetallicRoughnessPropertiesAsync;
  88244. /** @hidden */
  88245. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  88246. private _createDefaultMaterial;
  88247. /**
  88248. * Creates a Babylon material from a glTF material.
  88249. * @param context The context when loading the asset
  88250. * @param material The glTF material property
  88251. * @param babylonDrawMode The draw mode for the Babylon material
  88252. * @returns The Babylon material
  88253. */
  88254. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  88255. /**
  88256. * Loads properties from a glTF material into a Babylon material.
  88257. * @param context The context when loading the asset
  88258. * @param material The glTF material property
  88259. * @param babylonMaterial The Babylon material
  88260. * @returns A promise that resolves when the load is complete
  88261. */
  88262. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88263. /**
  88264. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  88265. * @param context The context when loading the asset
  88266. * @param material The glTF material property
  88267. * @param babylonMaterial The Babylon material
  88268. * @returns A promise that resolves when the load is complete
  88269. */
  88270. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88271. /**
  88272. * Loads the alpha properties from a glTF material into a Babylon material.
  88273. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  88274. * @param context The context when loading the asset
  88275. * @param material The glTF material property
  88276. * @param babylonMaterial The Babylon material
  88277. */
  88278. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  88279. /**
  88280. * Loads a glTF texture info.
  88281. * @param context The context when loading the asset
  88282. * @param textureInfo The glTF texture info property
  88283. * @param assign A function called synchronously after parsing the glTF properties
  88284. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  88285. */
  88286. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88287. /** @hidden */
  88288. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88289. /** @hidden */
  88290. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  88291. private _loadSampler;
  88292. /**
  88293. * Loads a glTF image.
  88294. * @param context The context when loading the asset
  88295. * @param image The glTF image property
  88296. * @returns A promise that resolves with the loaded data when the load is complete
  88297. */
  88298. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  88299. /**
  88300. * Loads a glTF uri.
  88301. * @param context The context when loading the asset
  88302. * @param property The glTF property associated with the uri
  88303. * @param uri The base64 or relative uri
  88304. * @returns A promise that resolves with the loaded data when the load is complete
  88305. */
  88306. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  88307. /**
  88308. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  88309. * @param babylonObject the Babylon object with metadata
  88310. * @param pointer the JSON pointer
  88311. */
  88312. static AddPointerMetadata(babylonObject: {
  88313. metadata: any;
  88314. }, pointer: string): void;
  88315. private static _GetTextureWrapMode;
  88316. private static _GetTextureSamplingMode;
  88317. private static _GetTypedArrayConstructor;
  88318. private static _GetTypedArray;
  88319. private static _GetNumComponents;
  88320. private static _ValidateUri;
  88321. /** @hidden */
  88322. static _GetDrawMode(context: string, mode: number | undefined): number;
  88323. private _compileMaterialsAsync;
  88324. private _compileShadowGeneratorsAsync;
  88325. private _forEachExtensions;
  88326. private _applyExtensions;
  88327. private _extensionsOnLoading;
  88328. private _extensionsOnReady;
  88329. private _extensionsLoadSceneAsync;
  88330. private _extensionsLoadNodeAsync;
  88331. private _extensionsLoadCameraAsync;
  88332. private _extensionsLoadVertexDataAsync;
  88333. private _extensionsLoadMeshPrimitiveAsync;
  88334. private _extensionsLoadMaterialAsync;
  88335. private _extensionsCreateMaterial;
  88336. private _extensionsLoadMaterialPropertiesAsync;
  88337. private _extensionsLoadTextureInfoAsync;
  88338. private _extensionsLoadTextureAsync;
  88339. private _extensionsLoadAnimationAsync;
  88340. private _extensionsLoadSkinAsync;
  88341. private _extensionsLoadUriAsync;
  88342. private _extensionsLoadBufferViewAsync;
  88343. private _extensionsLoadBufferAsync;
  88344. /**
  88345. * Helper method called by a loader extension to load an glTF extension.
  88346. * @param context The context when loading the asset
  88347. * @param property The glTF property to load the extension from
  88348. * @param extensionName The name of the extension to load
  88349. * @param actionAsync The action to run
  88350. * @returns The promise returned by actionAsync or null if the extension does not exist
  88351. */
  88352. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88353. /**
  88354. * Helper method called by a loader extension to load a glTF extra.
  88355. * @param context The context when loading the asset
  88356. * @param property The glTF property to load the extra from
  88357. * @param extensionName The name of the extension to load
  88358. * @param actionAsync The action to run
  88359. * @returns The promise returned by actionAsync or null if the extra does not exist
  88360. */
  88361. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88362. /**
  88363. * Checks for presence of an extension.
  88364. * @param name The name of the extension to check
  88365. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  88366. */
  88367. isExtensionUsed(name: string): boolean;
  88368. /**
  88369. * Increments the indentation level and logs a message.
  88370. * @param message The message to log
  88371. */
  88372. logOpen(message: string): void;
  88373. /**
  88374. * Decrements the indentation level.
  88375. */
  88376. logClose(): void;
  88377. /**
  88378. * Logs a message
  88379. * @param message The message to log
  88380. */
  88381. log(message: string): void;
  88382. /**
  88383. * Starts a performance counter.
  88384. * @param counterName The name of the performance counter
  88385. */
  88386. startPerformanceCounter(counterName: string): void;
  88387. /**
  88388. * Ends a performance counter.
  88389. * @param counterName The name of the performance counter
  88390. */
  88391. endPerformanceCounter(counterName: string): void;
  88392. }
  88393. }
  88394. declare module BABYLON.GLTF2.Loader.Extensions {
  88395. /** @hidden */
  88396. interface IEXTLightsImageBased_LightImageBased {
  88397. _babylonTexture?: BaseTexture;
  88398. _loaded?: Promise<void>;
  88399. }
  88400. /**
  88401. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  88402. */
  88403. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  88404. /**
  88405. * The name of this extension.
  88406. */
  88407. readonly name: string;
  88408. /**
  88409. * Defines whether this extension is enabled.
  88410. */
  88411. enabled: boolean;
  88412. private _loader;
  88413. private _lights?;
  88414. /** @hidden */
  88415. constructor(loader: GLTFLoader);
  88416. /** @hidden */
  88417. dispose(): void;
  88418. /** @hidden */
  88419. onLoading(): void;
  88420. /** @hidden */
  88421. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88422. private _loadLightAsync;
  88423. }
  88424. }
  88425. declare module BABYLON.GLTF2.Loader.Extensions {
  88426. /**
  88427. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  88428. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  88429. * !!! Experimental Extension Subject to Changes !!!
  88430. */
  88431. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  88432. /**
  88433. * The name of this extension.
  88434. */
  88435. readonly name: string;
  88436. /**
  88437. * Defines whether this extension is enabled.
  88438. */
  88439. enabled: boolean;
  88440. private _loader;
  88441. /** @hidden */
  88442. constructor(loader: GLTFLoader);
  88443. /** @hidden */
  88444. dispose(): void;
  88445. /** @hidden */
  88446. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88447. }
  88448. }
  88449. declare module BABYLON.GLTF2.Loader.Extensions {
  88450. /**
  88451. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  88452. *
  88453. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  88454. */
  88455. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  88456. /**
  88457. * The name of this extension.
  88458. */
  88459. readonly name: string;
  88460. /**
  88461. * Defines whether this extension is enabled.
  88462. */
  88463. enabled: boolean;
  88464. /**
  88465. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  88466. */
  88467. static DecoderPath: string;
  88468. private _loader;
  88469. private _decoderPromise?;
  88470. /** @hidden */
  88471. constructor(loader: GLTFLoader);
  88472. /** @hidden */
  88473. dispose(): void;
  88474. /** @hidden */
  88475. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88476. }
  88477. }
  88478. declare module BABYLON.GLTF2.Loader.Extensions {
  88479. /**
  88480. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  88481. */
  88482. export class EXT_texture_webp implements IGLTFLoaderExtension {
  88483. /** The name of this extension. */
  88484. readonly name: string;
  88485. /** Defines whether this extension is enabled. */
  88486. enabled: boolean;
  88487. private _loader;
  88488. /** @hidden */
  88489. constructor(loader: GLTFLoader);
  88490. /** @hidden */
  88491. dispose(): void;
  88492. /** @hidden */
  88493. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88494. }
  88495. }
  88496. declare module BABYLON.GLTF2.Loader.Extensions {
  88497. /**
  88498. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  88499. */
  88500. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  88501. /**
  88502. * The name of this extension.
  88503. */
  88504. readonly name: string;
  88505. /**
  88506. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  88507. */
  88508. dracoCompression?: DracoCompression;
  88509. /**
  88510. * Defines whether this extension is enabled.
  88511. */
  88512. enabled: boolean;
  88513. private _loader;
  88514. /** @hidden */
  88515. constructor(loader: GLTFLoader);
  88516. /** @hidden */
  88517. dispose(): void;
  88518. /** @hidden */
  88519. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88520. }
  88521. }
  88522. declare module BABYLON.GLTF2.Loader.Extensions {
  88523. /**
  88524. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  88525. */
  88526. export class KHR_lights implements IGLTFLoaderExtension {
  88527. /**
  88528. * The name of this extension.
  88529. */
  88530. readonly name: string;
  88531. /**
  88532. * Defines whether this extension is enabled.
  88533. */
  88534. enabled: boolean;
  88535. private _loader;
  88536. private _lights?;
  88537. /** @hidden */
  88538. constructor(loader: GLTFLoader);
  88539. /** @hidden */
  88540. dispose(): void;
  88541. /** @hidden */
  88542. onLoading(): void;
  88543. /** @hidden */
  88544. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88545. }
  88546. }
  88547. declare module BABYLON.GLTF2.Loader.Extensions {
  88548. /**
  88549. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  88550. */
  88551. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  88552. /**
  88553. * The name of this extension.
  88554. */
  88555. readonly name: string;
  88556. /**
  88557. * Defines whether this extension is enabled.
  88558. */
  88559. enabled: boolean;
  88560. /**
  88561. * Defines a number that determines the order the extensions are applied.
  88562. */
  88563. order: number;
  88564. private _loader;
  88565. /** @hidden */
  88566. constructor(loader: GLTFLoader);
  88567. /** @hidden */
  88568. dispose(): void;
  88569. /** @hidden */
  88570. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88571. private _loadSpecularGlossinessPropertiesAsync;
  88572. }
  88573. }
  88574. declare module BABYLON.GLTF2.Loader.Extensions {
  88575. /**
  88576. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  88577. */
  88578. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  88579. /**
  88580. * The name of this extension.
  88581. */
  88582. readonly name: string;
  88583. /**
  88584. * Defines whether this extension is enabled.
  88585. */
  88586. enabled: boolean;
  88587. /**
  88588. * Defines a number that determines the order the extensions are applied.
  88589. */
  88590. order: number;
  88591. private _loader;
  88592. /** @hidden */
  88593. constructor(loader: GLTFLoader);
  88594. /** @hidden */
  88595. dispose(): void;
  88596. /** @hidden */
  88597. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88598. private _loadUnlitPropertiesAsync;
  88599. }
  88600. }
  88601. declare module BABYLON.GLTF2.Loader.Extensions {
  88602. /**
  88603. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  88604. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  88605. */
  88606. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  88607. /**
  88608. * The name of this extension.
  88609. */
  88610. readonly name: string;
  88611. /**
  88612. * Defines whether this extension is enabled.
  88613. */
  88614. enabled: boolean;
  88615. /**
  88616. * Defines a number that determines the order the extensions are applied.
  88617. */
  88618. order: number;
  88619. private _loader;
  88620. /** @hidden */
  88621. constructor(loader: GLTFLoader);
  88622. /** @hidden */
  88623. dispose(): void;
  88624. /** @hidden */
  88625. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88626. private _loadClearCoatPropertiesAsync;
  88627. }
  88628. }
  88629. declare module BABYLON.GLTF2.Loader.Extensions {
  88630. /**
  88631. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  88632. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  88633. * !!! Experimental Extension Subject to Changes !!!
  88634. */
  88635. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  88636. /**
  88637. * The name of this extension.
  88638. */
  88639. readonly name: string;
  88640. /**
  88641. * Defines whether this extension is enabled.
  88642. */
  88643. enabled: boolean;
  88644. /**
  88645. * Defines a number that determines the order the extensions are applied.
  88646. */
  88647. order: number;
  88648. private _loader;
  88649. /** @hidden */
  88650. constructor(loader: GLTFLoader);
  88651. /** @hidden */
  88652. dispose(): void;
  88653. /** @hidden */
  88654. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88655. private _loadSheenPropertiesAsync;
  88656. }
  88657. }
  88658. declare module BABYLON.GLTF2.Loader.Extensions {
  88659. /**
  88660. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  88661. * !!! Experimental Extension Subject to Changes !!!
  88662. */
  88663. export class KHR_materials_specular implements IGLTFLoaderExtension {
  88664. /**
  88665. * The name of this extension.
  88666. */
  88667. readonly name: string;
  88668. /**
  88669. * Defines whether this extension is enabled.
  88670. */
  88671. enabled: boolean;
  88672. /**
  88673. * Defines a number that determines the order the extensions are applied.
  88674. */
  88675. order: number;
  88676. private _loader;
  88677. /** @hidden */
  88678. constructor(loader: GLTFLoader);
  88679. /** @hidden */
  88680. dispose(): void;
  88681. /** @hidden */
  88682. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88683. private _loadSpecularPropertiesAsync;
  88684. }
  88685. }
  88686. declare module BABYLON.GLTF2.Loader.Extensions {
  88687. /**
  88688. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  88689. * !!! Experimental Extension Subject to Changes !!!
  88690. */
  88691. export class KHR_materials_ior implements IGLTFLoaderExtension {
  88692. /**
  88693. * Default ior Value from the spec.
  88694. */
  88695. private static readonly _DEFAULT_IOR;
  88696. /**
  88697. * The name of this extension.
  88698. */
  88699. readonly name: string;
  88700. /**
  88701. * Defines whether this extension is enabled.
  88702. */
  88703. enabled: boolean;
  88704. /**
  88705. * Defines a number that determines the order the extensions are applied.
  88706. */
  88707. order: number;
  88708. private _loader;
  88709. /** @hidden */
  88710. constructor(loader: GLTFLoader);
  88711. /** @hidden */
  88712. dispose(): void;
  88713. /** @hidden */
  88714. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88715. private _loadIorPropertiesAsync;
  88716. }
  88717. }
  88718. declare module BABYLON.GLTF2.Loader.Extensions {
  88719. /**
  88720. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  88721. */
  88722. export class KHR_materials_variants implements IGLTFLoaderExtension {
  88723. /**
  88724. * The name of this extension.
  88725. */
  88726. readonly name: string;
  88727. /**
  88728. * Defines whether this extension is enabled.
  88729. */
  88730. enabled: boolean;
  88731. private _loader;
  88732. private _variants?;
  88733. /** @hidden */
  88734. constructor(loader: GLTFLoader);
  88735. /** @hidden */
  88736. dispose(): void;
  88737. /**
  88738. * Gets the list of available variant names for this asset.
  88739. * @param rootMesh The glTF root mesh
  88740. * @returns the list of all the variant names for this model
  88741. */
  88742. static GetAvailableVariants(rootMesh: Mesh): string[];
  88743. /**
  88744. * Gets the list of available variant names for this asset.
  88745. * @param rootMesh The glTF root mesh
  88746. * @returns the list of all the variant names for this model
  88747. */
  88748. getAvailableVariants(rootMesh: Mesh): string[];
  88749. /**
  88750. * Select a variant given a variant name or a list of variant names.
  88751. * @param rootMesh The glTF root mesh
  88752. * @param variantName The variant name(s) to select.
  88753. */
  88754. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88755. /**
  88756. * Select a variant given a variant name or a list of variant names.
  88757. * @param rootMesh The glTF root mesh
  88758. * @param variantName The variant name(s) to select.
  88759. */
  88760. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88761. /**
  88762. * Reset back to the original before selecting a variant.
  88763. * @param rootMesh The glTF root mesh
  88764. */
  88765. static Reset(rootMesh: Mesh): void;
  88766. /**
  88767. * Reset back to the original before selecting a variant.
  88768. * @param rootMesh The glTF root mesh
  88769. */
  88770. reset(rootMesh: Mesh): void;
  88771. /**
  88772. * Gets the last selected variant name(s) or null if original.
  88773. * @param rootMesh The glTF root mesh
  88774. * @returns The selected variant name(s).
  88775. */
  88776. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88777. /**
  88778. * Gets the last selected variant name(s) or null if original.
  88779. * @param rootMesh The glTF root mesh
  88780. * @returns The selected variant name(s).
  88781. */
  88782. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88783. private static _GetExtensionMetadata;
  88784. /** @hidden */
  88785. onLoading(): void;
  88786. /** @hidden */
  88787. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88788. }
  88789. }
  88790. declare module BABYLON.GLTF2.Loader.Extensions {
  88791. /**
  88792. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  88793. */
  88794. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  88795. /**
  88796. * The name of this extension.
  88797. */
  88798. readonly name: string;
  88799. /**
  88800. * Defines whether this extension is enabled.
  88801. */
  88802. enabled: boolean;
  88803. /**
  88804. * Defines a number that determines the order the extensions are applied.
  88805. */
  88806. order: number;
  88807. private _loader;
  88808. /** @hidden */
  88809. constructor(loader: GLTFLoader);
  88810. /** @hidden */
  88811. dispose(): void;
  88812. /** @hidden */
  88813. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88814. private _loadTransparentPropertiesAsync;
  88815. }
  88816. }
  88817. declare module BABYLON.GLTF2.Loader.Extensions {
  88818. /**
  88819. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  88820. * !!! Experimental Extension Subject to Changes !!!
  88821. */
  88822. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  88823. /**
  88824. * The name of this extension.
  88825. */
  88826. readonly name: string;
  88827. /**
  88828. * Defines whether this extension is enabled.
  88829. */
  88830. enabled: boolean;
  88831. /**
  88832. * Defines a number that determines the order the extensions are applied.
  88833. */
  88834. order: number;
  88835. private _loader;
  88836. /** @hidden */
  88837. constructor(loader: GLTFLoader);
  88838. /** @hidden */
  88839. dispose(): void;
  88840. /** @hidden */
  88841. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88842. private _loadTranslucentPropertiesAsync;
  88843. }
  88844. }
  88845. declare module BABYLON.GLTF2.Loader.Extensions {
  88846. /**
  88847. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  88848. */
  88849. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  88850. /**
  88851. * The name of this extension.
  88852. */
  88853. readonly name: string;
  88854. /**
  88855. * Defines whether this extension is enabled.
  88856. */
  88857. enabled: boolean;
  88858. /** @hidden */
  88859. constructor(loader: GLTFLoader);
  88860. /** @hidden */
  88861. dispose(): void;
  88862. }
  88863. }
  88864. declare module BABYLON.GLTF2.Loader.Extensions {
  88865. /**
  88866. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  88867. * !!! Experimental Extension Subject to Changes !!!
  88868. */
  88869. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  88870. /** The name of this extension. */
  88871. readonly name: string;
  88872. /** Defines whether this extension is enabled. */
  88873. enabled: boolean;
  88874. private _loader;
  88875. /** @hidden */
  88876. constructor(loader: GLTFLoader);
  88877. /** @hidden */
  88878. dispose(): void;
  88879. /** @hidden */
  88880. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88881. }
  88882. }
  88883. declare module BABYLON.GLTF2.Loader.Extensions {
  88884. /**
  88885. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  88886. */
  88887. export class KHR_texture_transform implements IGLTFLoaderExtension {
  88888. /**
  88889. * The name of this extension.
  88890. */
  88891. readonly name: string;
  88892. /**
  88893. * Defines whether this extension is enabled.
  88894. */
  88895. enabled: boolean;
  88896. private _loader;
  88897. /** @hidden */
  88898. constructor(loader: GLTFLoader);
  88899. /** @hidden */
  88900. dispose(): void;
  88901. /** @hidden */
  88902. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88903. }
  88904. }
  88905. declare module BABYLON.GLTF2.Loader.Extensions {
  88906. /**
  88907. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1893)
  88908. * !!! Experimental Extension Subject to Changes !!!
  88909. */
  88910. export class KHR_xmp_json_ld implements IGLTFLoaderExtension {
  88911. /**
  88912. * The name of this extension.
  88913. */
  88914. readonly name: string;
  88915. /**
  88916. * Defines whether this extension is enabled.
  88917. */
  88918. enabled: boolean;
  88919. /**
  88920. * Defines a number that determines the order the extensions are applied.
  88921. */
  88922. order: number;
  88923. private _loader;
  88924. /** @hidden */
  88925. constructor(loader: GLTFLoader);
  88926. /** @hidden */
  88927. dispose(): void;
  88928. /**
  88929. * Called after the loader state changes to LOADING.
  88930. */
  88931. onLoading(): void;
  88932. }
  88933. }
  88934. declare module BABYLON.GLTF2.Loader.Extensions {
  88935. /**
  88936. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  88937. */
  88938. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  88939. /**
  88940. * The name of this extension.
  88941. */
  88942. readonly name: string;
  88943. /**
  88944. * Defines whether this extension is enabled.
  88945. */
  88946. enabled: boolean;
  88947. private _loader;
  88948. private _clips;
  88949. private _emitters;
  88950. /** @hidden */
  88951. constructor(loader: GLTFLoader);
  88952. /** @hidden */
  88953. dispose(): void;
  88954. /** @hidden */
  88955. onLoading(): void;
  88956. /** @hidden */
  88957. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88958. /** @hidden */
  88959. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88960. /** @hidden */
  88961. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88962. private _loadClipAsync;
  88963. private _loadEmitterAsync;
  88964. private _getEventAction;
  88965. private _loadAnimationEventAsync;
  88966. }
  88967. }
  88968. declare module BABYLON.GLTF2.Loader.Extensions {
  88969. /**
  88970. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  88971. */
  88972. export class MSFT_lod implements IGLTFLoaderExtension {
  88973. /**
  88974. * The name of this extension.
  88975. */
  88976. readonly name: string;
  88977. /**
  88978. * Defines whether this extension is enabled.
  88979. */
  88980. enabled: boolean;
  88981. /**
  88982. * Defines a number that determines the order the extensions are applied.
  88983. */
  88984. order: number;
  88985. /**
  88986. * Maximum number of LODs to load, starting from the lowest LOD.
  88987. */
  88988. maxLODsToLoad: number;
  88989. /**
  88990. * Observable raised when all node LODs of one level are loaded.
  88991. * The event data is the index of the loaded LOD starting from zero.
  88992. * Dispose the loader to cancel the loading of the next level of LODs.
  88993. */
  88994. onNodeLODsLoadedObservable: Observable<number>;
  88995. /**
  88996. * Observable raised when all material LODs of one level are loaded.
  88997. * The event data is the index of the loaded LOD starting from zero.
  88998. * Dispose the loader to cancel the loading of the next level of LODs.
  88999. */
  89000. onMaterialLODsLoadedObservable: Observable<number>;
  89001. private _loader;
  89002. private _bufferLODs;
  89003. private _nodeIndexLOD;
  89004. private _nodeSignalLODs;
  89005. private _nodePromiseLODs;
  89006. private _nodeBufferLODs;
  89007. private _materialIndexLOD;
  89008. private _materialSignalLODs;
  89009. private _materialPromiseLODs;
  89010. private _materialBufferLODs;
  89011. /** @hidden */
  89012. constructor(loader: GLTFLoader);
  89013. /** @hidden */
  89014. dispose(): void;
  89015. /** @hidden */
  89016. onReady(): void;
  89017. /** @hidden */
  89018. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89019. /** @hidden */
  89020. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89021. /** @hidden */
  89022. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  89023. /** @hidden */
  89024. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  89025. /** @hidden */
  89026. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  89027. private _loadBufferLOD;
  89028. /**
  89029. * Gets an array of LOD properties from lowest to highest.
  89030. */
  89031. private _getLODs;
  89032. private _disposeTransformNode;
  89033. private _disposeMaterials;
  89034. }
  89035. }
  89036. declare module BABYLON.GLTF2.Loader.Extensions {
  89037. /** @hidden */
  89038. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  89039. readonly name: string;
  89040. enabled: boolean;
  89041. private _loader;
  89042. constructor(loader: GLTFLoader);
  89043. dispose(): void;
  89044. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89045. }
  89046. }
  89047. declare module BABYLON.GLTF2.Loader.Extensions {
  89048. /** @hidden */
  89049. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  89050. readonly name: string;
  89051. enabled: boolean;
  89052. private _loader;
  89053. constructor(loader: GLTFLoader);
  89054. dispose(): void;
  89055. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89056. }
  89057. }
  89058. declare module BABYLON.GLTF2.Loader.Extensions {
  89059. /**
  89060. * Store glTF extras (if present) in BJS objects' metadata
  89061. */
  89062. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  89063. /**
  89064. * The name of this extension.
  89065. */
  89066. readonly name: string;
  89067. /**
  89068. * Defines whether this extension is enabled.
  89069. */
  89070. enabled: boolean;
  89071. private _loader;
  89072. private _assignExtras;
  89073. /** @hidden */
  89074. constructor(loader: GLTFLoader);
  89075. /** @hidden */
  89076. dispose(): void;
  89077. /** @hidden */
  89078. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89079. /** @hidden */
  89080. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  89081. /** @hidden */
  89082. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  89083. }
  89084. }
  89085. declare module BABYLON {
  89086. /**
  89087. * Class reading and parsing the MTL file bundled with the obj file.
  89088. */
  89089. export class MTLFileLoader {
  89090. /**
  89091. * Invert Y-Axis of referenced textures on load
  89092. */
  89093. static INVERT_TEXTURE_Y: boolean;
  89094. /**
  89095. * All material loaded from the mtl will be set here
  89096. */
  89097. materials: StandardMaterial[];
  89098. /**
  89099. * This function will read the mtl file and create each material described inside
  89100. * This function could be improve by adding :
  89101. * -some component missing (Ni, Tf...)
  89102. * -including the specific options available
  89103. *
  89104. * @param scene defines the scene the material will be created in
  89105. * @param data defines the mtl data to parse
  89106. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  89107. * @param forAssetContainer defines if the material should be registered in the scene
  89108. */
  89109. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  89110. /**
  89111. * Gets the texture for the material.
  89112. *
  89113. * If the material is imported from input file,
  89114. * We sanitize the url to ensure it takes the textre from aside the material.
  89115. *
  89116. * @param rootUrl The root url to load from
  89117. * @param value The value stored in the mtl
  89118. * @return The Texture
  89119. */
  89120. private static _getTexture;
  89121. }
  89122. }
  89123. declare module BABYLON {
  89124. /**
  89125. * Options for loading OBJ/MTL files
  89126. */
  89127. type MeshLoadOptions = {
  89128. /**
  89129. * Defines if UVs are optimized by default during load.
  89130. */
  89131. OptimizeWithUV: boolean;
  89132. /**
  89133. * Defines custom scaling of UV coordinates of loaded meshes.
  89134. */
  89135. UVScaling: Vector2;
  89136. /**
  89137. * Invert model on y-axis (does a model scaling inversion)
  89138. */
  89139. InvertY: boolean;
  89140. /**
  89141. * Invert Y-Axis of referenced textures on load
  89142. */
  89143. InvertTextureY: boolean;
  89144. /**
  89145. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89146. */
  89147. ImportVertexColors: boolean;
  89148. /**
  89149. * Compute the normals for the model, even if normals are present in the file.
  89150. */
  89151. ComputeNormals: boolean;
  89152. /**
  89153. * Optimize the normals for the model. Lighting can be uneven if you use OptimizeWithUV = true because new vertices can be created for the same location if they pertain to different faces.
  89154. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89155. */
  89156. OptimizeNormals: boolean;
  89157. /**
  89158. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89159. */
  89160. SkipMaterials: boolean;
  89161. /**
  89162. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89163. */
  89164. MaterialLoadingFailsSilently: boolean;
  89165. };
  89166. /**
  89167. * OBJ file type loader.
  89168. * This is a babylon scene loader plugin.
  89169. */
  89170. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  89171. /**
  89172. * Defines if UVs are optimized by default during load.
  89173. */
  89174. static OPTIMIZE_WITH_UV: boolean;
  89175. /**
  89176. * Invert model on y-axis (does a model scaling inversion)
  89177. */
  89178. static INVERT_Y: boolean;
  89179. /**
  89180. * Invert Y-Axis of referenced textures on load
  89181. */
  89182. static get INVERT_TEXTURE_Y(): boolean;
  89183. static set INVERT_TEXTURE_Y(value: boolean);
  89184. /**
  89185. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89186. */
  89187. static IMPORT_VERTEX_COLORS: boolean;
  89188. /**
  89189. * Compute the normals for the model, even if normals are present in the file.
  89190. */
  89191. static COMPUTE_NORMALS: boolean;
  89192. /**
  89193. * Optimize the normals for the model. Lighting can be uneven if you use OptimizeWithUV = true because new vertices can be created for the same location if they pertain to different faces.
  89194. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89195. */
  89196. static OPTIMIZE_NORMALS: boolean;
  89197. /**
  89198. * Defines custom scaling of UV coordinates of loaded meshes.
  89199. */
  89200. static UV_SCALING: Vector2;
  89201. /**
  89202. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89203. */
  89204. static SKIP_MATERIALS: boolean;
  89205. /**
  89206. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89207. *
  89208. * Defaults to true for backwards compatibility.
  89209. */
  89210. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  89211. /**
  89212. * Defines the name of the plugin.
  89213. */
  89214. name: string;
  89215. /**
  89216. * Defines the extension the plugin is able to load.
  89217. */
  89218. extensions: string;
  89219. /** @hidden */
  89220. obj: RegExp;
  89221. /** @hidden */
  89222. group: RegExp;
  89223. /** @hidden */
  89224. mtllib: RegExp;
  89225. /** @hidden */
  89226. usemtl: RegExp;
  89227. /** @hidden */
  89228. smooth: RegExp;
  89229. /** @hidden */
  89230. vertexPattern: RegExp;
  89231. /** @hidden */
  89232. normalPattern: RegExp;
  89233. /** @hidden */
  89234. uvPattern: RegExp;
  89235. /** @hidden */
  89236. facePattern1: RegExp;
  89237. /** @hidden */
  89238. facePattern2: RegExp;
  89239. /** @hidden */
  89240. facePattern3: RegExp;
  89241. /** @hidden */
  89242. facePattern4: RegExp;
  89243. /** @hidden */
  89244. facePattern5: RegExp;
  89245. private _forAssetContainer;
  89246. private _meshLoadOptions;
  89247. /**
  89248. * Creates loader for .OBJ files
  89249. *
  89250. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  89251. */
  89252. constructor(meshLoadOptions?: MeshLoadOptions);
  89253. private static get currentMeshLoadOptions();
  89254. /**
  89255. * Calls synchronously the MTL file attached to this obj.
  89256. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  89257. * Without this function materials are not displayed in the first frame (but displayed after).
  89258. * In consequence it is impossible to get material information in your HTML file
  89259. *
  89260. * @param url The URL of the MTL file
  89261. * @param rootUrl
  89262. * @param onSuccess Callback function to be called when the MTL file is loaded
  89263. * @private
  89264. */
  89265. private _loadMTL;
  89266. /**
  89267. * Instantiates a OBJ file loader plugin.
  89268. * @returns the created plugin
  89269. */
  89270. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  89271. /**
  89272. * If the data string can be loaded directly.
  89273. *
  89274. * @param data string containing the file data
  89275. * @returns if the data can be loaded directly
  89276. */
  89277. canDirectLoad(data: string): boolean;
  89278. /**
  89279. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  89280. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  89281. * @param scene the scene the meshes should be added to
  89282. * @param data the OBJ data to load
  89283. * @param rootUrl root url to load from
  89284. * @param onProgress event that fires when loading progress has occured
  89285. * @param fileName Defines the name of the file to load
  89286. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  89287. */
  89288. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  89289. /**
  89290. * Imports all objects from the loaded OBJ data and adds them to the scene
  89291. * @param scene the scene the objects should be added to
  89292. * @param data the OBJ data to load
  89293. * @param rootUrl root url to load from
  89294. * @param onProgress event that fires when loading progress has occured
  89295. * @param fileName Defines the name of the file to load
  89296. * @returns a promise which completes when objects have been loaded to the scene
  89297. */
  89298. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  89299. /**
  89300. * Load into an asset container.
  89301. * @param scene The scene to load into
  89302. * @param data The data to import
  89303. * @param rootUrl The root url for scene and resources
  89304. * @param onProgress The callback when the load progresses
  89305. * @param fileName Defines the name of the file to load
  89306. * @returns The loaded asset container
  89307. */
  89308. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  89309. private _optimizeNormals;
  89310. /**
  89311. * Read the OBJ file and create an Array of meshes.
  89312. * Each mesh contains all information given by the OBJ and the MTL file.
  89313. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  89314. *
  89315. * @param meshesNames
  89316. * @param scene Scene The scene where are displayed the data
  89317. * @param data String The content of the obj file
  89318. * @param rootUrl String The path to the folder
  89319. * @returns Array<AbstractMesh>
  89320. * @private
  89321. */
  89322. private _parseSolid;
  89323. }
  89324. }
  89325. declare module BABYLON {
  89326. /**
  89327. * STL file type loader.
  89328. * This is a babylon scene loader plugin.
  89329. */
  89330. export class STLFileLoader implements ISceneLoaderPlugin {
  89331. /** @hidden */
  89332. solidPattern: RegExp;
  89333. /** @hidden */
  89334. facetsPattern: RegExp;
  89335. /** @hidden */
  89336. normalPattern: RegExp;
  89337. /** @hidden */
  89338. vertexPattern: RegExp;
  89339. /**
  89340. * Defines the name of the plugin.
  89341. */
  89342. name: string;
  89343. /**
  89344. * Defines the extensions the stl loader is able to load.
  89345. * force data to come in as an ArrayBuffer
  89346. * we'll convert to string if it looks like it's an ASCII .stl
  89347. */
  89348. extensions: ISceneLoaderPluginExtensions;
  89349. /**
  89350. * Import meshes into a scene.
  89351. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  89352. * @param scene The scene to import into
  89353. * @param data The data to import
  89354. * @param rootUrl The root url for scene and resources
  89355. * @param meshes The meshes array to import into
  89356. * @param particleSystems The particle systems array to import into
  89357. * @param skeletons The skeletons array to import into
  89358. * @param onError The callback when import fails
  89359. * @returns True if successful or false otherwise
  89360. */
  89361. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  89362. /**
  89363. * Load into a scene.
  89364. * @param scene The scene to load into
  89365. * @param data The data to import
  89366. * @param rootUrl The root url for scene and resources
  89367. * @param onError The callback when import fails
  89368. * @returns true if successful or false otherwise
  89369. */
  89370. load(scene: Scene, data: any, rootUrl: string): boolean;
  89371. /**
  89372. * Load into an asset container.
  89373. * @param scene The scene to load into
  89374. * @param data The data to import
  89375. * @param rootUrl The root url for scene and resources
  89376. * @param onError The callback when import fails
  89377. * @returns The loaded asset container
  89378. */
  89379. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  89380. private _isBinary;
  89381. private _parseBinary;
  89382. private _parseASCII;
  89383. }
  89384. }
  89385. declare module BABYLON {
  89386. /**
  89387. * Class for generating OBJ data from a Babylon scene.
  89388. */
  89389. export class OBJExport {
  89390. /**
  89391. * Exports the geometry of a Mesh array in .OBJ file format (text)
  89392. * @param mesh defines the list of meshes to serialize
  89393. * @param materials defines if materials should be exported
  89394. * @param matlibname defines the name of the associated mtl file
  89395. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  89396. * @returns the OBJ content
  89397. */
  89398. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  89399. /**
  89400. * Exports the material(s) of a mesh in .MTL file format (text)
  89401. * @param mesh defines the mesh to extract the material from
  89402. * @returns the mtl content
  89403. */
  89404. static MTL(mesh: Mesh): string;
  89405. }
  89406. }
  89407. declare module BABYLON {
  89408. /** @hidden */
  89409. export var __IGLTFExporterExtension: number;
  89410. /**
  89411. * Interface for extending the exporter
  89412. * @hidden
  89413. */
  89414. export interface IGLTFExporterExtension {
  89415. /**
  89416. * The name of this extension
  89417. */
  89418. readonly name: string;
  89419. /**
  89420. * Defines whether this extension is enabled
  89421. */
  89422. enabled: boolean;
  89423. /**
  89424. * Defines whether this extension is required
  89425. */
  89426. required: boolean;
  89427. }
  89428. }
  89429. declare module BABYLON.GLTF2.Exporter {
  89430. /** @hidden */
  89431. export var __IGLTFExporterExtensionV2: number;
  89432. /**
  89433. * Interface for a glTF exporter extension
  89434. * @hidden
  89435. */
  89436. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  89437. /**
  89438. * Define this method to modify the default behavior before exporting a texture
  89439. * @param context The context when loading the asset
  89440. * @param babylonTexture The Babylon.js texture
  89441. * @param mimeType The mime-type of the generated image
  89442. * @returns A promise that resolves with the exported texture
  89443. */
  89444. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  89445. /**
  89446. * Define this method to get notified when a texture info is created
  89447. * @param context The context when loading the asset
  89448. * @param textureInfo The glTF texture info
  89449. * @param babylonTexture The Babylon.js texture
  89450. */
  89451. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89452. /**
  89453. * Define this method to modify the default behavior when exporting texture info
  89454. * @param context The context when loading the asset
  89455. * @param meshPrimitive glTF mesh primitive
  89456. * @param babylonSubMesh Babylon submesh
  89457. * @param binaryWriter glTF serializer binary writer instance
  89458. * @returns nullable IMeshPrimitive promise
  89459. */
  89460. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  89461. /**
  89462. * Define this method to modify the default behavior when exporting a node
  89463. * @param context The context when exporting the node
  89464. * @param node glTF node
  89465. * @param babylonNode BabylonJS node
  89466. * @returns nullable INode promise
  89467. */
  89468. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89469. [key: number]: number;
  89470. }): Promise<Nullable<INode>>;
  89471. /**
  89472. * Define this method to modify the default behavior when exporting a material
  89473. * @param material glTF material
  89474. * @param babylonMaterial BabylonJS material
  89475. * @returns nullable IMaterial promise
  89476. */
  89477. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  89478. /**
  89479. * Define this method to return additional textures to export from a material
  89480. * @param material glTF material
  89481. * @param babylonMaterial BabylonJS material
  89482. * @returns List of textures
  89483. */
  89484. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  89485. /** Gets a boolean indicating that this extension was used */
  89486. wasUsed: boolean;
  89487. /** Gets a boolean indicating that this extension is required for the file to work */
  89488. required: boolean;
  89489. /**
  89490. * Called after the exporter state changes to EXPORTING
  89491. */
  89492. onExporting?(): void;
  89493. }
  89494. }
  89495. declare module BABYLON.GLTF2.Exporter {
  89496. /**
  89497. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  89498. * @hidden
  89499. */
  89500. export class _GLTFMaterialExporter {
  89501. /**
  89502. * Represents the dielectric specular values for R, G and B
  89503. */
  89504. private static readonly _DielectricSpecular;
  89505. /**
  89506. * Allows the maximum specular power to be defined for material calculations
  89507. */
  89508. private static readonly _MaxSpecularPower;
  89509. /**
  89510. * Mapping to store textures
  89511. */
  89512. private _textureMap;
  89513. /**
  89514. * Numeric tolerance value
  89515. */
  89516. private static readonly _Epsilon;
  89517. /**
  89518. * Reference to the glTF Exporter
  89519. */
  89520. private _exporter;
  89521. constructor(exporter: _Exporter);
  89522. /**
  89523. * Specifies if two colors are approximately equal in value
  89524. * @param color1 first color to compare to
  89525. * @param color2 second color to compare to
  89526. * @param epsilon threshold value
  89527. */
  89528. private static FuzzyEquals;
  89529. /**
  89530. * Gets the materials from a Babylon scene and converts them to glTF materials
  89531. * @param scene babylonjs scene
  89532. * @param mimeType texture mime type
  89533. * @param images array of images
  89534. * @param textures array of textures
  89535. * @param materials array of materials
  89536. * @param imageData mapping of texture names to base64 textures
  89537. * @param hasTextureCoords specifies if texture coordinates are present on the material
  89538. */
  89539. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  89540. /**
  89541. * Makes a copy of the glTF material without the texture parameters
  89542. * @param originalMaterial original glTF material
  89543. * @returns glTF material without texture parameters
  89544. */
  89545. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  89546. /**
  89547. * Specifies if the material has any texture parameters present
  89548. * @param material glTF Material
  89549. * @returns boolean specifying if texture parameters are present
  89550. */
  89551. _hasTexturesPresent(material: IMaterial): boolean;
  89552. /**
  89553. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  89554. * @param babylonStandardMaterial
  89555. * @returns glTF Metallic Roughness Material representation
  89556. */
  89557. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  89558. /**
  89559. * Computes the metallic factor
  89560. * @param diffuse diffused value
  89561. * @param specular specular value
  89562. * @param oneMinusSpecularStrength one minus the specular strength
  89563. * @returns metallic value
  89564. */
  89565. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  89566. /**
  89567. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  89568. * @param glTFMaterial glTF material
  89569. * @param babylonMaterial Babylon material
  89570. */
  89571. private static _SetAlphaMode;
  89572. /**
  89573. * Converts a Babylon Standard Material to a glTF Material
  89574. * @param babylonStandardMaterial BJS Standard Material
  89575. * @param mimeType mime type to use for the textures
  89576. * @param images array of glTF image interfaces
  89577. * @param textures array of glTF texture interfaces
  89578. * @param materials array of glTF material interfaces
  89579. * @param imageData map of image file name to data
  89580. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89581. */
  89582. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89583. private _finishMaterial;
  89584. /**
  89585. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  89586. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  89587. * @param mimeType mime type to use for the textures
  89588. * @param images array of glTF image interfaces
  89589. * @param textures array of glTF texture interfaces
  89590. * @param materials array of glTF material interfaces
  89591. * @param imageData map of image file name to data
  89592. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89593. */
  89594. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89595. /**
  89596. * Converts an image typed array buffer to a base64 image
  89597. * @param buffer typed array buffer
  89598. * @param width width of the image
  89599. * @param height height of the image
  89600. * @param mimeType mimetype of the image
  89601. * @returns base64 image string
  89602. */
  89603. private _createBase64FromCanvasAsync;
  89604. /**
  89605. * Generates a white texture based on the specified width and height
  89606. * @param width width of the texture in pixels
  89607. * @param height height of the texture in pixels
  89608. * @param scene babylonjs scene
  89609. * @returns white texture
  89610. */
  89611. private _createWhiteTexture;
  89612. /**
  89613. * Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null
  89614. * @param texture1 first texture to resize
  89615. * @param texture2 second texture to resize
  89616. * @param scene babylonjs scene
  89617. * @returns resized textures or null
  89618. */
  89619. private _resizeTexturesToSameDimensions;
  89620. /**
  89621. * Converts an array of pixels to a Float32Array
  89622. * Throws an error if the pixel format is not supported
  89623. * @param pixels - array buffer containing pixel values
  89624. * @returns Float32 of pixels
  89625. */
  89626. private _convertPixelArrayToFloat32;
  89627. /**
  89628. * Convert Specular Glossiness Textures to Metallic Roughness
  89629. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  89630. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  89631. * @param diffuseTexture texture used to store diffuse information
  89632. * @param specularGlossinessTexture texture used to store specular and glossiness information
  89633. * @param factors specular glossiness material factors
  89634. * @param mimeType the mime type to use for the texture
  89635. * @returns pbr metallic roughness interface or null
  89636. */
  89637. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  89638. /**
  89639. * Converts specular glossiness material properties to metallic roughness
  89640. * @param specularGlossiness interface with specular glossiness material properties
  89641. * @returns interface with metallic roughness material properties
  89642. */
  89643. private _convertSpecularGlossinessToMetallicRoughness;
  89644. /**
  89645. * Calculates the surface reflectance, independent of lighting conditions
  89646. * @param color Color source to calculate brightness from
  89647. * @returns number representing the perceived brightness, or zero if color is undefined
  89648. */
  89649. private _getPerceivedBrightness;
  89650. /**
  89651. * Returns the maximum color component value
  89652. * @param color
  89653. * @returns maximum color component value, or zero if color is null or undefined
  89654. */
  89655. private _getMaxComponent;
  89656. /**
  89657. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  89658. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89659. * @param mimeType mime type to use for the textures
  89660. * @param images array of glTF image interfaces
  89661. * @param textures array of glTF texture interfaces
  89662. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89663. * @param imageData map of image file name to data
  89664. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89665. * @returns glTF PBR Metallic Roughness factors
  89666. */
  89667. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  89668. private _getGLTFTextureSampler;
  89669. private _getGLTFTextureWrapMode;
  89670. private _getGLTFTextureWrapModesSampler;
  89671. /**
  89672. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  89673. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89674. * @param mimeType mime type to use for the textures
  89675. * @param images array of glTF image interfaces
  89676. * @param textures array of glTF texture interfaces
  89677. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89678. * @param imageData map of image file name to data
  89679. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89680. * @returns glTF PBR Metallic Roughness factors
  89681. */
  89682. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  89683. /**
  89684. * Converts a Babylon PBR Base Material to a glTF Material
  89685. * @param babylonPBRMaterial BJS PBR Base Material
  89686. * @param mimeType mime type to use for the textures
  89687. * @param images array of glTF image interfaces
  89688. * @param textures array of glTF texture interfaces
  89689. * @param materials array of glTF material interfaces
  89690. * @param imageData map of image file name to data
  89691. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89692. */
  89693. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89694. private setMetallicRoughnessPbrMaterial;
  89695. private getPixelsFromTexture;
  89696. /**
  89697. * Extracts a texture from a Babylon texture into file data and glTF data
  89698. * @param babylonTexture Babylon texture to extract
  89699. * @param mimeType Mime Type of the babylonTexture
  89700. * @return glTF texture info, or null if the texture format is not supported
  89701. */
  89702. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89703. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89704. /**
  89705. * Builds a texture from base64 string
  89706. * @param base64Texture base64 texture string
  89707. * @param baseTextureName Name to use for the texture
  89708. * @param mimeType image mime type for the texture
  89709. * @param images array of images
  89710. * @param textures array of textures
  89711. * @param imageData map of image data
  89712. * @returns glTF texture info, or null if the texture format is not supported
  89713. */
  89714. private _getTextureInfoFromBase64;
  89715. }
  89716. }
  89717. declare module BABYLON {
  89718. /**
  89719. * Class for holding and downloading glTF file data
  89720. */
  89721. export class GLTFData {
  89722. /**
  89723. * Object which contains the file name as the key and its data as the value
  89724. */
  89725. glTFFiles: {
  89726. [fileName: string]: string | Blob;
  89727. };
  89728. /**
  89729. * Initializes the glTF file object
  89730. */
  89731. constructor();
  89732. /**
  89733. * Downloads the glTF data as files based on their names and data
  89734. */
  89735. downloadFiles(): void;
  89736. }
  89737. }
  89738. declare module BABYLON {
  89739. /**
  89740. * Holds a collection of exporter options and parameters
  89741. */
  89742. export interface IExportOptions {
  89743. /**
  89744. * Function which indicates whether a babylon node should be exported or not
  89745. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  89746. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  89747. */
  89748. shouldExportNode?(node: Node): boolean;
  89749. /**
  89750. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  89751. * @param metadata source metadata to read from
  89752. * @returns the data to store to glTF node extras
  89753. */
  89754. metadataSelector?(metadata: any): any;
  89755. /**
  89756. * The sample rate to bake animation curves
  89757. */
  89758. animationSampleRate?: number;
  89759. /**
  89760. * Begin serialization without waiting for the scene to be ready
  89761. */
  89762. exportWithoutWaitingForScene?: boolean;
  89763. /**
  89764. * Indicates if coordinate system swapping root nodes should be included in export
  89765. */
  89766. includeCoordinateSystemConversionNodes?: boolean;
  89767. }
  89768. /**
  89769. * Class for generating glTF data from a Babylon scene.
  89770. */
  89771. export class GLTF2Export {
  89772. /**
  89773. * Exports the geometry of the scene to .gltf file format asynchronously
  89774. * @param scene Babylon scene with scene hierarchy information
  89775. * @param filePrefix File prefix to use when generating the glTF file
  89776. * @param options Exporter options
  89777. * @returns Returns an object with a .gltf file and associates texture names
  89778. * as keys and their data and paths as values
  89779. */
  89780. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89781. private static _PreExportAsync;
  89782. private static _PostExportAsync;
  89783. /**
  89784. * Exports the geometry of the scene to .glb file format asychronously
  89785. * @param scene Babylon scene with scene hierarchy information
  89786. * @param filePrefix File prefix to use when generating glb file
  89787. * @param options Exporter options
  89788. * @returns Returns an object with a .glb filename as key and data as value
  89789. */
  89790. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89791. }
  89792. }
  89793. declare module BABYLON.GLTF2.Exporter {
  89794. /**
  89795. * @hidden
  89796. */
  89797. export class _GLTFUtilities {
  89798. /**
  89799. * Creates a buffer view based on the supplied arguments
  89800. * @param bufferIndex index value of the specified buffer
  89801. * @param byteOffset byte offset value
  89802. * @param byteLength byte length of the bufferView
  89803. * @param byteStride byte distance between conequential elements
  89804. * @param name name of the buffer view
  89805. * @returns bufferView for glTF
  89806. */
  89807. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  89808. /**
  89809. * Creates an accessor based on the supplied arguments
  89810. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  89811. * @param name The name of the accessor
  89812. * @param type The type of the accessor
  89813. * @param componentType The datatype of components in the attribute
  89814. * @param count The number of attributes referenced by this accessor
  89815. * @param byteOffset The offset relative to the start of the bufferView in bytes
  89816. * @param min Minimum value of each component in this attribute
  89817. * @param max Maximum value of each component in this attribute
  89818. * @returns accessor for glTF
  89819. */
  89820. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  89821. /**
  89822. * Calculates the minimum and maximum values of an array of position floats
  89823. * @param positions Positions array of a mesh
  89824. * @param vertexStart Starting vertex offset to calculate min and max values
  89825. * @param vertexCount Number of vertices to check for min and max values
  89826. * @returns min number array and max number array
  89827. */
  89828. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  89829. min: number[];
  89830. max: number[];
  89831. };
  89832. /**
  89833. * Converts a new right-handed Vector3
  89834. * @param vector vector3 array
  89835. * @returns right-handed Vector3
  89836. */
  89837. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  89838. /**
  89839. * Converts a Vector3 to right-handed
  89840. * @param vector Vector3 to convert to right-handed
  89841. */
  89842. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  89843. /**
  89844. * Converts a three element number array to right-handed
  89845. * @param vector number array to convert to right-handed
  89846. */
  89847. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  89848. /**
  89849. * Converts a new right-handed Vector3
  89850. * @param vector vector3 array
  89851. * @returns right-handed Vector3
  89852. */
  89853. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  89854. /**
  89855. * Converts a Vector3 to right-handed
  89856. * @param vector Vector3 to convert to right-handed
  89857. */
  89858. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  89859. /**
  89860. * Converts a three element number array to right-handed
  89861. * @param vector number array to convert to right-handed
  89862. */
  89863. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  89864. /**
  89865. * Converts a Vector4 to right-handed
  89866. * @param vector Vector4 to convert to right-handed
  89867. */
  89868. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  89869. /**
  89870. * Converts a Vector4 to right-handed
  89871. * @param vector Vector4 to convert to right-handed
  89872. */
  89873. static _GetRightHandedArray4FromRef(vector: number[]): void;
  89874. /**
  89875. * Converts a Quaternion to right-handed
  89876. * @param quaternion Source quaternion to convert to right-handed
  89877. */
  89878. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  89879. /**
  89880. * Converts a Quaternion to right-handed
  89881. * @param quaternion Source quaternion to convert to right-handed
  89882. */
  89883. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  89884. static _NormalizeTangentFromRef(tangent: Vector4): void;
  89885. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  89886. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  89887. }
  89888. }
  89889. declare module BABYLON.GLTF2.Exporter {
  89890. /**
  89891. * Converts Babylon Scene into glTF 2.0.
  89892. * @hidden
  89893. */
  89894. export class _Exporter {
  89895. /**
  89896. * Stores the glTF to export
  89897. */
  89898. _glTF: IGLTF;
  89899. /**
  89900. * Stores all generated buffer views, which represents views into the main glTF buffer data
  89901. */
  89902. _bufferViews: IBufferView[];
  89903. /**
  89904. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  89905. */
  89906. _accessors: IAccessor[];
  89907. /**
  89908. * Stores all the generated nodes, which contains transform and/or mesh information per node
  89909. */
  89910. _nodes: INode[];
  89911. /**
  89912. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  89913. */
  89914. private _scenes;
  89915. /**
  89916. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  89917. */
  89918. private _meshes;
  89919. /**
  89920. * Stores all the generated material information, which represents the appearance of each primitive
  89921. */
  89922. _materials: IMaterial[];
  89923. _materialMap: {
  89924. [materialID: number]: number;
  89925. };
  89926. /**
  89927. * Stores all the generated texture information, which is referenced by glTF materials
  89928. */
  89929. _textures: ITexture[];
  89930. /**
  89931. * Stores all the generated image information, which is referenced by glTF textures
  89932. */
  89933. _images: IImage[];
  89934. /**
  89935. * Stores all the texture samplers
  89936. */
  89937. _samplers: ISampler[];
  89938. /**
  89939. * Stores all the generated glTF skins
  89940. */
  89941. _skins: ISkin[];
  89942. /**
  89943. * Stores all the generated animation samplers, which is referenced by glTF animations
  89944. */
  89945. /**
  89946. * Stores the animations for glTF models
  89947. */
  89948. private _animations;
  89949. /**
  89950. * Stores the total amount of bytes stored in the glTF buffer
  89951. */
  89952. private _totalByteLength;
  89953. /**
  89954. * Stores a reference to the Babylon scene containing the source geometry and material information
  89955. */
  89956. _babylonScene: Scene;
  89957. /**
  89958. * Stores a map of the image data, where the key is the file name and the value
  89959. * is the image data
  89960. */
  89961. _imageData: {
  89962. [fileName: string]: {
  89963. data: Uint8Array;
  89964. mimeType: ImageMimeType;
  89965. };
  89966. };
  89967. protected _orderedImageData: Array<{
  89968. data: Uint8Array;
  89969. mimeType: ImageMimeType;
  89970. }>;
  89971. /**
  89972. * Stores a map of the unique id of a node to its index in the node array
  89973. */
  89974. _nodeMap: {
  89975. [key: number]: number;
  89976. };
  89977. /**
  89978. * Specifies if the source Babylon scene was left handed, and needed conversion.
  89979. */
  89980. _convertToRightHandedSystem: boolean;
  89981. /**
  89982. * Specifies if a Babylon node should be converted to right-handed on export
  89983. */
  89984. _convertToRightHandedSystemMap: {
  89985. [nodeId: number]: boolean;
  89986. };
  89987. _includeCoordinateSystemConversionNodes: boolean;
  89988. /**
  89989. * Baked animation sample rate
  89990. */
  89991. private _animationSampleRate;
  89992. private _options;
  89993. private _localEngine;
  89994. _glTFMaterialExporter: _GLTFMaterialExporter;
  89995. private _extensions;
  89996. private static _ExtensionNames;
  89997. private static _ExtensionFactories;
  89998. private _applyExtension;
  89999. private _applyExtensions;
  90000. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  90001. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  90002. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90003. [key: number]: number;
  90004. }): Promise<Nullable<INode>>;
  90005. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  90006. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  90007. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  90008. private _forEachExtensions;
  90009. private _extensionsOnExporting;
  90010. /**
  90011. * Load glTF serializer extensions
  90012. */
  90013. private _loadExtensions;
  90014. /**
  90015. * Creates a glTF Exporter instance, which can accept optional exporter options
  90016. * @param babylonScene Babylon scene object
  90017. * @param options Options to modify the behavior of the exporter
  90018. */
  90019. constructor(babylonScene: Scene, options?: IExportOptions);
  90020. dispose(): void;
  90021. /**
  90022. * Registers a glTF exporter extension
  90023. * @param name Name of the extension to export
  90024. * @param factory The factory function that creates the exporter extension
  90025. */
  90026. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  90027. /**
  90028. * Un-registers an exporter extension
  90029. * @param name The name fo the exporter extension
  90030. * @returns A boolean indicating whether the extension has been un-registered
  90031. */
  90032. static UnregisterExtension(name: string): boolean;
  90033. private reorderIndicesBasedOnPrimitiveMode;
  90034. /**
  90035. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  90036. * clock-wise during export to glTF
  90037. * @param submesh BabylonJS submesh
  90038. * @param primitiveMode Primitive mode of the mesh
  90039. * @param sideOrientation the winding order of the submesh
  90040. * @param vertexBufferKind The type of vertex attribute
  90041. * @param meshAttributeArray The vertex attribute data
  90042. * @param byteOffset The offset to the binary data
  90043. * @param binaryWriter The binary data for the glTF file
  90044. * @param convertToRightHandedSystem Converts the values to right-handed
  90045. */
  90046. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  90047. /**
  90048. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  90049. * clock-wise during export to glTF
  90050. * @param submesh BabylonJS submesh
  90051. * @param primitiveMode Primitive mode of the mesh
  90052. * @param sideOrientation the winding order of the submesh
  90053. * @param vertexBufferKind The type of vertex attribute
  90054. * @param meshAttributeArray The vertex attribute data
  90055. * @param byteOffset The offset to the binary data
  90056. * @param binaryWriter The binary data for the glTF file
  90057. * @param convertToRightHandedSystem Converts the values to right-handed
  90058. */
  90059. private reorderTriangleFillMode;
  90060. /**
  90061. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  90062. * clock-wise during export to glTF
  90063. * @param submesh BabylonJS submesh
  90064. * @param primitiveMode Primitive mode of the mesh
  90065. * @param sideOrientation the winding order of the submesh
  90066. * @param vertexBufferKind The type of vertex attribute
  90067. * @param meshAttributeArray The vertex attribute data
  90068. * @param byteOffset The offset to the binary data
  90069. * @param binaryWriter The binary data for the glTF file
  90070. * @param convertToRightHandedSystem Converts the values to right-handed
  90071. */
  90072. private reorderTriangleStripDrawMode;
  90073. /**
  90074. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  90075. * clock-wise during export to glTF
  90076. * @param submesh BabylonJS submesh
  90077. * @param primitiveMode Primitive mode of the mesh
  90078. * @param sideOrientation the winding order of the submesh
  90079. * @param vertexBufferKind The type of vertex attribute
  90080. * @param meshAttributeArray The vertex attribute data
  90081. * @param byteOffset The offset to the binary data
  90082. * @param binaryWriter The binary data for the glTF file
  90083. * @param convertToRightHandedSystem Converts the values to right-handed
  90084. */
  90085. private reorderTriangleFanMode;
  90086. /**
  90087. * Writes the vertex attribute data to binary
  90088. * @param vertices The vertices to write to the binary writer
  90089. * @param byteOffset The offset into the binary writer to overwrite binary data
  90090. * @param vertexAttributeKind The vertex attribute type
  90091. * @param meshAttributeArray The vertex attribute data
  90092. * @param binaryWriter The writer containing the binary data
  90093. * @param convertToRightHandedSystem Converts the values to right-handed
  90094. */
  90095. private writeVertexAttributeData;
  90096. /**
  90097. * Writes mesh attribute data to a data buffer
  90098. * Returns the bytelength of the data
  90099. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90100. * @param meshAttributeArray Array containing the attribute data
  90101. * @param byteStride Specifies the space between data
  90102. * @param binaryWriter The buffer to write the binary data to
  90103. * @param convertToRightHandedSystem Converts the values to right-handed
  90104. */
  90105. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  90106. /**
  90107. * Writes mesh attribute data to a data buffer
  90108. * Returns the bytelength of the data
  90109. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90110. * @param meshAttributeArray Array containing the attribute data
  90111. * @param byteStride Specifies the space between data
  90112. * @param binaryWriter The buffer to write the binary data to
  90113. * @param convertToRightHandedSystem Converts the values to right-handed
  90114. */
  90115. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  90116. /**
  90117. * Generates glTF json data
  90118. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  90119. * @param glTFPrefix Text to use when prefixing a glTF file
  90120. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  90121. * @returns json data as string
  90122. */
  90123. private generateJSON;
  90124. /**
  90125. * Generates data for .gltf and .bin files based on the glTF prefix string
  90126. * @param glTFPrefix Text to use when prefixing a glTF file
  90127. * @param dispose Dispose the exporter
  90128. * @returns GLTFData with glTF file data
  90129. */
  90130. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90131. /**
  90132. * Creates a binary buffer for glTF
  90133. * @returns array buffer for binary data
  90134. */
  90135. private _generateBinaryAsync;
  90136. /**
  90137. * Pads the number to a multiple of 4
  90138. * @param num number to pad
  90139. * @returns padded number
  90140. */
  90141. private _getPadding;
  90142. /**
  90143. * @hidden
  90144. */
  90145. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90146. /**
  90147. * Sets the TRS for each node
  90148. * @param node glTF Node for storing the transformation data
  90149. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  90150. * @param convertToRightHandedSystem Converts the values to right-handed
  90151. */
  90152. private setNodeTransformation;
  90153. private getVertexBufferFromMesh;
  90154. /**
  90155. * Creates a bufferview based on the vertices type for the Babylon mesh
  90156. * @param kind Indicates the type of vertices data
  90157. * @param componentType Indicates the numerical type used to store the data
  90158. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  90159. * @param binaryWriter The buffer to write the bufferview data to
  90160. * @param convertToRightHandedSystem Converts the values to right-handed
  90161. */
  90162. private createBufferViewKind;
  90163. /**
  90164. * Creates a bufferview based on the vertices type for the Babylon mesh
  90165. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  90166. * @param babylonMorphTarget the morph target to be exported
  90167. * @param binaryWriter The buffer to write the bufferview data to
  90168. * @param convertToRightHandedSystem Converts the values to right-handed
  90169. */
  90170. private setMorphTargetAttributes;
  90171. /**
  90172. * The primitive mode of the Babylon mesh
  90173. * @param babylonMesh The BabylonJS mesh
  90174. */
  90175. private getMeshPrimitiveMode;
  90176. /**
  90177. * Sets the primitive mode of the glTF mesh primitive
  90178. * @param meshPrimitive glTF mesh primitive
  90179. * @param primitiveMode The primitive mode
  90180. */
  90181. private setPrimitiveMode;
  90182. /**
  90183. * Sets the vertex attribute accessor based of the glTF mesh primitive
  90184. * @param meshPrimitive glTF mesh primitive
  90185. * @param attributeKind vertex attribute
  90186. * @returns boolean specifying if uv coordinates are present
  90187. */
  90188. private setAttributeKind;
  90189. /**
  90190. * Sets data for the primitive attributes of each submesh
  90191. * @param mesh glTF Mesh object to store the primitive attribute information
  90192. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  90193. * @param binaryWriter Buffer to write the attribute data to
  90194. * @param convertToRightHandedSystem Converts the values to right-handed
  90195. */
  90196. private setPrimitiveAttributesAsync;
  90197. /**
  90198. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  90199. * @param node The node to check
  90200. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  90201. */
  90202. private isBabylonCoordinateSystemConvertingNode;
  90203. /**
  90204. * Creates a glTF scene based on the array of meshes
  90205. * Returns the the total byte offset
  90206. * @param babylonScene Babylon scene to get the mesh data from
  90207. * @param binaryWriter Buffer to write binary data to
  90208. */
  90209. private createSceneAsync;
  90210. /**
  90211. * Creates a mapping of Node unique id to node index and handles animations
  90212. * @param babylonScene Babylon Scene
  90213. * @param nodes Babylon transform nodes
  90214. * @param binaryWriter Buffer to write binary data to
  90215. * @returns Node mapping of unique id to index
  90216. */
  90217. private createNodeMapAndAnimationsAsync;
  90218. /**
  90219. * Creates a glTF node from a Babylon mesh
  90220. * @param babylonMesh Source Babylon mesh
  90221. * @param binaryWriter Buffer for storing geometry data
  90222. * @param convertToRightHandedSystem Converts the values to right-handed
  90223. * @param nodeMap Node mapping of unique id to glTF node index
  90224. * @returns glTF node
  90225. */
  90226. private createNodeAsync;
  90227. /**
  90228. * Creates a glTF skin from a Babylon skeleton
  90229. * @param babylonScene Babylon Scene
  90230. * @param nodes Babylon transform nodes
  90231. * @param binaryWriter Buffer to write binary data to
  90232. * @returns Node mapping of unique id to index
  90233. */
  90234. private createSkinsAsync;
  90235. }
  90236. /**
  90237. * @hidden
  90238. *
  90239. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  90240. */
  90241. export class _BinaryWriter {
  90242. /**
  90243. * Array buffer which stores all binary data
  90244. */
  90245. private _arrayBuffer;
  90246. /**
  90247. * View of the array buffer
  90248. */
  90249. private _dataView;
  90250. /**
  90251. * byte offset of data in array buffer
  90252. */
  90253. private _byteOffset;
  90254. /**
  90255. * Initialize binary writer with an initial byte length
  90256. * @param byteLength Initial byte length of the array buffer
  90257. */
  90258. constructor(byteLength: number);
  90259. /**
  90260. * Resize the array buffer to the specified byte length
  90261. * @param byteLength
  90262. */
  90263. private resizeBuffer;
  90264. /**
  90265. * Get an array buffer with the length of the byte offset
  90266. * @returns ArrayBuffer resized to the byte offset
  90267. */
  90268. getArrayBuffer(): ArrayBuffer;
  90269. /**
  90270. * Get the byte offset of the array buffer
  90271. * @returns byte offset
  90272. */
  90273. getByteOffset(): number;
  90274. /**
  90275. * Stores an UInt8 in the array buffer
  90276. * @param entry
  90277. * @param byteOffset If defined, specifies where to set the value as an offset.
  90278. */
  90279. setUInt8(entry: number, byteOffset?: number): void;
  90280. /**
  90281. * Stores an UInt16 in the array buffer
  90282. * @param entry
  90283. * @param byteOffset If defined, specifies where to set the value as an offset.
  90284. */
  90285. setUInt16(entry: number, byteOffset?: number): void;
  90286. /**
  90287. * Gets an UInt32 in the array buffer
  90288. * @param entry
  90289. * @param byteOffset If defined, specifies where to set the value as an offset.
  90290. */
  90291. getUInt32(byteOffset: number): number;
  90292. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90293. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90294. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90295. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90296. /**
  90297. * Stores a Float32 in the array buffer
  90298. * @param entry
  90299. */
  90300. setFloat32(entry: number, byteOffset?: number): void;
  90301. /**
  90302. * Stores an UInt32 in the array buffer
  90303. * @param entry
  90304. * @param byteOffset If defined, specifies where to set the value as an offset.
  90305. */
  90306. setUInt32(entry: number, byteOffset?: number): void;
  90307. }
  90308. }
  90309. declare module BABYLON.GLTF2.Exporter {
  90310. /**
  90311. * @hidden
  90312. * Interface to store animation data.
  90313. */
  90314. export interface _IAnimationData {
  90315. /**
  90316. * Keyframe data.
  90317. */
  90318. inputs: number[];
  90319. /**
  90320. * Value data.
  90321. */
  90322. outputs: number[][];
  90323. /**
  90324. * Animation interpolation data.
  90325. */
  90326. samplerInterpolation: AnimationSamplerInterpolation;
  90327. /**
  90328. * Minimum keyframe value.
  90329. */
  90330. inputsMin: number;
  90331. /**
  90332. * Maximum keyframe value.
  90333. */
  90334. inputsMax: number;
  90335. }
  90336. /**
  90337. * @hidden
  90338. */
  90339. export interface _IAnimationInfo {
  90340. /**
  90341. * The target channel for the animation
  90342. */
  90343. animationChannelTargetPath: AnimationChannelTargetPath;
  90344. /**
  90345. * The glTF accessor type for the data.
  90346. */
  90347. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  90348. /**
  90349. * Specifies if quaternions should be used.
  90350. */
  90351. useQuaternion: boolean;
  90352. }
  90353. /**
  90354. * @hidden
  90355. * Utility class for generating glTF animation data from BabylonJS.
  90356. */
  90357. export class _GLTFAnimation {
  90358. /**
  90359. * @ignore
  90360. *
  90361. * Creates glTF channel animation from BabylonJS animation.
  90362. * @param babylonTransformNode - BabylonJS mesh.
  90363. * @param animation - animation.
  90364. * @param animationChannelTargetPath - The target animation channel.
  90365. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  90366. * @param useQuaternion - Specifies if quaternions are used.
  90367. * @returns nullable IAnimationData
  90368. */
  90369. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  90370. private static _DeduceAnimationInfo;
  90371. /**
  90372. * @ignore
  90373. * Create node animations from the transform node animations
  90374. * @param babylonNode
  90375. * @param runtimeGLTFAnimation
  90376. * @param idleGLTFAnimations
  90377. * @param nodeMap
  90378. * @param nodes
  90379. * @param binaryWriter
  90380. * @param bufferViews
  90381. * @param accessors
  90382. * @param convertToRightHandedSystem
  90383. * @param animationSampleRate
  90384. */
  90385. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90386. [key: number]: number;
  90387. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90388. /**
  90389. * @ignore
  90390. * Create individual morph animations from the mesh's morph target animation tracks
  90391. * @param babylonNode
  90392. * @param runtimeGLTFAnimation
  90393. * @param idleGLTFAnimations
  90394. * @param nodeMap
  90395. * @param nodes
  90396. * @param binaryWriter
  90397. * @param bufferViews
  90398. * @param accessors
  90399. * @param convertToRightHandedSystem
  90400. * @param animationSampleRate
  90401. */
  90402. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90403. [key: number]: number;
  90404. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90405. /**
  90406. * @ignore
  90407. * Create node and morph animations from the animation groups
  90408. * @param babylonScene
  90409. * @param glTFAnimations
  90410. * @param nodeMap
  90411. * @param nodes
  90412. * @param binaryWriter
  90413. * @param bufferViews
  90414. * @param accessors
  90415. * @param convertToRightHandedSystemMap
  90416. * @param animationSampleRate
  90417. */
  90418. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  90419. [key: number]: number;
  90420. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  90421. [nodeId: number]: boolean;
  90422. }, animationSampleRate: number): void;
  90423. private static AddAnimation;
  90424. /**
  90425. * Create a baked animation
  90426. * @param babylonTransformNode BabylonJS mesh
  90427. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  90428. * @param animationChannelTargetPath animation target channel
  90429. * @param minFrame minimum animation frame
  90430. * @param maxFrame maximum animation frame
  90431. * @param fps frames per second of the animation
  90432. * @param inputs input key frames of the animation
  90433. * @param outputs output key frame data of the animation
  90434. * @param convertToRightHandedSystem converts the values to right-handed
  90435. * @param useQuaternion specifies if quaternions should be used
  90436. */
  90437. private static _CreateBakedAnimation;
  90438. private static _ConvertFactorToVector3OrQuaternion;
  90439. private static _SetInterpolatedValue;
  90440. /**
  90441. * Creates linear animation from the animation key frames
  90442. * @param babylonTransformNode BabylonJS mesh
  90443. * @param animation BabylonJS animation
  90444. * @param animationChannelTargetPath The target animation channel
  90445. * @param frameDelta The difference between the last and first frame of the animation
  90446. * @param inputs Array to store the key frame times
  90447. * @param outputs Array to store the key frame data
  90448. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90449. * @param useQuaternion Specifies if quaternions are used in the animation
  90450. */
  90451. private static _CreateLinearOrStepAnimation;
  90452. /**
  90453. * Creates cubic spline animation from the animation key frames
  90454. * @param babylonTransformNode BabylonJS mesh
  90455. * @param animation BabylonJS animation
  90456. * @param animationChannelTargetPath The target animation channel
  90457. * @param frameDelta The difference between the last and first frame of the animation
  90458. * @param inputs Array to store the key frame times
  90459. * @param outputs Array to store the key frame data
  90460. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90461. * @param useQuaternion Specifies if quaternions are used in the animation
  90462. */
  90463. private static _CreateCubicSplineAnimation;
  90464. private static _GetBasePositionRotationOrScale;
  90465. /**
  90466. * Adds a key frame value
  90467. * @param keyFrame
  90468. * @param animation
  90469. * @param outputs
  90470. * @param animationChannelTargetPath
  90471. * @param basePositionRotationOrScale
  90472. * @param convertToRightHandedSystem
  90473. * @param useQuaternion
  90474. */
  90475. private static _AddKeyframeValue;
  90476. /**
  90477. * Determine the interpolation based on the key frames
  90478. * @param keyFrames
  90479. * @param animationChannelTargetPath
  90480. * @param useQuaternion
  90481. */
  90482. private static _DeduceInterpolation;
  90483. /**
  90484. * Adds an input tangent or output tangent to the output data
  90485. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  90486. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  90487. * @param outputs The animation data by keyframe
  90488. * @param animationChannelTargetPath The target animation channel
  90489. * @param interpolation The interpolation type
  90490. * @param keyFrame The key frame with the animation data
  90491. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  90492. * @param useQuaternion Specifies if quaternions are used
  90493. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  90494. */
  90495. private static AddSplineTangent;
  90496. /**
  90497. * Get the minimum and maximum key frames' frame values
  90498. * @param keyFrames animation key frames
  90499. * @returns the minimum and maximum key frame value
  90500. */
  90501. private static calculateMinMaxKeyFrames;
  90502. }
  90503. }
  90504. declare module BABYLON.GLTF2.Exporter {
  90505. /** @hidden */
  90506. export var textureTransformPixelShader: {
  90507. name: string;
  90508. shader: string;
  90509. };
  90510. }
  90511. declare module BABYLON.GLTF2.Exporter.Extensions {
  90512. /**
  90513. * @hidden
  90514. */
  90515. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  90516. private _recordedTextures;
  90517. /** Name of this extension */
  90518. readonly name: string;
  90519. /** Defines whether this extension is enabled */
  90520. enabled: boolean;
  90521. /** Defines whether this extension is required */
  90522. required: boolean;
  90523. /** Reference to the glTF exporter */
  90524. private _wasUsed;
  90525. constructor(exporter: _Exporter);
  90526. dispose(): void;
  90527. /** @hidden */
  90528. get wasUsed(): boolean;
  90529. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90530. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  90531. /**
  90532. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  90533. * @param babylonTexture
  90534. * @param offset
  90535. * @param rotation
  90536. * @param scale
  90537. * @param scene
  90538. */
  90539. private _textureTransformTextureAsync;
  90540. }
  90541. }
  90542. declare module BABYLON.GLTF2.Exporter.Extensions {
  90543. /**
  90544. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  90545. */
  90546. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  90547. /** The name of this extension. */
  90548. readonly name: string;
  90549. /** Defines whether this extension is enabled. */
  90550. enabled: boolean;
  90551. /** Defines whether this extension is required */
  90552. required: boolean;
  90553. /** Reference to the glTF exporter */
  90554. private _exporter;
  90555. private _lights;
  90556. /** @hidden */
  90557. constructor(exporter: _Exporter);
  90558. /** @hidden */
  90559. dispose(): void;
  90560. /** @hidden */
  90561. get wasUsed(): boolean;
  90562. /** @hidden */
  90563. onExporting(): void;
  90564. /**
  90565. * Define this method to modify the default behavior when exporting a node
  90566. * @param context The context when exporting the node
  90567. * @param node glTF node
  90568. * @param babylonNode BabylonJS node
  90569. * @param nodeMap Node mapping of unique id to glTF node index
  90570. * @returns nullable INode promise
  90571. */
  90572. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90573. [key: number]: number;
  90574. }): Promise<Nullable<INode>>;
  90575. }
  90576. }
  90577. declare module BABYLON.GLTF2.Exporter.Extensions {
  90578. /**
  90579. * @hidden
  90580. */
  90581. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  90582. /** Name of this extension */
  90583. readonly name: string;
  90584. /** Defines whether this extension is enabled */
  90585. enabled: boolean;
  90586. /** Defines whether this extension is required */
  90587. required: boolean;
  90588. /** Reference to the glTF exporter */
  90589. private _textureInfos;
  90590. private _exportedTextures;
  90591. private _wasUsed;
  90592. constructor(exporter: _Exporter);
  90593. dispose(): void;
  90594. /** @hidden */
  90595. get wasUsed(): boolean;
  90596. private _getTextureIndex;
  90597. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90598. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90599. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90600. }
  90601. }
  90602. declare module BABYLON.GLTF2.Exporter.Extensions {
  90603. /**
  90604. * @hidden
  90605. */
  90606. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  90607. /** Name of this extension */
  90608. readonly name: string;
  90609. /** Defines whether this extension is enabled */
  90610. enabled: boolean;
  90611. /** Defines whether this extension is required */
  90612. required: boolean;
  90613. private _wasUsed;
  90614. constructor(exporter: _Exporter);
  90615. /** @hidden */
  90616. get wasUsed(): boolean;
  90617. dispose(): void;
  90618. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90619. }
  90620. }
  90621. declare module BABYLON {
  90622. /**
  90623. * Class for generating STL data from a Babylon scene.
  90624. */
  90625. export class STLExport {
  90626. /**
  90627. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  90628. * @param meshes list defines the mesh to serialize
  90629. * @param download triggers the automatic download of the file.
  90630. * @param fileName changes the downloads fileName.
  90631. * @param binary changes the STL to a binary type.
  90632. * @param isLittleEndian toggle for binary type exporter.
  90633. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  90634. * @returns the STL as UTF8 string
  90635. */
  90636. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  90637. }
  90638. }
  90639. declare module "babylonjs-gltf2interface" {
  90640. export = BABYLON.GLTF2;
  90641. }
  90642. /**
  90643. * Module for glTF 2.0 Interface
  90644. */
  90645. declare module BABYLON.GLTF2 {
  90646. /**
  90647. * The datatype of the components in the attribute
  90648. */
  90649. const enum AccessorComponentType {
  90650. /**
  90651. * Byte
  90652. */
  90653. BYTE = 5120,
  90654. /**
  90655. * Unsigned Byte
  90656. */
  90657. UNSIGNED_BYTE = 5121,
  90658. /**
  90659. * Short
  90660. */
  90661. SHORT = 5122,
  90662. /**
  90663. * Unsigned Short
  90664. */
  90665. UNSIGNED_SHORT = 5123,
  90666. /**
  90667. * Unsigned Int
  90668. */
  90669. UNSIGNED_INT = 5125,
  90670. /**
  90671. * Float
  90672. */
  90673. FLOAT = 5126,
  90674. }
  90675. /**
  90676. * Specifies if the attirbute is a scalar, vector, or matrix
  90677. */
  90678. const enum AccessorType {
  90679. /**
  90680. * Scalar
  90681. */
  90682. SCALAR = "SCALAR",
  90683. /**
  90684. * Vector2
  90685. */
  90686. VEC2 = "VEC2",
  90687. /**
  90688. * Vector3
  90689. */
  90690. VEC3 = "VEC3",
  90691. /**
  90692. * Vector4
  90693. */
  90694. VEC4 = "VEC4",
  90695. /**
  90696. * Matrix2x2
  90697. */
  90698. MAT2 = "MAT2",
  90699. /**
  90700. * Matrix3x3
  90701. */
  90702. MAT3 = "MAT3",
  90703. /**
  90704. * Matrix4x4
  90705. */
  90706. MAT4 = "MAT4",
  90707. }
  90708. /**
  90709. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90710. */
  90711. const enum AnimationChannelTargetPath {
  90712. /**
  90713. * Translation
  90714. */
  90715. TRANSLATION = "translation",
  90716. /**
  90717. * Rotation
  90718. */
  90719. ROTATION = "rotation",
  90720. /**
  90721. * Scale
  90722. */
  90723. SCALE = "scale",
  90724. /**
  90725. * Weights
  90726. */
  90727. WEIGHTS = "weights",
  90728. }
  90729. /**
  90730. * Interpolation algorithm
  90731. */
  90732. const enum AnimationSamplerInterpolation {
  90733. /**
  90734. * The animated values are linearly interpolated between keyframes
  90735. */
  90736. LINEAR = "LINEAR",
  90737. /**
  90738. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  90739. */
  90740. STEP = "STEP",
  90741. /**
  90742. * The animation's interpolation is computed using a cubic spline with specified tangents
  90743. */
  90744. CUBICSPLINE = "CUBICSPLINE",
  90745. }
  90746. /**
  90747. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90748. */
  90749. const enum CameraType {
  90750. /**
  90751. * A perspective camera containing properties to create a perspective projection matrix
  90752. */
  90753. PERSPECTIVE = "perspective",
  90754. /**
  90755. * An orthographic camera containing properties to create an orthographic projection matrix
  90756. */
  90757. ORTHOGRAPHIC = "orthographic",
  90758. }
  90759. /**
  90760. * The mime-type of the image
  90761. */
  90762. const enum ImageMimeType {
  90763. /**
  90764. * JPEG Mime-type
  90765. */
  90766. JPEG = "image/jpeg",
  90767. /**
  90768. * PNG Mime-type
  90769. */
  90770. PNG = "image/png",
  90771. }
  90772. /**
  90773. * The alpha rendering mode of the material
  90774. */
  90775. const enum MaterialAlphaMode {
  90776. /**
  90777. * The alpha value is ignored and the rendered output is fully opaque
  90778. */
  90779. OPAQUE = "OPAQUE",
  90780. /**
  90781. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  90782. */
  90783. MASK = "MASK",
  90784. /**
  90785. * The alpha value is used to composite the source and destination areas. The rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator)
  90786. */
  90787. BLEND = "BLEND",
  90788. }
  90789. /**
  90790. * The type of the primitives to render
  90791. */
  90792. const enum MeshPrimitiveMode {
  90793. /**
  90794. * Points
  90795. */
  90796. POINTS = 0,
  90797. /**
  90798. * Lines
  90799. */
  90800. LINES = 1,
  90801. /**
  90802. * Line Loop
  90803. */
  90804. LINE_LOOP = 2,
  90805. /**
  90806. * Line Strip
  90807. */
  90808. LINE_STRIP = 3,
  90809. /**
  90810. * Triangles
  90811. */
  90812. TRIANGLES = 4,
  90813. /**
  90814. * Triangle Strip
  90815. */
  90816. TRIANGLE_STRIP = 5,
  90817. /**
  90818. * Triangle Fan
  90819. */
  90820. TRIANGLE_FAN = 6,
  90821. }
  90822. /**
  90823. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90824. */
  90825. const enum TextureMagFilter {
  90826. /**
  90827. * Nearest
  90828. */
  90829. NEAREST = 9728,
  90830. /**
  90831. * Linear
  90832. */
  90833. LINEAR = 9729,
  90834. }
  90835. /**
  90836. * Minification filter. All valid values correspond to WebGL enums
  90837. */
  90838. const enum TextureMinFilter {
  90839. /**
  90840. * Nearest
  90841. */
  90842. NEAREST = 9728,
  90843. /**
  90844. * Linear
  90845. */
  90846. LINEAR = 9729,
  90847. /**
  90848. * Nearest Mip-Map Nearest
  90849. */
  90850. NEAREST_MIPMAP_NEAREST = 9984,
  90851. /**
  90852. * Linear Mipmap Nearest
  90853. */
  90854. LINEAR_MIPMAP_NEAREST = 9985,
  90855. /**
  90856. * Nearest Mipmap Linear
  90857. */
  90858. NEAREST_MIPMAP_LINEAR = 9986,
  90859. /**
  90860. * Linear Mipmap Linear
  90861. */
  90862. LINEAR_MIPMAP_LINEAR = 9987,
  90863. }
  90864. /**
  90865. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90866. */
  90867. const enum TextureWrapMode {
  90868. /**
  90869. * Clamp to Edge
  90870. */
  90871. CLAMP_TO_EDGE = 33071,
  90872. /**
  90873. * Mirrored Repeat
  90874. */
  90875. MIRRORED_REPEAT = 33648,
  90876. /**
  90877. * Repeat
  90878. */
  90879. REPEAT = 10497,
  90880. }
  90881. /**
  90882. * glTF Property
  90883. */
  90884. interface IProperty {
  90885. /**
  90886. * Dictionary object with extension-specific objects
  90887. */
  90888. extensions?: {
  90889. [key: string]: any;
  90890. };
  90891. /**
  90892. * Application-Specific data
  90893. */
  90894. extras?: any;
  90895. }
  90896. /**
  90897. * glTF Child of Root Property
  90898. */
  90899. interface IChildRootProperty extends IProperty {
  90900. /**
  90901. * The user-defined name of this object
  90902. */
  90903. name?: string;
  90904. }
  90905. /**
  90906. * Indices of those attributes that deviate from their initialization value
  90907. */
  90908. interface IAccessorSparseIndices extends IProperty {
  90909. /**
  90910. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90911. */
  90912. bufferView: number;
  90913. /**
  90914. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90915. */
  90916. byteOffset?: number;
  90917. /**
  90918. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  90919. */
  90920. componentType: AccessorComponentType;
  90921. }
  90922. /**
  90923. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  90924. */
  90925. interface IAccessorSparseValues extends IProperty {
  90926. /**
  90927. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90928. */
  90929. bufferView: number;
  90930. /**
  90931. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90932. */
  90933. byteOffset?: number;
  90934. }
  90935. /**
  90936. * Sparse storage of attributes that deviate from their initialization value
  90937. */
  90938. interface IAccessorSparse extends IProperty {
  90939. /**
  90940. * The number of attributes encoded in this sparse accessor
  90941. */
  90942. count: number;
  90943. /**
  90944. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  90945. */
  90946. indices: IAccessorSparseIndices;
  90947. /**
  90948. * Array of size count times number of components, storing the displaced accessor attributes pointed by indices. Substituted values must have the same componentType and number of components as the base accessor
  90949. */
  90950. values: IAccessorSparseValues;
  90951. }
  90952. /**
  90953. * A typed view into a bufferView. A bufferView contains raw binary data. An accessor provides a typed view into a bufferView or a subset of a bufferView similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer
  90954. */
  90955. interface IAccessor extends IChildRootProperty {
  90956. /**
  90957. * The index of the bufferview
  90958. */
  90959. bufferView?: number;
  90960. /**
  90961. * The offset relative to the start of the bufferView in bytes
  90962. */
  90963. byteOffset?: number;
  90964. /**
  90965. * The datatype of components in the attribute
  90966. */
  90967. componentType: AccessorComponentType;
  90968. /**
  90969. * Specifies whether integer data values should be normalized
  90970. */
  90971. normalized?: boolean;
  90972. /**
  90973. * The number of attributes referenced by this accessor
  90974. */
  90975. count: number;
  90976. /**
  90977. * Specifies if the attribute is a scalar, vector, or matrix
  90978. */
  90979. type: AccessorType;
  90980. /**
  90981. * Maximum value of each component in this attribute
  90982. */
  90983. max?: number[];
  90984. /**
  90985. * Minimum value of each component in this attribute
  90986. */
  90987. min?: number[];
  90988. /**
  90989. * Sparse storage of attributes that deviate from their initialization value
  90990. */
  90991. sparse?: IAccessorSparse;
  90992. }
  90993. /**
  90994. * Targets an animation's sampler at a node's property
  90995. */
  90996. interface IAnimationChannel extends IProperty {
  90997. /**
  90998. * The index of a sampler in this animation used to compute the value for the target
  90999. */
  91000. sampler: number;
  91001. /**
  91002. * The index of the node and TRS property to target
  91003. */
  91004. target: IAnimationChannelTarget;
  91005. }
  91006. /**
  91007. * The index of the node and TRS property that an animation channel targets
  91008. */
  91009. interface IAnimationChannelTarget extends IProperty {
  91010. /**
  91011. * The index of the node to target
  91012. */
  91013. node: number;
  91014. /**
  91015. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  91016. */
  91017. path: AnimationChannelTargetPath;
  91018. }
  91019. /**
  91020. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91021. */
  91022. interface IAnimationSampler extends IProperty {
  91023. /**
  91024. * The index of an accessor containing keyframe input values, e.g., time
  91025. */
  91026. input: number;
  91027. /**
  91028. * Interpolation algorithm
  91029. */
  91030. interpolation?: AnimationSamplerInterpolation;
  91031. /**
  91032. * The index of an accessor, containing keyframe output values
  91033. */
  91034. output: number;
  91035. }
  91036. /**
  91037. * A keyframe animation
  91038. */
  91039. interface IAnimation extends IChildRootProperty {
  91040. /**
  91041. * An array of channels, each of which targets an animation's sampler at a node's property
  91042. */
  91043. channels: IAnimationChannel[];
  91044. /**
  91045. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91046. */
  91047. samplers: IAnimationSampler[];
  91048. }
  91049. /**
  91050. * Metadata about the glTF asset
  91051. */
  91052. interface IAsset extends IChildRootProperty {
  91053. /**
  91054. * A copyright message suitable for display to credit the content creator
  91055. */
  91056. copyright?: string;
  91057. /**
  91058. * Tool that generated this glTF model. Useful for debugging
  91059. */
  91060. generator?: string;
  91061. /**
  91062. * The glTF version that this asset targets
  91063. */
  91064. version: string;
  91065. /**
  91066. * The minimum glTF version that this asset targets
  91067. */
  91068. minVersion?: string;
  91069. }
  91070. /**
  91071. * A buffer points to binary geometry, animation, or skins
  91072. */
  91073. interface IBuffer extends IChildRootProperty {
  91074. /**
  91075. * The uri of the buffer. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri
  91076. */
  91077. uri?: string;
  91078. /**
  91079. * The length of the buffer in bytes
  91080. */
  91081. byteLength: number;
  91082. }
  91083. /**
  91084. * A view into a buffer generally representing a subset of the buffer
  91085. */
  91086. interface IBufferView extends IChildRootProperty {
  91087. /**
  91088. * The index of the buffer
  91089. */
  91090. buffer: number;
  91091. /**
  91092. * The offset into the buffer in bytes
  91093. */
  91094. byteOffset?: number;
  91095. /**
  91096. * The lenth of the bufferView in bytes
  91097. */
  91098. byteLength: number;
  91099. /**
  91100. * The stride, in bytes
  91101. */
  91102. byteStride?: number;
  91103. }
  91104. /**
  91105. * An orthographic camera containing properties to create an orthographic projection matrix
  91106. */
  91107. interface ICameraOrthographic extends IProperty {
  91108. /**
  91109. * The floating-point horizontal magnification of the view. Must not be zero
  91110. */
  91111. xmag: number;
  91112. /**
  91113. * The floating-point vertical magnification of the view. Must not be zero
  91114. */
  91115. ymag: number;
  91116. /**
  91117. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  91118. */
  91119. zfar: number;
  91120. /**
  91121. * The floating-point distance to the near clipping plane
  91122. */
  91123. znear: number;
  91124. }
  91125. /**
  91126. * A perspective camera containing properties to create a perspective projection matrix
  91127. */
  91128. interface ICameraPerspective extends IProperty {
  91129. /**
  91130. * The floating-point aspect ratio of the field of view
  91131. */
  91132. aspectRatio?: number;
  91133. /**
  91134. * The floating-point vertical field of view in radians
  91135. */
  91136. yfov: number;
  91137. /**
  91138. * The floating-point distance to the far clipping plane
  91139. */
  91140. zfar?: number;
  91141. /**
  91142. * The floating-point distance to the near clipping plane
  91143. */
  91144. znear: number;
  91145. }
  91146. /**
  91147. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  91148. */
  91149. interface ICamera extends IChildRootProperty {
  91150. /**
  91151. * An orthographic camera containing properties to create an orthographic projection matrix
  91152. */
  91153. orthographic?: ICameraOrthographic;
  91154. /**
  91155. * A perspective camera containing properties to create a perspective projection matrix
  91156. */
  91157. perspective?: ICameraPerspective;
  91158. /**
  91159. * Specifies if the camera uses a perspective or orthographic projection
  91160. */
  91161. type: CameraType;
  91162. }
  91163. /**
  91164. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  91165. */
  91166. interface IImage extends IChildRootProperty {
  91167. /**
  91168. * The uri of the image. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri. The image format must be jpg or png
  91169. */
  91170. uri?: string;
  91171. /**
  91172. * The image's MIME type
  91173. */
  91174. mimeType?: ImageMimeType;
  91175. /**
  91176. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  91177. */
  91178. bufferView?: number;
  91179. }
  91180. /**
  91181. * Material Normal Texture Info
  91182. */
  91183. interface IMaterialNormalTextureInfo extends ITextureInfo {
  91184. /**
  91185. * The scalar multiplier applied to each normal vector of the normal texture
  91186. */
  91187. scale?: number;
  91188. }
  91189. /**
  91190. * Material Occlusion Texture Info
  91191. */
  91192. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  91193. /**
  91194. * A scalar multiplier controlling the amount of occlusion applied
  91195. */
  91196. strength?: number;
  91197. }
  91198. /**
  91199. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  91200. */
  91201. interface IMaterialPbrMetallicRoughness {
  91202. /**
  91203. * The material's base color factor
  91204. */
  91205. baseColorFactor?: number[];
  91206. /**
  91207. * The base color texture
  91208. */
  91209. baseColorTexture?: ITextureInfo;
  91210. /**
  91211. * The metalness of the material
  91212. */
  91213. metallicFactor?: number;
  91214. /**
  91215. * The roughness of the material
  91216. */
  91217. roughnessFactor?: number;
  91218. /**
  91219. * The metallic-roughness texture
  91220. */
  91221. metallicRoughnessTexture?: ITextureInfo;
  91222. }
  91223. /**
  91224. * The material appearance of a primitive
  91225. */
  91226. interface IMaterial extends IChildRootProperty {
  91227. /**
  91228. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of pbrMetallicRoughness apply
  91229. */
  91230. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  91231. /**
  91232. * The normal map texture
  91233. */
  91234. normalTexture?: IMaterialNormalTextureInfo;
  91235. /**
  91236. * The occlusion map texture
  91237. */
  91238. occlusionTexture?: IMaterialOcclusionTextureInfo;
  91239. /**
  91240. * The emissive map texture
  91241. */
  91242. emissiveTexture?: ITextureInfo;
  91243. /**
  91244. * The RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values
  91245. */
  91246. emissiveFactor?: number[];
  91247. /**
  91248. * The alpha rendering mode of the material
  91249. */
  91250. alphaMode?: MaterialAlphaMode;
  91251. /**
  91252. * The alpha cutoff value of the material
  91253. */
  91254. alphaCutoff?: number;
  91255. /**
  91256. * Specifies whether the material is double sided
  91257. */
  91258. doubleSided?: boolean;
  91259. }
  91260. /**
  91261. * Geometry to be rendered with the given material
  91262. */
  91263. interface IMeshPrimitive extends IProperty {
  91264. /**
  91265. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  91266. */
  91267. attributes: {
  91268. [name: string]: number;
  91269. };
  91270. /**
  91271. * The index of the accessor that contains the indices
  91272. */
  91273. indices?: number;
  91274. /**
  91275. * The index of the material to apply to this primitive when rendering
  91276. */
  91277. material?: number;
  91278. /**
  91279. * The type of primitives to render. All valid values correspond to WebGL enums
  91280. */
  91281. mode?: MeshPrimitiveMode;
  91282. /**
  91283. * An array of Morph Targets, each Morph Target is a dictionary mapping attributes (only POSITION, NORMAL, and TANGENT supported) to their deviations in the Morph Target
  91284. */
  91285. targets?: {
  91286. [name: string]: number;
  91287. }[];
  91288. }
  91289. /**
  91290. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  91291. */
  91292. interface IMesh extends IChildRootProperty {
  91293. /**
  91294. * An array of primitives, each defining geometry to be rendered with a material
  91295. */
  91296. primitives: IMeshPrimitive[];
  91297. /**
  91298. * Array of weights to be applied to the Morph Targets
  91299. */
  91300. weights?: number[];
  91301. }
  91302. /**
  91303. * A node in the node hierarchy
  91304. */
  91305. interface INode extends IChildRootProperty {
  91306. /**
  91307. * The index of the camera referenced by this node
  91308. */
  91309. camera?: number;
  91310. /**
  91311. * The indices of this node's children
  91312. */
  91313. children?: number[];
  91314. /**
  91315. * The index of the skin referenced by this node
  91316. */
  91317. skin?: number;
  91318. /**
  91319. * A floating-point 4x4 transformation matrix stored in column-major order
  91320. */
  91321. matrix?: number[];
  91322. /**
  91323. * The index of the mesh in this node
  91324. */
  91325. mesh?: number;
  91326. /**
  91327. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  91328. */
  91329. rotation?: number[];
  91330. /**
  91331. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  91332. */
  91333. scale?: number[];
  91334. /**
  91335. * The node's translation along the x, y, and z axes
  91336. */
  91337. translation?: number[];
  91338. /**
  91339. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  91340. */
  91341. weights?: number[];
  91342. }
  91343. /**
  91344. * Texture sampler properties for filtering and wrapping modes
  91345. */
  91346. interface ISampler extends IChildRootProperty {
  91347. /**
  91348. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91349. */
  91350. magFilter?: TextureMagFilter;
  91351. /**
  91352. * Minification filter. All valid values correspond to WebGL enums
  91353. */
  91354. minFilter?: TextureMinFilter;
  91355. /**
  91356. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91357. */
  91358. wrapS?: TextureWrapMode;
  91359. /**
  91360. * T (V) wrapping mode. All valid values correspond to WebGL enums
  91361. */
  91362. wrapT?: TextureWrapMode;
  91363. }
  91364. /**
  91365. * The root nodes of a scene
  91366. */
  91367. interface IScene extends IChildRootProperty {
  91368. /**
  91369. * The indices of each root node
  91370. */
  91371. nodes: number[];
  91372. }
  91373. /**
  91374. * Joints and matrices defining a skin
  91375. */
  91376. interface ISkin extends IChildRootProperty {
  91377. /**
  91378. * The index of the accessor containing the floating-point 4x4 inverse-bind matrices. The default is that each matrix is a 4x4 identity matrix, which implies that inverse-bind matrices were pre-applied
  91379. */
  91380. inverseBindMatrices?: number;
  91381. /**
  91382. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  91383. */
  91384. skeleton?: number;
  91385. /**
  91386. * Indices of skeleton nodes, used as joints in this skin. The array length must be the same as the count property of the inverseBindMatrices accessor (when defined)
  91387. */
  91388. joints: number[];
  91389. }
  91390. /**
  91391. * A texture and its sampler
  91392. */
  91393. interface ITexture extends IChildRootProperty {
  91394. /**
  91395. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  91396. */
  91397. sampler?: number;
  91398. /**
  91399. * The index of the image used by this texture
  91400. */
  91401. source: number;
  91402. }
  91403. /**
  91404. * Reference to a texture
  91405. */
  91406. interface ITextureInfo extends IProperty {
  91407. /**
  91408. * The index of the texture
  91409. */
  91410. index: number;
  91411. /**
  91412. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  91413. */
  91414. texCoord?: number;
  91415. }
  91416. /**
  91417. * The root object for a glTF asset
  91418. */
  91419. interface IGLTF extends IProperty {
  91420. /**
  91421. * An array of accessors. An accessor is a typed view into a bufferView
  91422. */
  91423. accessors?: IAccessor[];
  91424. /**
  91425. * An array of keyframe animations
  91426. */
  91427. animations?: IAnimation[];
  91428. /**
  91429. * Metadata about the glTF asset
  91430. */
  91431. asset: IAsset;
  91432. /**
  91433. * An array of buffers. A buffer points to binary geometry, animation, or skins
  91434. */
  91435. buffers?: IBuffer[];
  91436. /**
  91437. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  91438. */
  91439. bufferViews?: IBufferView[];
  91440. /**
  91441. * An array of cameras
  91442. */
  91443. cameras?: ICamera[];
  91444. /**
  91445. * Names of glTF extensions used somewhere in this asset
  91446. */
  91447. extensionsUsed?: string[];
  91448. /**
  91449. * Names of glTF extensions required to properly load this asset
  91450. */
  91451. extensionsRequired?: string[];
  91452. /**
  91453. * An array of images. An image defines data used to create a texture
  91454. */
  91455. images?: IImage[];
  91456. /**
  91457. * An array of materials. A material defines the appearance of a primitive
  91458. */
  91459. materials?: IMaterial[];
  91460. /**
  91461. * An array of meshes. A mesh is a set of primitives to be rendered
  91462. */
  91463. meshes?: IMesh[];
  91464. /**
  91465. * An array of nodes
  91466. */
  91467. nodes?: INode[];
  91468. /**
  91469. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  91470. */
  91471. samplers?: ISampler[];
  91472. /**
  91473. * The index of the default scene
  91474. */
  91475. scene?: number;
  91476. /**
  91477. * An array of scenes
  91478. */
  91479. scenes?: IScene[];
  91480. /**
  91481. * An array of skins. A skin is defined by joints and matrices
  91482. */
  91483. skins?: ISkin[];
  91484. /**
  91485. * An array of textures
  91486. */
  91487. textures?: ITexture[];
  91488. }
  91489. /**
  91490. * The glTF validation results
  91491. * @ignore
  91492. */
  91493. interface IGLTFValidationResults {
  91494. info: {
  91495. generator: string;
  91496. hasAnimations: boolean;
  91497. hasDefaultScene: boolean;
  91498. hasMaterials: boolean;
  91499. hasMorphTargets: boolean;
  91500. hasSkins: boolean;
  91501. hasTextures: boolean;
  91502. maxAttributesUsed: number;
  91503. primitivesCount: number
  91504. };
  91505. issues: {
  91506. messages: Array<string>;
  91507. numErrors: number;
  91508. numHints: number;
  91509. numInfos: number;
  91510. numWarnings: number;
  91511. truncated: boolean
  91512. };
  91513. mimeType: string;
  91514. uri: string;
  91515. validatedAt: string;
  91516. validatorVersion: string;
  91517. }
  91518. /**
  91519. * The glTF validation options
  91520. */
  91521. interface IGLTFValidationOptions {
  91522. /** Uri to use */
  91523. uri?: string;
  91524. /** Function used to load external resources */
  91525. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  91526. /** Boolean indicating that we need to validate accessor data */
  91527. validateAccessorData?: boolean;
  91528. /** max number of issues allowed */
  91529. maxIssues?: number;
  91530. /** Ignored issues */
  91531. ignoredIssues?: Array<string>;
  91532. /** Value to override severy settings */
  91533. severityOverrides?: Object;
  91534. }
  91535. /**
  91536. * The glTF validator object
  91537. * @ignore
  91538. */
  91539. interface IGLTFValidator {
  91540. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91541. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91542. }
  91543. /**
  91544. * Interfaces from the EXT_lights_image_based extension
  91545. */
  91546. /** @hidden */
  91547. interface IEXTLightsImageBased_LightReferenceImageBased {
  91548. light: number;
  91549. }
  91550. /** @hidden */
  91551. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  91552. intensity: number;
  91553. rotation: number[];
  91554. specularImageSize: number;
  91555. specularImages: number[][];
  91556. irradianceCoefficients: number[][];
  91557. }
  91558. /** @hidden */
  91559. interface IEXTLightsImageBased {
  91560. lights: IEXTLightsImageBased_LightImageBased[];
  91561. }
  91562. /**
  91563. * Interfaces from the EXT_mesh_gpu_instancing extension
  91564. * !!! Experimental Extension Subject to Changes !!!
  91565. */
  91566. /** @hidden */
  91567. interface IEXTMeshGpuInstancing {
  91568. mesh?: number;
  91569. attributes: { [name: string]: number };
  91570. }
  91571. /**
  91572. * Interfaces from the KHR_draco_mesh_compression extension
  91573. */
  91574. /** @hidden */
  91575. interface IKHRDracoMeshCompression {
  91576. bufferView: number;
  91577. attributes: { [name: string]: number };
  91578. }
  91579. /**
  91580. * Interfaces from the KHR_lights_punctual extension
  91581. */
  91582. /** @hidden */
  91583. const enum IKHRLightsPunctual_LightType {
  91584. DIRECTIONAL = "directional",
  91585. POINT = "point",
  91586. SPOT = "spot"
  91587. }
  91588. /** @hidden */
  91589. interface IKHRLightsPunctual_LightReference {
  91590. light: number;
  91591. }
  91592. /** @hidden */
  91593. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  91594. type: IKHRLightsPunctual_LightType;
  91595. color?: number[];
  91596. intensity?: number;
  91597. range?: number;
  91598. spot?: {
  91599. innerConeAngle?: number;
  91600. outerConeAngle?: number;
  91601. };
  91602. }
  91603. /** @hidden */
  91604. interface IKHRLightsPunctual {
  91605. lights: IKHRLightsPunctual_Light[];
  91606. }
  91607. /**
  91608. * Interfaces from the KHR_materials_clearcoat extension
  91609. * !!! Experimental Extension Subject to Changes !!!
  91610. */
  91611. /** @hidden */
  91612. interface IKHRMaterialsClearcoat {
  91613. clearcoatFactor: number;
  91614. clearcoatTexture: ITextureInfo;
  91615. clearcoatRoughnessFactor: number;
  91616. clearcoatRoughnessTexture: ITextureInfo;
  91617. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  91618. }
  91619. /**
  91620. * Interfaces from the KHR_materials_ior extension
  91621. * !!! Experimental Extension Subject to Changes !!!
  91622. */
  91623. /** @hidden */
  91624. interface IKHRMaterialsIor {
  91625. ior: number;
  91626. }
  91627. /**
  91628. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  91629. */
  91630. /** @hidden */
  91631. interface IKHRMaterialsPbrSpecularGlossiness {
  91632. diffuseFactor: number[];
  91633. diffuseTexture: ITextureInfo;
  91634. specularFactor: number[];
  91635. glossinessFactor: number;
  91636. specularGlossinessTexture: ITextureInfo;
  91637. }
  91638. /**
  91639. * Interfaces from the KHR_materials_sheen extension
  91640. * !!! Experimental Extension Subject to Changes !!!
  91641. */
  91642. /** @hidden */
  91643. interface IKHRMaterialsSheen {
  91644. sheenColorFactor?: number[];
  91645. sheenColorTexture?: ITextureInfo;
  91646. sheenRoughnessFactor?: number;
  91647. sheenRoughnessTexture?: ITextureInfo;
  91648. }
  91649. /**
  91650. * Interfaces from the KHR_materials_specular extension
  91651. * !!! Experimental Extension Subject to Changes !!!
  91652. */
  91653. /** @hidden */
  91654. interface IKHRMaterialsSpecular {
  91655. specularFactor: number;
  91656. specularColorFactor: number[];
  91657. specularTexture: ITextureInfo;
  91658. }
  91659. /**
  91660. * Interfaces from the KHR_materials_transmission extension
  91661. * !!! Experimental Extension Subject to Changes !!!
  91662. */
  91663. /** @hidden */
  91664. interface IKHRMaterialsTransmission {
  91665. transmissionFactor?: number;
  91666. transmissionTexture?: ITextureInfo;
  91667. }
  91668. /**
  91669. * Interfaces from the KHR_materials_translucency extension
  91670. * !!! Experimental Extension Subject to Changes !!!
  91671. */
  91672. /** @hidden */
  91673. interface IKHRMaterialsTranslucency {
  91674. translucencyFactor?: number;
  91675. translucencyTexture?: ITextureInfo;
  91676. }
  91677. /**
  91678. * Interfaces from the KHR_materials_variants extension
  91679. * !!! Experimental Extension Subject to Changes !!!
  91680. */
  91681. /** @hidden */
  91682. interface IKHRMaterialVariants_Mapping extends IProperty {
  91683. mappings: Array<{
  91684. variants: number[];
  91685. material: number;
  91686. }>;
  91687. }
  91688. /** @hidden */
  91689. interface IKHRMaterialVariants_Variant extends IProperty {
  91690. name: string;
  91691. }
  91692. /** @hidden */
  91693. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  91694. variants: Array<IKHRMaterialVariants_Variant>;
  91695. }
  91696. /**
  91697. * Interfaces from the KHR_texture_basisu extension
  91698. * !!! Experimental Extension Subject to Changes !!!
  91699. */
  91700. /** @hidden */
  91701. interface IKHRTextureBasisU {
  91702. source: number;
  91703. }
  91704. /**
  91705. * Interfaces from the EXT_texture_webp extension
  91706. */
  91707. /** @hidden */
  91708. interface IEXTTextureWebP {
  91709. source: number;
  91710. }
  91711. /**
  91712. * Interfaces from the KHR_texture_transform extension
  91713. */
  91714. /** @hidden */
  91715. interface IKHRTextureTransform {
  91716. offset?: number[];
  91717. rotation?: number;
  91718. scale?: number[];
  91719. texCoord?: number;
  91720. }
  91721. /**
  91722. * Interfaces from the KHR_xmp_json_ld extension
  91723. * !!! Experimental Extension Subject to Changes !!!
  91724. */
  91725. /** @hidden */
  91726. interface IKHRXmpJsonLd_Gltf {
  91727. packets: Array<{
  91728. [key: string]: unknown;
  91729. }>;
  91730. }
  91731. /** @hidden */
  91732. interface IKHRXmpJsonLd_Node {
  91733. packet: number;
  91734. }
  91735. /**
  91736. * Interfaces from the MSFT_audio_emitter extension
  91737. */
  91738. /** @hidden */
  91739. interface IMSFTAudioEmitter_ClipReference {
  91740. clip: number;
  91741. weight?: number;
  91742. }
  91743. /** @hidden */
  91744. interface IMSFTAudioEmitter_EmittersReference {
  91745. emitters: number[];
  91746. }
  91747. /** @hidden */
  91748. const enum IMSFTAudioEmitter_DistanceModel {
  91749. linear = "linear",
  91750. inverse = "inverse",
  91751. exponential = "exponential",
  91752. }
  91753. /** @hidden */
  91754. interface IMSFTAudioEmitter_Emitter {
  91755. name?: string;
  91756. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  91757. refDistance?: number;
  91758. maxDistance?: number;
  91759. rolloffFactor?: number;
  91760. innerAngle?: number;
  91761. outerAngle?: number;
  91762. loop?: boolean;
  91763. volume?: number;
  91764. clips: IMSFTAudioEmitter_ClipReference[];
  91765. }
  91766. /** @hidden */
  91767. const enum IMSFTAudioEmitter_AudioMimeType {
  91768. WAV = "audio/wav",
  91769. }
  91770. /** @hidden */
  91771. interface IMSFTAudioEmitter_Clip extends IProperty {
  91772. uri?: string;
  91773. bufferView?: number;
  91774. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  91775. }
  91776. /** @hidden */
  91777. const enum IMSFTAudioEmitter_AnimationEventAction {
  91778. play = "play",
  91779. pause = "pause",
  91780. stop = "stop",
  91781. }
  91782. /** @hidden */
  91783. interface IMSFTAudioEmitter_AnimationEvent {
  91784. action: IMSFTAudioEmitter_AnimationEventAction;
  91785. emitter: number;
  91786. time: number;
  91787. startOffset?: number;
  91788. }
  91789. /**
  91790. * Interfaces from the MSFT_lod extension
  91791. */
  91792. /** @hidden */
  91793. interface IMSFTLOD {
  91794. ids: number[];
  91795. }
  91796. /**
  91797. * Interfaces from the EXT_meshopt_compression extension
  91798. */
  91799. /** @hidden */
  91800. interface IEXTMeshoptCompression {
  91801. buffer: number;
  91802. byteOffset?: number;
  91803. byteLength: number;
  91804. byteStride: number;
  91805. count: number;
  91806. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  91807. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  91808. }
  91809. }
  91810. declare module BABYLON {
  91811. /** @hidden */
  91812. export var cellPixelShader: {
  91813. name: string;
  91814. shader: string;
  91815. };
  91816. }
  91817. declare module BABYLON {
  91818. /** @hidden */
  91819. export var cellVertexShader: {
  91820. name: string;
  91821. shader: string;
  91822. };
  91823. }
  91824. declare module BABYLON {
  91825. export class CellMaterial extends BABYLON.PushMaterial {
  91826. private _diffuseTexture;
  91827. diffuseTexture: BABYLON.BaseTexture;
  91828. diffuseColor: BABYLON.Color3;
  91829. _computeHighLevel: boolean;
  91830. computeHighLevel: boolean;
  91831. private _disableLighting;
  91832. disableLighting: boolean;
  91833. private _maxSimultaneousLights;
  91834. maxSimultaneousLights: number;
  91835. constructor(name: string, scene: BABYLON.Scene);
  91836. needAlphaBlending(): boolean;
  91837. needAlphaTesting(): boolean;
  91838. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91839. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91840. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91841. getAnimatables(): BABYLON.IAnimatable[];
  91842. getActiveTextures(): BABYLON.BaseTexture[];
  91843. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91844. dispose(forceDisposeEffect?: boolean): void;
  91845. getClassName(): string;
  91846. clone(name: string): CellMaterial;
  91847. serialize(): any;
  91848. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  91849. }
  91850. }
  91851. declare module BABYLON {
  91852. export class CustomShaderStructure {
  91853. FragmentStore: string;
  91854. VertexStore: string;
  91855. constructor();
  91856. }
  91857. export class ShaderSpecialParts {
  91858. constructor();
  91859. Fragment_Begin: string;
  91860. Fragment_Definitions: string;
  91861. Fragment_MainBegin: string;
  91862. Fragment_Custom_Diffuse: string;
  91863. Fragment_Before_Lights: string;
  91864. Fragment_Before_Fog: string;
  91865. Fragment_Custom_Alpha: string;
  91866. Fragment_Before_FragColor: string;
  91867. Vertex_Begin: string;
  91868. Vertex_Definitions: string;
  91869. Vertex_MainBegin: string;
  91870. Vertex_Before_PositionUpdated: string;
  91871. Vertex_Before_NormalUpdated: string;
  91872. Vertex_After_WorldPosComputed: string;
  91873. Vertex_MainEnd: string;
  91874. }
  91875. export class CustomMaterial extends BABYLON.StandardMaterial {
  91876. static ShaderIndexer: number;
  91877. CustomParts: ShaderSpecialParts;
  91878. _isCreatedShader: boolean;
  91879. _createdShaderName: string;
  91880. _customUniform: string[];
  91881. _newUniforms: string[];
  91882. _newUniformInstances: {
  91883. [name: string]: any;
  91884. };
  91885. _newSamplerInstances: {
  91886. [name: string]: BABYLON.Texture;
  91887. };
  91888. _customAttributes: string[];
  91889. FragmentShader: string;
  91890. VertexShader: string;
  91891. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91892. ReviewUniform(name: string, arr: string[]): string[];
  91893. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91894. constructor(name: string, scene: BABYLON.Scene);
  91895. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  91896. AddAttribute(name: string): CustomMaterial;
  91897. Fragment_Begin(shaderPart: string): CustomMaterial;
  91898. Fragment_Definitions(shaderPart: string): CustomMaterial;
  91899. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  91900. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  91901. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  91902. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  91903. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  91904. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  91905. Vertex_Begin(shaderPart: string): CustomMaterial;
  91906. Vertex_Definitions(shaderPart: string): CustomMaterial;
  91907. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  91908. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  91909. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  91910. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  91911. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  91912. }
  91913. }
  91914. declare module BABYLON {
  91915. export class ShaderAlebdoParts {
  91916. constructor();
  91917. Fragment_Begin: string;
  91918. Fragment_Definitions: string;
  91919. Fragment_MainBegin: string;
  91920. Fragment_Custom_Albedo: string;
  91921. Fragment_Before_Lights: string;
  91922. Fragment_Custom_MetallicRoughness: string;
  91923. Fragment_Custom_MicroSurface: string;
  91924. Fragment_Before_Fog: string;
  91925. Fragment_Custom_Alpha: string;
  91926. Fragment_Before_FragColor: string;
  91927. Vertex_Begin: string;
  91928. Vertex_Definitions: string;
  91929. Vertex_MainBegin: string;
  91930. Vertex_Before_PositionUpdated: string;
  91931. Vertex_Before_NormalUpdated: string;
  91932. Vertex_After_WorldPosComputed: string;
  91933. Vertex_MainEnd: string;
  91934. }
  91935. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  91936. static ShaderIndexer: number;
  91937. CustomParts: ShaderAlebdoParts;
  91938. _isCreatedShader: boolean;
  91939. _createdShaderName: string;
  91940. _customUniform: string[];
  91941. _newUniforms: string[];
  91942. _newUniformInstances: {
  91943. [name: string]: any;
  91944. };
  91945. _newSamplerInstances: {
  91946. [name: string]: BABYLON.Texture;
  91947. };
  91948. _customAttributes: string[];
  91949. FragmentShader: string;
  91950. VertexShader: string;
  91951. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91952. ReviewUniform(name: string, arr: string[]): string[];
  91953. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[], options?: BABYLON.ICustomShaderNameResolveOptions): string;
  91954. constructor(name: string, scene: BABYLON.Scene);
  91955. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  91956. AddAttribute(name: string): PBRCustomMaterial;
  91957. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  91958. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  91959. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  91960. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  91961. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  91962. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  91963. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  91964. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  91965. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  91966. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  91967. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  91968. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  91969. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  91970. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  91971. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  91972. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  91973. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  91974. }
  91975. }
  91976. declare module BABYLON {
  91977. /** @hidden */
  91978. export var firePixelShader: {
  91979. name: string;
  91980. shader: string;
  91981. };
  91982. }
  91983. declare module BABYLON {
  91984. /** @hidden */
  91985. export var fireVertexShader: {
  91986. name: string;
  91987. shader: string;
  91988. };
  91989. }
  91990. declare module BABYLON {
  91991. export class FireMaterial extends BABYLON.PushMaterial {
  91992. private _diffuseTexture;
  91993. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91994. private _distortionTexture;
  91995. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91996. private _opacityTexture;
  91997. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91998. diffuseColor: BABYLON.Color3;
  91999. speed: number;
  92000. private _scaledDiffuse;
  92001. private _lastTime;
  92002. constructor(name: string, scene: BABYLON.Scene);
  92003. needAlphaBlending(): boolean;
  92004. needAlphaTesting(): boolean;
  92005. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92006. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92007. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92008. getAnimatables(): BABYLON.IAnimatable[];
  92009. getActiveTextures(): BABYLON.BaseTexture[];
  92010. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92011. getClassName(): string;
  92012. dispose(forceDisposeEffect?: boolean): void;
  92013. clone(name: string): FireMaterial;
  92014. serialize(): any;
  92015. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  92016. }
  92017. }
  92018. declare module BABYLON {
  92019. /** @hidden */
  92020. export var furPixelShader: {
  92021. name: string;
  92022. shader: string;
  92023. };
  92024. }
  92025. declare module BABYLON {
  92026. /** @hidden */
  92027. export var furVertexShader: {
  92028. name: string;
  92029. shader: string;
  92030. };
  92031. }
  92032. declare module BABYLON {
  92033. export class FurMaterial extends BABYLON.PushMaterial {
  92034. private _diffuseTexture;
  92035. diffuseTexture: BABYLON.BaseTexture;
  92036. private _heightTexture;
  92037. heightTexture: BABYLON.BaseTexture;
  92038. diffuseColor: BABYLON.Color3;
  92039. furLength: number;
  92040. furAngle: number;
  92041. furColor: BABYLON.Color3;
  92042. furOffset: number;
  92043. furSpacing: number;
  92044. furGravity: BABYLON.Vector3;
  92045. furSpeed: number;
  92046. furDensity: number;
  92047. furOcclusion: number;
  92048. furTexture: BABYLON.DynamicTexture;
  92049. private _disableLighting;
  92050. disableLighting: boolean;
  92051. private _maxSimultaneousLights;
  92052. maxSimultaneousLights: number;
  92053. highLevelFur: boolean;
  92054. _meshes: BABYLON.AbstractMesh[];
  92055. private _furTime;
  92056. constructor(name: string, scene: BABYLON.Scene);
  92057. get furTime(): number;
  92058. set furTime(furTime: number);
  92059. needAlphaBlending(): boolean;
  92060. needAlphaTesting(): boolean;
  92061. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92062. updateFur(): void;
  92063. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92064. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92065. getAnimatables(): BABYLON.IAnimatable[];
  92066. getActiveTextures(): BABYLON.BaseTexture[];
  92067. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92068. dispose(forceDisposeEffect?: boolean): void;
  92069. clone(name: string): FurMaterial;
  92070. serialize(): any;
  92071. getClassName(): string;
  92072. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  92073. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  92074. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  92075. }
  92076. }
  92077. declare module BABYLON {
  92078. /** @hidden */
  92079. export var gradientPixelShader: {
  92080. name: string;
  92081. shader: string;
  92082. };
  92083. }
  92084. declare module BABYLON {
  92085. /** @hidden */
  92086. export var gradientVertexShader: {
  92087. name: string;
  92088. shader: string;
  92089. };
  92090. }
  92091. declare module BABYLON {
  92092. export class GradientMaterial extends BABYLON.PushMaterial {
  92093. private _maxSimultaneousLights;
  92094. maxSimultaneousLights: number;
  92095. topColor: BABYLON.Color3;
  92096. topColorAlpha: number;
  92097. bottomColor: BABYLON.Color3;
  92098. bottomColorAlpha: number;
  92099. offset: number;
  92100. scale: number;
  92101. smoothness: number;
  92102. private _disableLighting;
  92103. disableLighting: boolean;
  92104. constructor(name: string, scene: BABYLON.Scene);
  92105. needAlphaBlending(): boolean;
  92106. needAlphaTesting(): boolean;
  92107. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92108. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92109. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92110. getAnimatables(): BABYLON.IAnimatable[];
  92111. dispose(forceDisposeEffect?: boolean): void;
  92112. clone(name: string): GradientMaterial;
  92113. serialize(): any;
  92114. getClassName(): string;
  92115. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  92116. }
  92117. }
  92118. declare module BABYLON {
  92119. /** @hidden */
  92120. export var gridPixelShader: {
  92121. name: string;
  92122. shader: string;
  92123. };
  92124. }
  92125. declare module BABYLON {
  92126. /** @hidden */
  92127. export var gridVertexShader: {
  92128. name: string;
  92129. shader: string;
  92130. };
  92131. }
  92132. declare module BABYLON {
  92133. /**
  92134. * The grid materials allows you to wrap any shape with a grid.
  92135. * Colors are customizable.
  92136. */
  92137. export class GridMaterial extends BABYLON.PushMaterial {
  92138. /**
  92139. * Main color of the grid (e.g. between lines)
  92140. */
  92141. mainColor: BABYLON.Color3;
  92142. /**
  92143. * Color of the grid lines.
  92144. */
  92145. lineColor: BABYLON.Color3;
  92146. /**
  92147. * The scale of the grid compared to unit.
  92148. */
  92149. gridRatio: number;
  92150. /**
  92151. * Allows setting an offset for the grid lines.
  92152. */
  92153. gridOffset: BABYLON.Vector3;
  92154. /**
  92155. * The frequency of thicker lines.
  92156. */
  92157. majorUnitFrequency: number;
  92158. /**
  92159. * The visibility of minor units in the grid.
  92160. */
  92161. minorUnitVisibility: number;
  92162. /**
  92163. * The grid opacity outside of the lines.
  92164. */
  92165. opacity: number;
  92166. /**
  92167. * Determine RBG output is premultiplied by alpha value.
  92168. */
  92169. preMultiplyAlpha: boolean;
  92170. private _opacityTexture;
  92171. opacityTexture: BABYLON.BaseTexture;
  92172. private _gridControl;
  92173. /**
  92174. * constructor
  92175. * @param name The name given to the material in order to identify it afterwards.
  92176. * @param scene The scene the material is used in.
  92177. */
  92178. constructor(name: string, scene: BABYLON.Scene);
  92179. /**
  92180. * Returns wehter or not the grid requires alpha blending.
  92181. */
  92182. needAlphaBlending(): boolean;
  92183. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92184. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92185. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92186. /**
  92187. * Dispose the material and its associated resources.
  92188. * @param forceDisposeEffect will also dispose the used effect when true
  92189. */
  92190. dispose(forceDisposeEffect?: boolean): void;
  92191. clone(name: string): GridMaterial;
  92192. serialize(): any;
  92193. getClassName(): string;
  92194. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  92195. }
  92196. }
  92197. declare module BABYLON {
  92198. /** @hidden */
  92199. export var lavaPixelShader: {
  92200. name: string;
  92201. shader: string;
  92202. };
  92203. }
  92204. declare module BABYLON {
  92205. /** @hidden */
  92206. export var lavaVertexShader: {
  92207. name: string;
  92208. shader: string;
  92209. };
  92210. }
  92211. declare module BABYLON {
  92212. export class LavaMaterial extends BABYLON.PushMaterial {
  92213. private _diffuseTexture;
  92214. diffuseTexture: BABYLON.BaseTexture;
  92215. noiseTexture: BABYLON.BaseTexture;
  92216. fogColor: BABYLON.Color3;
  92217. speed: number;
  92218. movingSpeed: number;
  92219. lowFrequencySpeed: number;
  92220. fogDensity: number;
  92221. private _lastTime;
  92222. diffuseColor: BABYLON.Color3;
  92223. private _disableLighting;
  92224. disableLighting: boolean;
  92225. private _unlit;
  92226. unlit: boolean;
  92227. private _maxSimultaneousLights;
  92228. maxSimultaneousLights: number;
  92229. private _scaledDiffuse;
  92230. constructor(name: string, scene: BABYLON.Scene);
  92231. needAlphaBlending(): boolean;
  92232. needAlphaTesting(): boolean;
  92233. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92234. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92235. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92236. getAnimatables(): BABYLON.IAnimatable[];
  92237. getActiveTextures(): BABYLON.BaseTexture[];
  92238. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92239. dispose(forceDisposeEffect?: boolean): void;
  92240. clone(name: string): LavaMaterial;
  92241. serialize(): any;
  92242. getClassName(): string;
  92243. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  92244. }
  92245. }
  92246. declare module BABYLON {
  92247. /** @hidden */
  92248. export var mixPixelShader: {
  92249. name: string;
  92250. shader: string;
  92251. };
  92252. }
  92253. declare module BABYLON {
  92254. /** @hidden */
  92255. export var mixVertexShader: {
  92256. name: string;
  92257. shader: string;
  92258. };
  92259. }
  92260. declare module BABYLON {
  92261. export class MixMaterial extends BABYLON.PushMaterial {
  92262. /**
  92263. * Mix textures
  92264. */
  92265. private _mixTexture1;
  92266. mixTexture1: BABYLON.BaseTexture;
  92267. private _mixTexture2;
  92268. mixTexture2: BABYLON.BaseTexture;
  92269. /**
  92270. * Diffuse textures
  92271. */
  92272. private _diffuseTexture1;
  92273. diffuseTexture1: BABYLON.Texture;
  92274. private _diffuseTexture2;
  92275. diffuseTexture2: BABYLON.Texture;
  92276. private _diffuseTexture3;
  92277. diffuseTexture3: BABYLON.Texture;
  92278. private _diffuseTexture4;
  92279. diffuseTexture4: BABYLON.Texture;
  92280. private _diffuseTexture5;
  92281. diffuseTexture5: BABYLON.Texture;
  92282. private _diffuseTexture6;
  92283. diffuseTexture6: BABYLON.Texture;
  92284. private _diffuseTexture7;
  92285. diffuseTexture7: BABYLON.Texture;
  92286. private _diffuseTexture8;
  92287. diffuseTexture8: BABYLON.Texture;
  92288. /**
  92289. * Uniforms
  92290. */
  92291. diffuseColor: BABYLON.Color3;
  92292. specularColor: BABYLON.Color3;
  92293. specularPower: number;
  92294. private _disableLighting;
  92295. disableLighting: boolean;
  92296. private _maxSimultaneousLights;
  92297. maxSimultaneousLights: number;
  92298. constructor(name: string, scene: BABYLON.Scene);
  92299. needAlphaBlending(): boolean;
  92300. needAlphaTesting(): boolean;
  92301. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92302. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92303. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92304. getAnimatables(): BABYLON.IAnimatable[];
  92305. getActiveTextures(): BABYLON.BaseTexture[];
  92306. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92307. dispose(forceDisposeEffect?: boolean): void;
  92308. clone(name: string): MixMaterial;
  92309. serialize(): any;
  92310. getClassName(): string;
  92311. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  92312. }
  92313. }
  92314. declare module BABYLON {
  92315. /** @hidden */
  92316. export var normalPixelShader: {
  92317. name: string;
  92318. shader: string;
  92319. };
  92320. }
  92321. declare module BABYLON {
  92322. /** @hidden */
  92323. export var normalVertexShader: {
  92324. name: string;
  92325. shader: string;
  92326. };
  92327. }
  92328. declare module BABYLON {
  92329. export class NormalMaterial extends BABYLON.PushMaterial {
  92330. private _diffuseTexture;
  92331. diffuseTexture: BABYLON.BaseTexture;
  92332. diffuseColor: BABYLON.Color3;
  92333. private _disableLighting;
  92334. disableLighting: boolean;
  92335. private _maxSimultaneousLights;
  92336. maxSimultaneousLights: number;
  92337. constructor(name: string, scene: BABYLON.Scene);
  92338. needAlphaBlending(): boolean;
  92339. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92340. needAlphaTesting(): boolean;
  92341. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92342. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92343. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92344. getAnimatables(): BABYLON.IAnimatable[];
  92345. getActiveTextures(): BABYLON.BaseTexture[];
  92346. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92347. dispose(forceDisposeEffect?: boolean): void;
  92348. clone(name: string): NormalMaterial;
  92349. serialize(): any;
  92350. getClassName(): string;
  92351. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  92352. }
  92353. }
  92354. declare module BABYLON {
  92355. /** @hidden */
  92356. export var shadowOnlyPixelShader: {
  92357. name: string;
  92358. shader: string;
  92359. };
  92360. }
  92361. declare module BABYLON {
  92362. /** @hidden */
  92363. export var shadowOnlyVertexShader: {
  92364. name: string;
  92365. shader: string;
  92366. };
  92367. }
  92368. declare module BABYLON {
  92369. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  92370. private _activeLight;
  92371. private _needAlphaBlending;
  92372. constructor(name: string, scene: BABYLON.Scene);
  92373. shadowColor: BABYLON.Color3;
  92374. needAlphaBlending(): boolean;
  92375. needAlphaTesting(): boolean;
  92376. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92377. get activeLight(): BABYLON.IShadowLight;
  92378. set activeLight(light: BABYLON.IShadowLight);
  92379. private _getFirstShadowLightForMesh;
  92380. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92381. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92382. clone(name: string): ShadowOnlyMaterial;
  92383. serialize(): any;
  92384. getClassName(): string;
  92385. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  92386. }
  92387. }
  92388. declare module BABYLON {
  92389. /** @hidden */
  92390. export var simplePixelShader: {
  92391. name: string;
  92392. shader: string;
  92393. };
  92394. }
  92395. declare module BABYLON {
  92396. /** @hidden */
  92397. export var simpleVertexShader: {
  92398. name: string;
  92399. shader: string;
  92400. };
  92401. }
  92402. declare module BABYLON {
  92403. export class SimpleMaterial extends BABYLON.PushMaterial {
  92404. private _diffuseTexture;
  92405. diffuseTexture: BABYLON.BaseTexture;
  92406. diffuseColor: BABYLON.Color3;
  92407. private _disableLighting;
  92408. disableLighting: boolean;
  92409. private _maxSimultaneousLights;
  92410. maxSimultaneousLights: number;
  92411. constructor(name: string, scene: BABYLON.Scene);
  92412. needAlphaBlending(): boolean;
  92413. needAlphaTesting(): boolean;
  92414. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92415. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92416. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92417. getAnimatables(): BABYLON.IAnimatable[];
  92418. getActiveTextures(): BABYLON.BaseTexture[];
  92419. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92420. dispose(forceDisposeEffect?: boolean): void;
  92421. clone(name: string): SimpleMaterial;
  92422. serialize(): any;
  92423. getClassName(): string;
  92424. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  92425. }
  92426. }
  92427. declare module BABYLON {
  92428. /** @hidden */
  92429. export var skyPixelShader: {
  92430. name: string;
  92431. shader: string;
  92432. };
  92433. }
  92434. declare module BABYLON {
  92435. /** @hidden */
  92436. export var skyVertexShader: {
  92437. name: string;
  92438. shader: string;
  92439. };
  92440. }
  92441. declare module BABYLON {
  92442. /**
  92443. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  92444. * @see https://doc.babylonjs.com/extensions/sky
  92445. */
  92446. export class SkyMaterial extends BABYLON.PushMaterial {
  92447. /**
  92448. * Defines the overall luminance of sky in interval ]0, 1[.
  92449. */
  92450. luminance: number;
  92451. /**
  92452. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  92453. */
  92454. turbidity: number;
  92455. /**
  92456. * Defines the sky appearance (light intensity).
  92457. */
  92458. rayleigh: number;
  92459. /**
  92460. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  92461. */
  92462. mieCoefficient: number;
  92463. /**
  92464. * Defines the amount of haze particles following the Mie scattering theory.
  92465. */
  92466. mieDirectionalG: number;
  92467. /**
  92468. * Defines the distance of the sun according to the active scene camera.
  92469. */
  92470. distance: number;
  92471. /**
  92472. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  92473. * "inclined".
  92474. */
  92475. inclination: number;
  92476. /**
  92477. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  92478. * an object direction and a reference direction.
  92479. */
  92480. azimuth: number;
  92481. /**
  92482. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  92483. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  92484. */
  92485. sunPosition: BABYLON.Vector3;
  92486. /**
  92487. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  92488. * .sunPosition property.
  92489. */
  92490. useSunPosition: boolean;
  92491. /**
  92492. * Defines an offset vector used to get a horizon offset.
  92493. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  92494. */
  92495. cameraOffset: BABYLON.Vector3;
  92496. /**
  92497. * Defines the vector the skyMaterial should consider as up. (default is BABYLON.Vector3(0, 1, 0) as returned by BABYLON.Vector3.Up())
  92498. */
  92499. up: BABYLON.Vector3;
  92500. private _cameraPosition;
  92501. private _skyOrientation;
  92502. /**
  92503. * Instantiates a new sky material.
  92504. * This material allows to create dynamic and texture free
  92505. * effects for skyboxes by taking care of the atmosphere state.
  92506. * @see https://doc.babylonjs.com/extensions/sky
  92507. * @param name Define the name of the material in the scene
  92508. * @param scene Define the scene the material belong to
  92509. */
  92510. constructor(name: string, scene: BABYLON.Scene);
  92511. /**
  92512. * Specifies if the material will require alpha blending
  92513. * @returns a boolean specifying if alpha blending is needed
  92514. */
  92515. needAlphaBlending(): boolean;
  92516. /**
  92517. * Specifies if this material should be rendered in alpha test mode
  92518. * @returns false as the sky material doesn't need alpha testing.
  92519. */
  92520. needAlphaTesting(): boolean;
  92521. /**
  92522. * Get the texture used for alpha test purpose.
  92523. * @returns null as the sky material has no texture.
  92524. */
  92525. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92526. /**
  92527. * Get if the submesh is ready to be used and all its information available.
  92528. * Child classes can use it to update shaders
  92529. * @param mesh defines the mesh to check
  92530. * @param subMesh defines which submesh to check
  92531. * @param useInstances specifies that instances should be used
  92532. * @returns a boolean indicating that the submesh is ready or not
  92533. */
  92534. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92535. /**
  92536. * Binds the submesh to this material by preparing the effect and shader to draw
  92537. * @param world defines the world transformation matrix
  92538. * @param mesh defines the mesh containing the submesh
  92539. * @param subMesh defines the submesh to bind the material to
  92540. */
  92541. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92542. /**
  92543. * Get the list of animatables in the material.
  92544. * @returns the list of animatables object used in the material
  92545. */
  92546. getAnimatables(): BABYLON.IAnimatable[];
  92547. /**
  92548. * Disposes the material
  92549. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92550. */
  92551. dispose(forceDisposeEffect?: boolean): void;
  92552. /**
  92553. * Makes a duplicate of the material, and gives it a new name
  92554. * @param name defines the new name for the duplicated material
  92555. * @returns the cloned material
  92556. */
  92557. clone(name: string): SkyMaterial;
  92558. /**
  92559. * Serializes this material in a JSON representation
  92560. * @returns the serialized material object
  92561. */
  92562. serialize(): any;
  92563. /**
  92564. * Gets the current class name of the material e.g. "SkyMaterial"
  92565. * Mainly use in serialization.
  92566. * @returns the class name
  92567. */
  92568. getClassName(): string;
  92569. /**
  92570. * Creates a sky material from parsed material data
  92571. * @param source defines the JSON representation of the material
  92572. * @param scene defines the hosting scene
  92573. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92574. * @returns a new sky material
  92575. */
  92576. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  92577. }
  92578. }
  92579. declare module BABYLON {
  92580. /** @hidden */
  92581. export var terrainPixelShader: {
  92582. name: string;
  92583. shader: string;
  92584. };
  92585. }
  92586. declare module BABYLON {
  92587. /** @hidden */
  92588. export var terrainVertexShader: {
  92589. name: string;
  92590. shader: string;
  92591. };
  92592. }
  92593. declare module BABYLON {
  92594. export class TerrainMaterial extends BABYLON.PushMaterial {
  92595. private _mixTexture;
  92596. mixTexture: BABYLON.BaseTexture;
  92597. private _diffuseTexture1;
  92598. diffuseTexture1: BABYLON.Texture;
  92599. private _diffuseTexture2;
  92600. diffuseTexture2: BABYLON.Texture;
  92601. private _diffuseTexture3;
  92602. diffuseTexture3: BABYLON.Texture;
  92603. private _bumpTexture1;
  92604. bumpTexture1: BABYLON.Texture;
  92605. private _bumpTexture2;
  92606. bumpTexture2: BABYLON.Texture;
  92607. private _bumpTexture3;
  92608. bumpTexture3: BABYLON.Texture;
  92609. diffuseColor: BABYLON.Color3;
  92610. specularColor: BABYLON.Color3;
  92611. specularPower: number;
  92612. private _disableLighting;
  92613. disableLighting: boolean;
  92614. private _maxSimultaneousLights;
  92615. maxSimultaneousLights: number;
  92616. constructor(name: string, scene: BABYLON.Scene);
  92617. needAlphaBlending(): boolean;
  92618. needAlphaTesting(): boolean;
  92619. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92620. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92621. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92622. getAnimatables(): BABYLON.IAnimatable[];
  92623. getActiveTextures(): BABYLON.BaseTexture[];
  92624. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92625. dispose(forceDisposeEffect?: boolean): void;
  92626. clone(name: string): TerrainMaterial;
  92627. serialize(): any;
  92628. getClassName(): string;
  92629. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  92630. }
  92631. }
  92632. declare module BABYLON {
  92633. /** @hidden */
  92634. export var triplanarPixelShader: {
  92635. name: string;
  92636. shader: string;
  92637. };
  92638. }
  92639. declare module BABYLON {
  92640. /** @hidden */
  92641. export var triplanarVertexShader: {
  92642. name: string;
  92643. shader: string;
  92644. };
  92645. }
  92646. declare module BABYLON {
  92647. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  92648. mixTexture: BABYLON.BaseTexture;
  92649. private _diffuseTextureX;
  92650. diffuseTextureX: BABYLON.BaseTexture;
  92651. private _diffuseTextureY;
  92652. diffuseTextureY: BABYLON.BaseTexture;
  92653. private _diffuseTextureZ;
  92654. diffuseTextureZ: BABYLON.BaseTexture;
  92655. private _normalTextureX;
  92656. normalTextureX: BABYLON.BaseTexture;
  92657. private _normalTextureY;
  92658. normalTextureY: BABYLON.BaseTexture;
  92659. private _normalTextureZ;
  92660. normalTextureZ: BABYLON.BaseTexture;
  92661. tileSize: number;
  92662. diffuseColor: BABYLON.Color3;
  92663. specularColor: BABYLON.Color3;
  92664. specularPower: number;
  92665. private _disableLighting;
  92666. disableLighting: boolean;
  92667. private _maxSimultaneousLights;
  92668. maxSimultaneousLights: number;
  92669. constructor(name: string, scene: BABYLON.Scene);
  92670. needAlphaBlending(): boolean;
  92671. needAlphaTesting(): boolean;
  92672. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92673. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92674. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92675. getAnimatables(): BABYLON.IAnimatable[];
  92676. getActiveTextures(): BABYLON.BaseTexture[];
  92677. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92678. dispose(forceDisposeEffect?: boolean): void;
  92679. clone(name: string): TriPlanarMaterial;
  92680. serialize(): any;
  92681. getClassName(): string;
  92682. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  92683. }
  92684. }
  92685. declare module BABYLON {
  92686. /** @hidden */
  92687. export var waterPixelShader: {
  92688. name: string;
  92689. shader: string;
  92690. };
  92691. }
  92692. declare module BABYLON {
  92693. /** @hidden */
  92694. export var waterVertexShader: {
  92695. name: string;
  92696. shader: string;
  92697. };
  92698. }
  92699. declare module BABYLON {
  92700. export class WaterMaterial extends BABYLON.PushMaterial {
  92701. renderTargetSize: BABYLON.Vector2;
  92702. private _bumpTexture;
  92703. bumpTexture: BABYLON.BaseTexture;
  92704. diffuseColor: BABYLON.Color3;
  92705. specularColor: BABYLON.Color3;
  92706. specularPower: number;
  92707. private _disableLighting;
  92708. disableLighting: boolean;
  92709. private _maxSimultaneousLights;
  92710. maxSimultaneousLights: number;
  92711. /**
  92712. * Defines the wind force.
  92713. */
  92714. windForce: number;
  92715. /**
  92716. * Defines the direction of the wind in the plane (X, Z).
  92717. */
  92718. windDirection: BABYLON.Vector2;
  92719. /**
  92720. * Defines the height of the waves.
  92721. */
  92722. waveHeight: number;
  92723. /**
  92724. * Defines the bump height related to the bump map.
  92725. */
  92726. bumpHeight: number;
  92727. /**
  92728. * Defines wether or not: to add a smaller moving bump to less steady waves.
  92729. */
  92730. private _bumpSuperimpose;
  92731. bumpSuperimpose: boolean;
  92732. /**
  92733. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  92734. */
  92735. private _fresnelSeparate;
  92736. fresnelSeparate: boolean;
  92737. /**
  92738. * Defines wether or not bump Wwves modify the reflection.
  92739. */
  92740. private _bumpAffectsReflection;
  92741. bumpAffectsReflection: boolean;
  92742. /**
  92743. * Defines the water color blended with the refraction (near).
  92744. */
  92745. waterColor: BABYLON.Color3;
  92746. /**
  92747. * Defines the blend factor related to the water color.
  92748. */
  92749. colorBlendFactor: number;
  92750. /**
  92751. * Defines the water color blended with the reflection (far).
  92752. */
  92753. waterColor2: BABYLON.Color3;
  92754. /**
  92755. * Defines the blend factor related to the water color (reflection, far).
  92756. */
  92757. colorBlendFactor2: number;
  92758. /**
  92759. * Defines the maximum length of a wave.
  92760. */
  92761. waveLength: number;
  92762. /**
  92763. * Defines the waves speed.
  92764. */
  92765. waveSpeed: number;
  92766. /**
  92767. * Defines the number of times waves are repeated. This is typically used to adjust waves count according to the ground's size where the material is applied on.
  92768. */
  92769. waveCount: number;
  92770. /**
  92771. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  92772. * will avoid calculating useless pixels in the pixel shader of the water material.
  92773. */
  92774. disableClipPlane: boolean;
  92775. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  92776. private _mesh;
  92777. private _refractionRTT;
  92778. private _reflectionRTT;
  92779. private _reflectionTransform;
  92780. private _lastTime;
  92781. private _lastDeltaTime;
  92782. private _useLogarithmicDepth;
  92783. private _waitingRenderList;
  92784. private _imageProcessingConfiguration;
  92785. private _imageProcessingObserver;
  92786. /**
  92787. * Gets a boolean indicating that current material needs to register RTT
  92788. */
  92789. get hasRenderTargetTextures(): boolean;
  92790. /**
  92791. * Constructor
  92792. */
  92793. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  92794. get useLogarithmicDepth(): boolean;
  92795. set useLogarithmicDepth(value: boolean);
  92796. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92797. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92798. addToRenderList(node: any): void;
  92799. enableRenderTargets(enable: boolean): void;
  92800. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  92801. get renderTargetsEnabled(): boolean;
  92802. needAlphaBlending(): boolean;
  92803. needAlphaTesting(): boolean;
  92804. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92805. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92806. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92807. private _createRenderTargets;
  92808. getAnimatables(): BABYLON.IAnimatable[];
  92809. getActiveTextures(): BABYLON.BaseTexture[];
  92810. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92811. dispose(forceDisposeEffect?: boolean): void;
  92812. clone(name: string): WaterMaterial;
  92813. serialize(): any;
  92814. getClassName(): string;
  92815. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  92816. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  92817. }
  92818. }
  92819. declare module BABYLON {
  92820. /** @hidden */
  92821. export var asciiartPixelShader: {
  92822. name: string;
  92823. shader: string;
  92824. };
  92825. }
  92826. declare module BABYLON {
  92827. /**
  92828. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  92829. *
  92830. * It basically takes care rendering the font front the given font size to a texture.
  92831. * This is used later on in the postprocess.
  92832. */
  92833. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  92834. private _font;
  92835. private _text;
  92836. private _charSize;
  92837. /**
  92838. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92839. */
  92840. get charSize(): number;
  92841. /**
  92842. * Create a new instance of the Ascii Art FontTexture class
  92843. * @param name the name of the texture
  92844. * @param font the font to use, use the W3C CSS notation
  92845. * @param text the caracter set to use in the rendering.
  92846. * @param scene the scene that owns the texture
  92847. */
  92848. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92849. /**
  92850. * Gets the max char width of a font.
  92851. * @param font the font to use, use the W3C CSS notation
  92852. * @return the max char width
  92853. */
  92854. private getFontWidth;
  92855. /**
  92856. * Gets the max char height of a font.
  92857. * @param font the font to use, use the W3C CSS notation
  92858. * @return the max char height
  92859. */
  92860. private getFontHeight;
  92861. /**
  92862. * Clones the current AsciiArtTexture.
  92863. * @return the clone of the texture.
  92864. */
  92865. clone(): AsciiArtFontTexture;
  92866. /**
  92867. * Parses a json object representing the texture and returns an instance of it.
  92868. * @param source the source JSON representation
  92869. * @param scene the scene to create the texture for
  92870. * @return the parsed texture
  92871. */
  92872. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  92873. }
  92874. /**
  92875. * Option available in the Ascii Art Post Process.
  92876. */
  92877. export interface IAsciiArtPostProcessOptions {
  92878. /**
  92879. * The font to use following the w3c font definition.
  92880. */
  92881. font?: string;
  92882. /**
  92883. * The character set to use in the postprocess.
  92884. */
  92885. characterSet?: string;
  92886. /**
  92887. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92888. * This number is defined between 0 and 1;
  92889. */
  92890. mixToTile?: number;
  92891. /**
  92892. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92893. * This number is defined between 0 and 1;
  92894. */
  92895. mixToNormal?: number;
  92896. }
  92897. /**
  92898. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  92899. *
  92900. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92901. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  92902. */
  92903. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  92904. /**
  92905. * The font texture used to render the char in the post process.
  92906. */
  92907. private _asciiArtFontTexture;
  92908. /**
  92909. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92910. * This number is defined between 0 and 1;
  92911. */
  92912. mixToTile: number;
  92913. /**
  92914. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92915. * This number is defined between 0 and 1;
  92916. */
  92917. mixToNormal: number;
  92918. /**
  92919. * Instantiates a new Ascii Art Post Process.
  92920. * @param name the name to give to the postprocess
  92921. * @camera the camera to apply the post process to.
  92922. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  92923. */
  92924. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  92925. }
  92926. }
  92927. declare module BABYLON {
  92928. /** @hidden */
  92929. export var digitalrainPixelShader: {
  92930. name: string;
  92931. shader: string;
  92932. };
  92933. }
  92934. declare module BABYLON {
  92935. /**
  92936. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  92937. *
  92938. * It basically takes care rendering the font front the given font size to a texture.
  92939. * This is used later on in the postprocess.
  92940. */
  92941. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  92942. private _font;
  92943. private _text;
  92944. private _charSize;
  92945. /**
  92946. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92947. */
  92948. get charSize(): number;
  92949. /**
  92950. * Create a new instance of the Digital Rain FontTexture class
  92951. * @param name the name of the texture
  92952. * @param font the font to use, use the W3C CSS notation
  92953. * @param text the caracter set to use in the rendering.
  92954. * @param scene the scene that owns the texture
  92955. */
  92956. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92957. /**
  92958. * Gets the max char width of a font.
  92959. * @param font the font to use, use the W3C CSS notation
  92960. * @return the max char width
  92961. */
  92962. private getFontWidth;
  92963. /**
  92964. * Gets the max char height of a font.
  92965. * @param font the font to use, use the W3C CSS notation
  92966. * @return the max char height
  92967. */
  92968. private getFontHeight;
  92969. /**
  92970. * Clones the current DigitalRainFontTexture.
  92971. * @return the clone of the texture.
  92972. */
  92973. clone(): DigitalRainFontTexture;
  92974. /**
  92975. * Parses a json object representing the texture and returns an instance of it.
  92976. * @param source the source JSON representation
  92977. * @param scene the scene to create the texture for
  92978. * @return the parsed texture
  92979. */
  92980. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  92981. }
  92982. /**
  92983. * Option available in the Digital Rain Post Process.
  92984. */
  92985. export interface IDigitalRainPostProcessOptions {
  92986. /**
  92987. * The font to use following the w3c font definition.
  92988. */
  92989. font?: string;
  92990. /**
  92991. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92992. * This number is defined between 0 and 1;
  92993. */
  92994. mixToTile?: number;
  92995. /**
  92996. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92997. * This number is defined between 0 and 1;
  92998. */
  92999. mixToNormal?: number;
  93000. }
  93001. /**
  93002. * DigitalRainPostProcess helps rendering everithing in digital rain.
  93003. *
  93004. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93005. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  93006. */
  93007. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  93008. /**
  93009. * The font texture used to render the char in the post process.
  93010. */
  93011. private _digitalRainFontTexture;
  93012. /**
  93013. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93014. * This number is defined between 0 and 1;
  93015. */
  93016. mixToTile: number;
  93017. /**
  93018. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93019. * This number is defined between 0 and 1;
  93020. */
  93021. mixToNormal: number;
  93022. /**
  93023. * Instantiates a new Digital Rain Post Process.
  93024. * @param name the name to give to the postprocess
  93025. * @camera the camera to apply the post process to.
  93026. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  93027. */
  93028. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  93029. }
  93030. }
  93031. declare module BABYLON {
  93032. /** @hidden */
  93033. export var brickProceduralTexturePixelShader: {
  93034. name: string;
  93035. shader: string;
  93036. };
  93037. }
  93038. declare module BABYLON {
  93039. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  93040. private _numberOfBricksHeight;
  93041. private _numberOfBricksWidth;
  93042. private _jointColor;
  93043. private _brickColor;
  93044. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93045. updateShaderUniforms(): void;
  93046. get numberOfBricksHeight(): number;
  93047. set numberOfBricksHeight(value: number);
  93048. get numberOfBricksWidth(): number;
  93049. set numberOfBricksWidth(value: number);
  93050. get jointColor(): BABYLON.Color3;
  93051. set jointColor(value: BABYLON.Color3);
  93052. get brickColor(): BABYLON.Color3;
  93053. set brickColor(value: BABYLON.Color3);
  93054. /**
  93055. * Serializes this brick procedural texture
  93056. * @returns a serialized brick procedural texture object
  93057. */
  93058. serialize(): any;
  93059. /**
  93060. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  93061. * @param parsedTexture defines parsed texture data
  93062. * @param scene defines the current scene
  93063. * @param rootUrl defines the root URL containing brick procedural texture information
  93064. * @returns a parsed Brick Procedural BABYLON.Texture
  93065. */
  93066. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  93067. }
  93068. }
  93069. declare module BABYLON {
  93070. /** @hidden */
  93071. export var cloudProceduralTexturePixelShader: {
  93072. name: string;
  93073. shader: string;
  93074. };
  93075. }
  93076. declare module BABYLON {
  93077. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  93078. private _skyColor;
  93079. private _cloudColor;
  93080. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93081. updateShaderUniforms(): void;
  93082. get skyColor(): BABYLON.Color4;
  93083. set skyColor(value: BABYLON.Color4);
  93084. get cloudColor(): BABYLON.Color4;
  93085. set cloudColor(value: BABYLON.Color4);
  93086. /**
  93087. * Serializes this cloud procedural texture
  93088. * @returns a serialized cloud procedural texture object
  93089. */
  93090. serialize(): any;
  93091. /**
  93092. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  93093. * @param parsedTexture defines parsed texture data
  93094. * @param scene defines the current scene
  93095. * @param rootUrl defines the root URL containing cloud procedural texture information
  93096. * @returns a parsed Cloud Procedural BABYLON.Texture
  93097. */
  93098. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  93099. }
  93100. }
  93101. declare module BABYLON {
  93102. /** @hidden */
  93103. export var fireProceduralTexturePixelShader: {
  93104. name: string;
  93105. shader: string;
  93106. };
  93107. }
  93108. declare module BABYLON {
  93109. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  93110. private _time;
  93111. private _speed;
  93112. private _autoGenerateTime;
  93113. private _fireColors;
  93114. private _alphaThreshold;
  93115. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93116. updateShaderUniforms(): void;
  93117. render(useCameraPostProcess?: boolean): void;
  93118. static get PurpleFireColors(): BABYLON.Color3[];
  93119. static get GreenFireColors(): BABYLON.Color3[];
  93120. static get RedFireColors(): BABYLON.Color3[];
  93121. static get BlueFireColors(): BABYLON.Color3[];
  93122. get autoGenerateTime(): boolean;
  93123. set autoGenerateTime(value: boolean);
  93124. get fireColors(): BABYLON.Color3[];
  93125. set fireColors(value: BABYLON.Color3[]);
  93126. get time(): number;
  93127. set time(value: number);
  93128. get speed(): BABYLON.Vector2;
  93129. set speed(value: BABYLON.Vector2);
  93130. get alphaThreshold(): number;
  93131. set alphaThreshold(value: number);
  93132. /**
  93133. * Serializes this fire procedural texture
  93134. * @returns a serialized fire procedural texture object
  93135. */
  93136. serialize(): any;
  93137. /**
  93138. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  93139. * @param parsedTexture defines parsed texture data
  93140. * @param scene defines the current scene
  93141. * @param rootUrl defines the root URL containing fire procedural texture information
  93142. * @returns a parsed Fire Procedural BABYLON.Texture
  93143. */
  93144. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  93145. }
  93146. }
  93147. declare module BABYLON {
  93148. /** @hidden */
  93149. export var grassProceduralTexturePixelShader: {
  93150. name: string;
  93151. shader: string;
  93152. };
  93153. }
  93154. declare module BABYLON {
  93155. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  93156. private _grassColors;
  93157. private _groundColor;
  93158. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93159. updateShaderUniforms(): void;
  93160. get grassColors(): BABYLON.Color3[];
  93161. set grassColors(value: BABYLON.Color3[]);
  93162. get groundColor(): BABYLON.Color3;
  93163. set groundColor(value: BABYLON.Color3);
  93164. /**
  93165. * Serializes this grass procedural texture
  93166. * @returns a serialized grass procedural texture object
  93167. */
  93168. serialize(): any;
  93169. /**
  93170. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  93171. * @param parsedTexture defines parsed texture data
  93172. * @param scene defines the current scene
  93173. * @param rootUrl defines the root URL containing grass procedural texture information
  93174. * @returns a parsed Grass Procedural BABYLON.Texture
  93175. */
  93176. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  93177. }
  93178. }
  93179. declare module BABYLON {
  93180. /** @hidden */
  93181. export var marbleProceduralTexturePixelShader: {
  93182. name: string;
  93183. shader: string;
  93184. };
  93185. }
  93186. declare module BABYLON {
  93187. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  93188. private _numberOfTilesHeight;
  93189. private _numberOfTilesWidth;
  93190. private _amplitude;
  93191. private _jointColor;
  93192. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93193. updateShaderUniforms(): void;
  93194. get numberOfTilesHeight(): number;
  93195. set numberOfTilesHeight(value: number);
  93196. get amplitude(): number;
  93197. set amplitude(value: number);
  93198. get numberOfTilesWidth(): number;
  93199. set numberOfTilesWidth(value: number);
  93200. get jointColor(): BABYLON.Color3;
  93201. set jointColor(value: BABYLON.Color3);
  93202. /**
  93203. * Serializes this marble procedural texture
  93204. * @returns a serialized marble procedural texture object
  93205. */
  93206. serialize(): any;
  93207. /**
  93208. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  93209. * @param parsedTexture defines parsed texture data
  93210. * @param scene defines the current scene
  93211. * @param rootUrl defines the root URL containing marble procedural texture information
  93212. * @returns a parsed Marble Procedural BABYLON.Texture
  93213. */
  93214. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  93215. }
  93216. }
  93217. declare module BABYLON {
  93218. /** @hidden */
  93219. export var normalMapProceduralTexturePixelShader: {
  93220. name: string;
  93221. shader: string;
  93222. };
  93223. }
  93224. declare module BABYLON {
  93225. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  93226. private _baseTexture;
  93227. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93228. updateShaderUniforms(): void;
  93229. render(useCameraPostProcess?: boolean): void;
  93230. resize(size: any, generateMipMaps: any): void;
  93231. isReady(): boolean;
  93232. get baseTexture(): BABYLON.Texture;
  93233. set baseTexture(texture: BABYLON.Texture);
  93234. /**
  93235. * Serializes this normal map procedural texture
  93236. * @returns a serialized normal map procedural texture object
  93237. */
  93238. serialize(): any;
  93239. /**
  93240. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  93241. * @param parsedTexture defines parsed texture data
  93242. * @param scene defines the current scene
  93243. * @param rootUrl defines the root URL containing normal map procedural texture information
  93244. * @returns a parsed Normal Map Procedural BABYLON.Texture
  93245. */
  93246. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  93247. }
  93248. }
  93249. declare module BABYLON {
  93250. /** @hidden */
  93251. export var perlinNoiseProceduralTexturePixelShader: {
  93252. name: string;
  93253. shader: string;
  93254. };
  93255. }
  93256. declare module BABYLON {
  93257. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  93258. time: number;
  93259. timeScale: number;
  93260. translationSpeed: number;
  93261. private _currentTranslation;
  93262. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93263. updateShaderUniforms(): void;
  93264. render(useCameraPostProcess?: boolean): void;
  93265. resize(size: any, generateMipMaps: any): void;
  93266. /**
  93267. * Serializes this perlin noise procedural texture
  93268. * @returns a serialized perlin noise procedural texture object
  93269. */
  93270. serialize(): any;
  93271. /**
  93272. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  93273. * @param parsedTexture defines parsed texture data
  93274. * @param scene defines the current scene
  93275. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  93276. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  93277. */
  93278. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  93279. }
  93280. }
  93281. declare module BABYLON {
  93282. /** @hidden */
  93283. export var roadProceduralTexturePixelShader: {
  93284. name: string;
  93285. shader: string;
  93286. };
  93287. }
  93288. declare module BABYLON {
  93289. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  93290. private _roadColor;
  93291. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93292. updateShaderUniforms(): void;
  93293. get roadColor(): BABYLON.Color3;
  93294. set roadColor(value: BABYLON.Color3);
  93295. /**
  93296. * Serializes this road procedural texture
  93297. * @returns a serialized road procedural texture object
  93298. */
  93299. serialize(): any;
  93300. /**
  93301. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  93302. * @param parsedTexture defines parsed texture data
  93303. * @param scene defines the current scene
  93304. * @param rootUrl defines the root URL containing road procedural texture information
  93305. * @returns a parsed Road Procedural BABYLON.Texture
  93306. */
  93307. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  93308. }
  93309. }
  93310. declare module BABYLON {
  93311. /** @hidden */
  93312. export var starfieldProceduralTexturePixelShader: {
  93313. name: string;
  93314. shader: string;
  93315. };
  93316. }
  93317. declare module BABYLON {
  93318. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  93319. private _time;
  93320. private _alpha;
  93321. private _beta;
  93322. private _zoom;
  93323. private _formuparam;
  93324. private _stepsize;
  93325. private _tile;
  93326. private _brightness;
  93327. private _darkmatter;
  93328. private _distfading;
  93329. private _saturation;
  93330. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93331. updateShaderUniforms(): void;
  93332. get time(): number;
  93333. set time(value: number);
  93334. get alpha(): number;
  93335. set alpha(value: number);
  93336. get beta(): number;
  93337. set beta(value: number);
  93338. get formuparam(): number;
  93339. set formuparam(value: number);
  93340. get stepsize(): number;
  93341. set stepsize(value: number);
  93342. get zoom(): number;
  93343. set zoom(value: number);
  93344. get tile(): number;
  93345. set tile(value: number);
  93346. get brightness(): number;
  93347. set brightness(value: number);
  93348. get darkmatter(): number;
  93349. set darkmatter(value: number);
  93350. get distfading(): number;
  93351. set distfading(value: number);
  93352. get saturation(): number;
  93353. set saturation(value: number);
  93354. /**
  93355. * Serializes this starfield procedural texture
  93356. * @returns a serialized starfield procedural texture object
  93357. */
  93358. serialize(): any;
  93359. /**
  93360. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  93361. * @param parsedTexture defines parsed texture data
  93362. * @param scene defines the current scene
  93363. * @param rootUrl defines the root URL containing startfield procedural texture information
  93364. * @returns a parsed Starfield Procedural BABYLON.Texture
  93365. */
  93366. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  93367. }
  93368. }
  93369. declare module BABYLON {
  93370. /** @hidden */
  93371. export var woodProceduralTexturePixelShader: {
  93372. name: string;
  93373. shader: string;
  93374. };
  93375. }
  93376. declare module BABYLON {
  93377. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  93378. private _ampScale;
  93379. private _woodColor;
  93380. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93381. updateShaderUniforms(): void;
  93382. get ampScale(): number;
  93383. set ampScale(value: number);
  93384. get woodColor(): BABYLON.Color3;
  93385. set woodColor(value: BABYLON.Color3);
  93386. /**
  93387. * Serializes this wood procedural texture
  93388. * @returns a serialized wood procedural texture object
  93389. */
  93390. serialize(): any;
  93391. /**
  93392. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  93393. * @param parsedTexture defines parsed texture data
  93394. * @param scene defines the current scene
  93395. * @param rootUrl defines the root URL containing wood procedural texture information
  93396. * @returns a parsed Wood Procedural BABYLON.Texture
  93397. */
  93398. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  93399. }
  93400. }